Skip to content

Conversation

cjgillot
Copy link
Contributor

I was puzzled that #142390 introduces additional computations of CFG traversals: borrowck computes them, right?

It turns out that borrowck clones the MIR body, so doesn't share its cache with other analyses.

This PR:

  • forces the computation of all caches in mir_promoted query;
  • modifies region renumbering to avoid dropping that cache.

@rustbot
Copy link
Collaborator

rustbot commented Jun 15, 2025

r? @fee1-dead

rustbot has assigned @fee1-dead.
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

@rustbot rustbot added S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. T-compiler Relevant to the compiler team, which will review and decide on the PR/issue. labels Jun 15, 2025
@rustbot
Copy link
Collaborator

rustbot commented Jun 15, 2025

Some changes occurred to MIR optimizations

cc @rust-lang/wg-mir-opt

@cjgillot
Copy link
Contributor Author

@bors2 try @rust-timer queue

@rust-timer

This comment has been minimized.

@rust-bors
Copy link

rust-bors bot commented Jun 15, 2025

⌛ Trying commit e7e8f6d with merge 18218cc

To cancel the try build, run the command @bors2 try cancel.

rust-bors bot added a commit that referenced this pull request Jun 15, 2025
Pre-compute MIR CFG caches for borrowck and other analyses

I was puzzled that #142390 introduces additional computations of CFG traversals: borrowck computes them, right?

It turns out that borrowck clones the MIR body, so doesn't share its cache with other analyses.

This PR:
- forces the computation of all caches in `mir_promoted` query;
- modifies region renumbering to avoid dropping that cache.

<!-- homu-ignore:start -->
<!--
If this PR is related to an unstable feature or an otherwise tracked effort,
please link to the relevant tracking issue here. If you don't know of a related
tracking issue or there are none, feel free to ignore this.

This PR will get automatically assigned to a reviewer. In case you would like
a specific user to review your work, you can assign it to them by using

    r? <reviewer name>
-->
<!-- homu-ignore:end -->
@rustbot rustbot added the S-waiting-on-perf Status: Waiting on a perf run to be completed. label Jun 15, 2025
@rust-bors
Copy link

rust-bors bot commented Jun 15, 2025

☀️ Try build successful (CI)
Build commit: 18218cc (18218cc5c664c3521f4769f46ef5e5e10128c92c, parent: 75e7cf5f85aad82331a38deff24845b63eaf30f3)

@rust-timer

This comment has been minimized.

@rust-timer
Copy link
Collaborator

Finished benchmarking commit (18218cc): comparison URL.

Overall result: ❌ regressions - please read the text below

Benchmarking this pull request means it may be perf-sensitive – we'll automatically label it not fit for rolling up. You can override this, but we strongly advise not to, due to possible changes in compiler perf.

Next Steps: If you can justify the regressions found in this try perf run, please do so in sufficient writing along with @rustbot label: +perf-regression-triaged. If not, please fix the regressions and do another perf run. If its results are neutral or positive, the label will be automatically removed.

@bors rollup=never
@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.5% [0.2%, 2.9%] 68
Regressions ❌
(secondary)
0.7% [0.2%, 1.8%] 47
Improvements ✅
(primary)
- - 0
Improvements ✅
(secondary)
- - 0
All ❌✅ (primary) 0.5% [0.2%, 2.9%] 68

Max RSS (memory usage)

Results (primary 1.7%, secondary 1.3%)

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

mean range count
Regressions ❌
(primary)
1.7% [0.9%, 2.8%] 12
Regressions ❌
(secondary)
2.5% [2.0%, 3.0%] 2
Improvements ✅
(primary)
- - 0
Improvements ✅
(secondary)
-1.2% [-1.2%, -1.2%] 1
All ❌✅ (primary) 1.7% [0.9%, 2.8%] 12

Cycles

Results (primary 1.1%)

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

mean range count
Regressions ❌
(primary)
1.1% [0.7%, 1.4%] 2
Regressions ❌
(secondary)
- - 0
Improvements ✅
(primary)
- - 0
Improvements ✅
(secondary)
- - 0
All ❌✅ (primary) 1.1% [0.7%, 1.4%] 2

Binary size

This benchmark run did not return any relevant results for this metric.

Bootstrap: 756.494s -> 756.086s (-0.05%)
Artifact size: 372.15 MiB -> 372.18 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 Jun 15, 2025
@cjgillot
Copy link
Contributor Author

Perf deserves investigation. I really didn't expect mir_borrowck to get slower.

@cjgillot
Copy link
Contributor Author

@bors2 try @rust-timer queue

@rust-timer

This comment has been minimized.

@rust-bors
Copy link

rust-bors bot commented Jun 15, 2025

⌛ Trying commit 3e77d40 with merge 98e2e6a

To cancel the try build, run the command @bors2 try cancel.

rust-bors bot added a commit that referenced this pull request Jun 15, 2025
Pre-compute MIR CFG caches for borrowck and other analyses

I was puzzled that #142390 introduces additional computations of CFG traversals: borrowck computes them, right?

It turns out that borrowck clones the MIR body, so doesn't share its cache with other analyses.

This PR:
- forces the computation of all caches in `mir_promoted` query;
- modifies region renumbering to avoid dropping that cache.

<!-- homu-ignore:start -->
<!--
If this PR is related to an unstable feature or an otherwise tracked effort,
please link to the relevant tracking issue here. If you don't know of a related
tracking issue or there are none, feel free to ignore this.

This PR will get automatically assigned to a reviewer. In case you would like
a specific user to review your work, you can assign it to them by using

    r? <reviewer name>
-->
<!-- homu-ignore:end -->
@rustbot rustbot added the S-waiting-on-perf Status: Waiting on a perf run to be completed. label Jun 15, 2025
@rust-bors
Copy link

rust-bors bot commented Jun 15, 2025

☀️ Try build successful (CI)
Build commit: 98e2e6a (98e2e6aea9abc7e12f76e27d72aced95f45b5260, parent: 586ad391f5ee4519acc7cae340e34673bae762b1)

@rust-timer

This comment has been minimized.

@rust-timer
Copy link
Collaborator

Finished benchmarking commit (98e2e6a): comparison URL.

Overall result: ❌ regressions - please read the text below

Benchmarking this pull request means it may be perf-sensitive – we'll automatically label it not fit for rolling up. You can override this, but we strongly advise not to, due to possible changes in compiler perf.

Next Steps: If you can justify the regressions found in this try perf run, please do so in sufficient writing along with @rustbot label: +perf-regression-triaged. If not, please fix the regressions and do another perf run. If its results are neutral or positive, the label will be automatically removed.

@bors rollup=never
@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)
1.8% [1.0%, 2.6%] 4
Regressions ❌
(secondary)
1.2% [0.6%, 1.6%] 6
Improvements ✅
(primary)
- - 0
Improvements ✅
(secondary)
- - 0
All ❌✅ (primary) 1.8% [1.0%, 2.6%] 4

Max RSS (memory usage)

Results (primary 0.1%, secondary -2.5%)

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

mean range count
Regressions ❌
(primary)
3.1% [0.5%, 6.5%] 3
Regressions ❌
(secondary)
- - 0
Improvements ✅
(primary)
-1.4% [-1.8%, -0.8%] 6
Improvements ✅
(secondary)
-2.5% [-2.7%, -2.2%] 2
All ❌✅ (primary) 0.1% [-1.8%, 6.5%] 9

Cycles

Results (secondary 1.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% [1.2%, 1.2%] 1
Improvements ✅
(primary)
- - 0
Improvements ✅
(secondary)
- - 0
All ❌✅ (primary) - - 0

Binary size

This benchmark run did not return any relevant results for this metric.

Bootstrap: 755.712s -> 754.846s (-0.11%)
Artifact size: 372.06 MiB -> 372.09 MiB (0.01%)

@rustbot rustbot removed the S-waiting-on-perf Status: Waiting on a perf run to be completed. label Jun 16, 2025
@cjgillot
Copy link
Contributor Author

Rebased onto #142542
@bors2 try @rust-timer queue

@rust-timer

This comment has been minimized.

@rust-bors
Copy link

rust-bors bot commented Jun 16, 2025

⌛ Trying commit ba39fdf with merge 0e5f13e

To cancel the try build, run the command @bors2 try cancel.

@rustbot
Copy link
Collaborator

rustbot commented Oct 12, 2025

This PR was rebased onto a different master 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.

@cjgillot
Copy link
Contributor Author

@bors2 try @rust-timer queue

@rust-timer

This comment has been minimized.

@rust-bors

This comment has been minimized.

rust-bors bot added a commit that referenced this pull request Oct 12, 2025
Pre-compute MIR CFG caches for borrowck and other analyses
@rustbot rustbot added the S-waiting-on-perf Status: Waiting on a perf run to be completed. label Oct 12, 2025
@rust-bors
Copy link

rust-bors bot commented Oct 12, 2025

☀️ Try build successful (CI)
Build commit: 8e7d148 (8e7d14809b3504ba2f2a9e8caa6ae58e9c5fe86b, parent: ff6dc928c5e33ce8e65c6911a790b9efcb5ef53a)

@rust-timer

This comment has been minimized.

@rust-timer
Copy link
Collaborator

Finished benchmarking commit (8e7d148): comparison URL.

Overall result: ❌✅ regressions and improvements - please read the text below

Benchmarking this pull request means it may be perf-sensitive – we'll automatically label it not fit for rolling up. You can override this, but we strongly advise not to, due to possible changes in compiler perf.

Next Steps: If you can justify the regressions found in this try perf run, please do so in sufficient writing along with @rustbot label: +perf-regression-triaged. If not, please fix the regressions and do another perf run. If its results are neutral or positive, the label will be automatically removed.

@bors rollup=never
@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)
1.5% [0.3%, 2.6%] 5
Regressions ❌
(secondary)
1.5% [1.1%, 1.8%] 4
Improvements ✅
(primary)
-0.2% [-0.4%, -0.1%] 49
Improvements ✅
(secondary)
-0.2% [-0.3%, -0.0%] 35
All ❌✅ (primary) -0.0% [-0.4%, 2.6%] 54

Max RSS (memory usage)

Results (primary -2.9%, secondary -0.7%)

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.5% [0.5%, 2.5%] 2
Improvements ✅
(primary)
-2.9% [-6.8%, -0.8%] 3
Improvements ✅
(secondary)
-1.3% [-2.1%, -0.6%] 8
All ❌✅ (primary) -2.9% [-6.8%, -0.8%] 3

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)
2.3% [2.1%, 2.4%] 2
Improvements ✅
(primary)
- - 0
Improvements ✅
(secondary)
-4.0% [-4.0%, -4.0%] 1
All ❌✅ (primary) - - 0

Binary size

This benchmark run did not return any relevant results for this metric.

Bootstrap: 471.991s -> 473.105s (0.24%)
Artifact size: 388.12 MiB -> 388.10 MiB (-0.01%)

@rustbot rustbot removed the S-waiting-on-perf Status: Waiting on a perf run to be completed. label Oct 12, 2025
@cjgillot
Copy link
Contributor Author

I don't think I will do better here. This is an improvement on all but 2 benchmarks. I can't figure out why.
@rustbot ready

@rustbot rustbot added S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. and removed S-waiting-on-author Status: This is awaiting some action (such as code changes or more information) from the author. labels Oct 13, 2025
@fee1-dead
Copy link
Member

I think this is fine. We're seeing enough wins for more common Rust code (serde, image, syn, etc) that I think it is fine to take the hit for the two outliers (tt-muncher and cranelift-codegen for some reason), I do think it could be because of cloning taking more instructions than what gets saved, but I don't think that is preventable.

@bors r+ rollup=never

@bors
Copy link
Collaborator

bors commented Oct 17, 2025

📌 Commit 42ff108 has been approved by fee1-dead

It is now in the queue for this repository.

@bors bors 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 Oct 17, 2025
@bors
Copy link
Collaborator

bors commented Oct 17, 2025

⌛ Testing commit 42ff108 with merge 28fad95...

@bors
Copy link
Collaborator

bors commented Oct 18, 2025

☀️ Test successful - checks-actions
Approved by: fee1-dead
Pushing 28fad95 to master...

@bors bors added the merged-by-bors This PR was explicitly merged by bors. label Oct 18, 2025
@bors bors merged commit 28fad95 into rust-lang:master Oct 18, 2025
12 checks passed
@rustbot rustbot added this to the 1.92.0 milestone Oct 18, 2025
Copy link
Contributor

What is this? This is an experimental post-merge analysis report that shows differences in test outcomes between the merged PR and its parent PR.

Comparing f464759 (parent) -> 28fad95 (this PR)

Test differences

Show 2 test diffs

2 doctest diffs were found. These are ignored, as they are noisy.

Test dashboard

Run

cargo run --manifest-path src/ci/citool/Cargo.toml -- \
    test-dashboard 28fad9598975af7734be05116b3c5fc74b720d87 --output-dir test-dashboard

And then open test-dashboard/index.html in your browser to see an overview of all executed tests.

Job duration changes

  1. dist-x86_64-apple: 7239.0s -> 6005.0s (-17.0%)
  2. test-various: 4099.6s -> 4729.1s (15.4%)
  3. x86_64-gnu-gcc: 3053.2s -> 3465.6s (13.5%)
  4. x86_64-gnu-llvm-20-1: 3227.1s -> 3622.4s (12.2%)
  5. i686-gnu-nopt-1: 7316.6s -> 8196.5s (12.0%)
  6. i686-gnu-2: 5624.2s -> 6245.1s (11.0%)
  7. x86_64-gnu-llvm-20-3: 6452.3s -> 7156.3s (10.9%)
  8. x86_64-gnu-llvm-20: 2540.1s -> 2805.8s (10.5%)
  9. dist-aarch64-linux: 6579.6s -> 5964.6s (-9.3%)
  10. dist-apple-various: 3666.2s -> 4004.2s (9.2%)
How to interpret the job duration changes?

Job durations can vary a lot, based on the actual runner instance
that executed the job, system noise, invalidated caches, etc. The table above is provided
mostly for t-infra members, for simpler debugging of potential CI slow-downs.

@rust-timer
Copy link
Collaborator

Finished benchmarking commit (28fad95): comparison URL.

Overall result: ❌✅ regressions and improvements - please read the text below

Our benchmarks found a performance regression caused by this PR.
This might be an actual regression, but it can also be just noise.

Next Steps:

  • If the regression was expected or you think it can be justified,
    please write a comment with sufficient written justification, and add
    @rustbot label: +perf-regression-triaged to it, to mark the regression as triaged.
  • If you think that you know of a way to resolve the regression, try to create
    a new PR with a fix for the regression.
  • If you do not understand the regression or you think that it is just noise,
    you can ask the @rust-lang/wg-compiler-performance working group for help (members of this group
    were already notified of this PR).

@rustbot label: +perf-regression
cc @rust-lang/wg-compiler-performance

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)
1.7% [1.0%, 2.6%] 4
Regressions ❌
(secondary)
0.9% [0.1%, 1.6%] 6
Improvements ✅
(primary)
-0.2% [-0.3%, -0.1%] 15
Improvements ✅
(secondary)
-0.3% [-0.4%, -0.2%] 13
All ❌✅ (primary) 0.2% [-0.3%, 2.6%] 19

Max RSS (memory usage)

Results (primary -0.0%, secondary 0.5%)

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

mean range count
Regressions ❌
(primary)
3.0% [3.0%, 3.0%] 1
Regressions ❌
(secondary)
2.9% [1.6%, 4.1%] 2
Improvements ✅
(primary)
-1.6% [-2.1%, -1.0%] 2
Improvements ✅
(secondary)
-1.1% [-1.9%, -0.6%] 3
All ❌✅ (primary) -0.0% [-2.1%, 3.0%] 3

Cycles

Results (primary -2.0%, secondary -3.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)
- - 0
Improvements ✅
(primary)
-2.0% [-2.0%, -2.0%] 1
Improvements ✅
(secondary)
-3.3% [-3.3%, -3.3%] 1
All ❌✅ (primary) -2.0% [-2.0%, -2.0%] 1

Binary size

This benchmark run did not return any relevant results for this metric.

Bootstrap: 475.372s -> 475.32s (-0.01%)
Artifact size: 390.39 MiB -> 390.35 MiB (-0.01%)

@cjgillot cjgillot deleted the renumber-cfg branch October 18, 2025 04:08
@lqd
Copy link
Member

lqd commented Oct 18, 2025

cranelift-codegen is one of the benchmarks where borrowck takes the longest, is it expected that this change impacts it so negatively?

@Mark-Simulacrum
Copy link
Member

I think this is fine. We're seeing enough wins for more common Rust code
(serde, image, syn, etc) that I think it is fine to take the hit for the two
outliers (tt-muncher and cranelift-codegen for some reason), I do think it
could be because of cloning taking more instructions than what gets saved,
but I don't think that is preventable.

#142540 (comment)

I think I'm broadly in agreement with this summary of the results. Definitely would be interested in figuring out why we have the outliers we do, though, and seems plausible there's an opportunity waiting there...

@Mark-Simulacrum Mark-Simulacrum added the perf-regression-triaged The performance regression has been triaged. label Oct 21, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

merged-by-bors This PR was explicitly merged by bors. perf-regression Performance regression. 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.

9 participants