Skip to content

Fix visible_parent_map fallback map merging perf regression - #160811

Merged
rust-bors[bot] merged 1 commit into
rust-lang:mainfrom
zalanlevai:160464-perf-regression
Aug 11, 2026
Merged

Fix visible_parent_map fallback map merging perf regression#160811
rust-bors[bot] merged 1 commit into
rust-lang:mainfrom
zalanlevai:160464-perf-regression

Conversation

@zalanlevai

@zalanlevai zalanlevai commented Aug 9, 2026

Copy link
Copy Markdown
Contributor

View all comments

This PR attempts to fix the visible_parent_map perf regression introduced in #160464, which was found in a post-merge perf run.

Because the original PR fixes unnecessary iterations in the breadth-first search (BFS), meaning that it only reduces the amount of work during the BFS, the likely cause of the perf regression is the changed merging of the fallback map into the final visible parent map after the BFS.

The goal of this PR is to determine whether this is the case through a perf try run. The change itself works around the Unord* APIs, but might be worth it to work around the perf regression.

  • I did not use an LLM to create a change in this PR.
  • I used an LLM to create a change in this PR, and I have explained below how it was used.

@rustbot rustbot added S-waiting-on-author Status: This is awaiting some action (such as code changes or more information) from the author. T-compiler Relevant to the compiler team, which will review and decide on the PR/issue. labels Aug 9, 2026
@JonathanBrouwer

Copy link
Copy Markdown
Contributor

@bors try @rust-timer queue

@rust-timer

This comment has been minimized.

@rustbot rustbot added the S-waiting-on-perf Status: Waiting on a perf run to be completed. label Aug 9, 2026
@rust-bors

This comment has been minimized.

rust-bors Bot pushed a commit that referenced this pull request Aug 9, 2026
Fix visible_parent_map fallback map merging perf regression
@rust-bors

rust-bors Bot commented Aug 9, 2026

Copy link
Copy Markdown
Contributor

☀️ Try build successful (CI)
Build commit: 9cbccc7 (9cbccc762cb6f14132feb088e9dd05ce77b54760)
Base parent: 153ecc4 (153ecc4f74035b709bb3e1eb9546f1d934865042)

@rust-timer

This comment has been minimized.

@rust-timer

Copy link
Copy Markdown
Collaborator

Finished benchmarking commit (9cbccc7): comparison URL.

Overall result: ❌✅ regressions and improvements - please read:

Benchmarking means the PR may be perf-sensitive. It's automatically marked not fit for rolling up. Overriding is possible but disadvised: it risks changing compiler perf.

Next, please: If you can, justify the regressions found in this try perf run in writing along with @rustbot label: +perf-regression-triaged. If not, fix the regressions and do another perf run. Neutral or positive results will clear the label automatically.

@bors rollup=never rustc-perf
@rustbot label: -S-waiting-on-perf +perf-regression

Instruction count

Our most reliable metric. Used to determine the overall result above. However, even this metric can be noisy.

mean range count
Regressions ❌
(primary)
- - 0
Regressions ❌
(secondary)
0.4% [0.2%, 0.5%] 7
Improvements ✅
(primary)
- - 0
Improvements ✅
(secondary)
-0.4% [-0.5%, -0.4%] 6
All ❌✅ (primary) - - 0

Max RSS (memory usage)

Results (primary -9.2%, secondary -0.4%)

A less reliable metric. May be of interest, but not used to determine the overall result above.

mean range count
Regressions ❌
(primary)
- - 0
Regressions ❌
(secondary)
0.6% [0.5%, 0.8%] 5
Improvements ✅
(primary)
-9.2% [-9.2%, -9.2%] 1
Improvements ✅
(secondary)
-0.8% [-2.4%, -0.4%] 10
All ❌✅ (primary) -9.2% [-9.2%, -9.2%] 1

Cycles

Results (secondary 0.2%)

A less reliable metric. May be of interest, but not used to determine the overall result above.

mean range count
Regressions ❌
(primary)
- - 0
Regressions ❌
(secondary)
1.2% [0.4%, 5.0%] 11
Improvements ✅
(primary)
- - 0
Improvements ✅
(secondary)
-0.7% [-1.6%, -0.4%] 11
All ❌✅ (primary) - - 0

Binary size

This perf run didn't have relevant results for this metric.

Bootstrap: 458.036s -> 460.145s (0.46%)
Artifact size: 398.61 MiB -> 398.66 MiB (0.01%)

@rustbot rustbot added perf-regression Performance regression. and removed S-waiting-on-perf Status: Waiting on a perf run to be completed. labels Aug 9, 2026
@zalanlevai

zalanlevai commented Aug 9, 2026

Copy link
Copy Markdown
Contributor Author

@JonathanBrouwer Thanks! I had a look through the perf run results and compared each benchmark that regressed in #160464 with the corresponding benchmark in this perf run. This change resolves all 7 perf regressions introduced in #160464, with the percentage deltas in this perf run cancelling out the ones in the perf run of the regressed PR.

This change's perf run also shows 7 other perf regressions of similar magnitude: 5 are the deep-vector benchmark and the other two are the tuple-stress benchmark. However, looking at their code, these two benchmarks do not contain code that would be affected by this change, at least from what I can tell. Looking at the profiles for these regressed benchmarks, the visible_parent_map query is not significant enough to show up in any of the before or after profiles. Do you think these new regressions could be a fluke or unrelated to this change?

@zalanlevai

Copy link
Copy Markdown
Contributor Author

I believe this is the correct label given the findings in my previous comment.

@rustbot label +perf-regression-triaged

@rustbot rustbot added the perf-regression-triaged The performance regression has been triaged. label Aug 9, 2026
@zalanlevai zalanlevai changed the title Fix visible_parent_map fallback map merging perf regression Fix visible_parent_map fallback map merging perf regression Aug 10, 2026
@zalanlevai
zalanlevai marked this pull request as ready for review August 10, 2026 00:57
@rustbot rustbot added the S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. label Aug 10, 2026
@rustbot rustbot removed the S-waiting-on-author Status: This is awaiting some action (such as code changes or more information) from the author. label Aug 10, 2026
@rustbot

rustbot commented Aug 10, 2026

Copy link
Copy Markdown
Collaborator

r? @davidtwco

rustbot has assigned @davidtwco.
They will have a look at your PR within the next two weeks and either review your PR or reassign to another reviewer.

Use r? to explicitly pick a reviewer

Why was this reviewer chosen?

The reviewer was selected based on:

  • Owners of files modified in this PR: compiler
  • compiler expanded to 75 candidates
  • Random selection from 19 candidates

@panstromek

panstromek commented Aug 10, 2026

Copy link
Copy Markdown
Contributor

This change resolves all 7 perf regressions introduced in #160464

I think Jonathan won't have time today, so I'll just confirm, this looks legit, I think your assessment is correct.

Do you think these new regressions could be a fluke or unrelated to this change?

The deep-vector and tuple-stress changes are a bit puzzling, but it could be some artifact noise, we see that relatively often, especially for those tiny stress tests. We can try to re-measure with up to date parent or just wait on post-merge results, that'll usually show something different so we know it's noise.

@zalanlevai
zalanlevai force-pushed the 160464-perf-regression branch from a553c6f to d577cbc Compare August 10, 2026 15:05
@rustbot

rustbot commented Aug 10, 2026

Copy link
Copy Markdown
Collaborator

This PR was rebased onto a different main commit. Here's a range-diff highlighting what actually changed.

Rebasing is a normal part of keeping PRs up to date, so no action is needed—this note is just to help reviewers.

@zalanlevai

Copy link
Copy Markdown
Contributor Author

Thank you @panstromek for taking a look at this! Just to be safe, I rebased the PR onto latest main to see whether these new regressions are real. Could you please re-run a try build perf run on this so we can see whether the results are any different?

@panstromek

Copy link
Copy Markdown
Contributor

@bors try @rust-timer queue

@rust-timer

This comment has been minimized.

@rustbot rustbot added the S-waiting-on-perf Status: Waiting on a perf run to be completed. label Aug 10, 2026
@rust-bors

This comment has been minimized.

rust-bors Bot pushed a commit that referenced this pull request Aug 10, 2026
Fix `visible_parent_map` fallback map merging perf regression
@rust-bors

rust-bors Bot commented Aug 10, 2026

Copy link
Copy Markdown
Contributor

☀️ Try build successful (CI)
Build commit: a7be450 (a7be4507d612028cbc821ef97eefd7d31c20ed10)
Base parent: 7088e4b (7088e4b63a9516ebfbfe2ab2d999cf01a528ac14)

@rust-timer

This comment has been minimized.

@rust-timer

Copy link
Copy Markdown
Collaborator

Finished benchmarking commit (a7be450): comparison URL.

Overall result: ✅ improvements - no action needed

Benchmarking means the PR may be perf-sensitive. Consider adding rollup=never if this change is not fit for rolling up.

@rustbot label: -S-waiting-on-perf -perf-regression

Instruction count

Our most reliable metric. Used to determine the overall result above. However, even this metric can be noisy.

mean range count
Regressions ❌
(primary)
- - 0
Regressions ❌
(secondary)
- - 0
Improvements ✅
(primary)
- - 0
Improvements ✅
(secondary)
-0.4% [-0.5%, -0.4%] 6
All ❌✅ (primary) - - 0

Max RSS (memory usage)

Results (secondary -0.3%)

A less reliable metric. May be of interest, but not used to determine the overall result above.

mean range count
Regressions ❌
(primary)
- - 0
Regressions ❌
(secondary)
2.6% [1.0%, 6.0%] 3
Improvements ✅
(primary)
- - 0
Improvements ✅
(secondary)
-1.1% [-3.4%, -0.4%] 12
All ❌✅ (primary) - - 0

Cycles

Results (secondary 1.8%)

A less reliable metric. May be of interest, but not used to determine the overall result above.

mean range count
Regressions ❌
(primary)
- - 0
Regressions ❌
(secondary)
3.8% [0.4%, 16.4%] 13
Improvements ✅
(primary)
- - 0
Improvements ✅
(secondary)
-0.8% [-1.2%, -0.5%] 10
All ❌✅ (primary) - - 0

Binary size

This perf run didn't have relevant results for this metric.

Bootstrap: 455.179s -> 454.498s (-0.15%)
Artifact size: 398.37 MiB -> 399.13 MiB (0.19%)

@rustbot rustbot removed S-waiting-on-perf Status: Waiting on a perf run to be completed. perf-regression Performance regression. labels Aug 10, 2026
@zalanlevai

Copy link
Copy Markdown
Contributor Author

Yay! This perf run neatly shows that the original regressions are still gone (including wg-grammar, which is just right below the significance threshold to be shown in the overview) and that no other benchmarks were affected by this change.

@JonathanBrouwer JonathanBrouwer left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@bors r+
Thanks for taking a look at this!

View changes since this review

@rust-bors

rust-bors Bot commented Aug 10, 2026

Copy link
Copy Markdown
Contributor

📌 Commit d577cbc has been approved by JonathanBrouwer

It is now in the queue for this repository.

@rust-bors rust-bors Bot added S-waiting-on-bors Status: Waiting on bors to run and complete tests. Bors will change the label on completion. and removed S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. labels Aug 10, 2026
@JonathanBrouwer

Copy link
Copy Markdown
Contributor

@bors rollup=iffy
Perf effect is pretty small so I'm throwing this in a small rolluo

rust-bors Bot pushed a commit that referenced this pull request Aug 11, 2026
…uwer

Rollup of 7 pull requests

Successful merges:

 - #160629 ([Priroda] Add bootstrap test and check steps)
 - #160811 (Fix `visible_parent_map` fallback map merging perf regression)
 - #154329 (Diagnostics ICE when replaying proof trees with next-solver)
 - #157841 (Ensure inferred let pattern types are well-formed)
 - #159300 (Implement `to_string()` on `ByteStr` and `ByteString`)
 - #160858 (Add regression test for assoc const panic ICE in match)
 - #160864 (Rename `HostEffectPredicate` to `HostEffectClause`)
@rust-bors
rust-bors Bot merged commit 65c0a8b into rust-lang:main Aug 11, 2026
14 checks passed
@rustbot rustbot added this to the 1.99.0 milestone Aug 11, 2026
rust-timer added a commit that referenced this pull request Aug 11, 2026
Rollup merge of #160811 - zalanlevai:160464-perf-regression, r=JonathanBrouwer

Fix `visible_parent_map` fallback map merging perf regression

This PR attempts to fix the `visible_parent_map` perf regression introduced in #160464, which was found in a [post-merge perf run](#160464 (comment)).

Because the original PR fixes unnecessary iterations in the breadth-first search (BFS), meaning that it only reduces the amount of work during the BFS, the likely cause of the perf regression is the changed merging of the fallback map into the final visible parent map after the BFS.

The goal of this PR is to determine whether this is the case through a perf try run. The change itself works around the Unord* APIs, but might be worth it to work around the perf regression.
github-actions Bot pushed a commit to rust-lang/rustc-dev-guide that referenced this pull request Aug 11, 2026
…uwer

Rollup of 7 pull requests

Successful merges:

 - rust-lang/rust#160629 ([Priroda] Add bootstrap test and check steps)
 - rust-lang/rust#160811 (Fix `visible_parent_map` fallback map merging perf regression)
 - rust-lang/rust#154329 (Diagnostics ICE when replaying proof trees with next-solver)
 - rust-lang/rust#157841 (Ensure inferred let pattern types are well-formed)
 - rust-lang/rust#159300 (Implement `to_string()` on `ByteStr` and `ByteString`)
 - rust-lang/rust#160858 (Add regression test for assoc const panic ICE in match)
 - rust-lang/rust#160864 (Rename `HostEffectPredicate` to `HostEffectClause`)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

perf-regression-triaged The performance regression has been triaged. S-waiting-on-bors Status: Waiting on bors to run and complete tests. Bors will change the label on completion. T-compiler Relevant to the compiler team, which will review and decide on the PR/issue.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

6 participants