Skip to content

Conversation

@cjgillot
Copy link
Contributor

@cjgillot cjgillot commented Jun 23, 2025

This PR proposes to perform destination propagation on MIR. Most of the pass was fully rewritten by @JakobDegen in #96451.

This pass is quite heavy, as it needs to perform and save the results of a full liveness dataflow analysis. This accounts for ~50% of the pass' runtime.

Perf sees a few decent savings in later llvm passes, but also sizeable régressions when there are no savings to balance this pass' runtime.

@rustbot rustbot added the T-compiler Relevant to the compiler team, which will review and decide on the PR/issue. label Jun 23, 2025
@cjgillot
Copy link
Contributor Author

@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 Jun 23, 2025
bors added a commit that referenced this pull request Jun 23, 2025
Enable DestinationPropagation by default

r? `@ghost`
@bors
Copy link
Collaborator

bors commented Jun 23, 2025

⌛ Trying commit b835228 with merge 2989fd8...

@cjgillot cjgillot added the A-mir-opt Area: MIR optimizations label Jun 23, 2025
@bors
Copy link
Collaborator

bors commented Jun 23, 2025

☀️ Try build successful - checks-actions
Build commit: 2989fd8 (2989fd868755417871c65b8864528f20125af5bc)

@rust-timer

This comment has been minimized.

@rust-timer
Copy link
Collaborator

Finished benchmarking commit (2989fd8): 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)
0.7% [0.2%, 3.1%] 27
Regressions ❌
(secondary)
0.6% [0.2%, 2.5%] 36
Improvements ✅
(primary)
-0.4% [-1.7%, -0.1%] 60
Improvements ✅
(secondary)
-0.7% [-2.9%, -0.2%] 71
All ❌✅ (primary) -0.0% [-1.7%, 3.1%] 87

Max RSS (memory usage)

Results (primary 0.7%, secondary 1.6%)

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

mean range count
Regressions ❌
(primary)
5.6% [1.7%, 10.5%] 5
Regressions ❌
(secondary)
1.6% [1.4%, 2.2%] 9
Improvements ✅
(primary)
-4.3% [-5.9%, -2.5%] 5
Improvements ✅
(secondary)
- - 0
All ❌✅ (primary) 0.7% [-5.9%, 10.5%] 10

Cycles

Results (primary 0.3%, secondary -1.0%)

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

mean range count
Regressions ❌
(primary)
1.0% [0.5%, 1.4%] 5
Regressions ❌
(secondary)
3.1% [1.8%, 4.4%] 3
Improvements ✅
(primary)
-1.5% [-1.7%, -1.3%] 2
Improvements ✅
(secondary)
-2.6% [-3.5%, -1.5%] 8
All ❌✅ (primary) 0.3% [-1.7%, 1.4%] 7

Binary size

Results (primary -0.0%, secondary 0.1%)

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

mean range count
Regressions ❌
(primary)
0.2% [0.0%, 0.4%] 22
Regressions ❌
(secondary)
0.4% [0.0%, 2.0%] 94
Improvements ✅
(primary)
-0.1% [-1.0%, -0.0%] 54
Improvements ✅
(secondary)
-1.0% [-13.0%, -0.0%] 28
All ❌✅ (primary) -0.0% [-1.0%, 0.4%] 76

Bootstrap: 688.878s -> 687.306s (-0.23%)
Artifact size: 371.92 MiB -> 371.62 MiB (-0.08%)

@rustbot rustbot added perf-regression Performance regression. and removed S-waiting-on-perf Status: Waiting on a perf run to be completed. labels Jun 24, 2025
@cjgillot cjgillot marked this pull request as ready for review June 25, 2025 19:10
@rustbot
Copy link
Collaborator

rustbot commented Jun 25, 2025

r? @petrochenkov

rustbot has assigned @petrochenkov.
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 the S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. label Jun 25, 2025
@rustbot
Copy link
Collaborator

rustbot commented Jun 25, 2025

Some changes occurred to MIR optimizations

cc @rust-lang/wg-mir-opt

@petrochenkov
Copy link
Contributor

r? mir

@rustbot rustbot assigned oli-obk and unassigned petrochenkov Jun 25, 2025
Copy link
Contributor

@oli-obk oli-obk left a comment

Choose a reason for hiding this comment

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

r=me

@cjgillot
Copy link
Contributor Author

cjgillot commented Jul 1, 2025

There is a pathological behaviour with cranelift-codegen I'd like to fix first. There are many locals that can be merged with _0. The current version needs to recompute all candidates and all conflicts each time it merges _0 with something.

@cjgillot cjgillot force-pushed the dest-prop-default branch from b835228 to 9298dfa Compare July 2, 2025 10:10
@cjgillot
Copy link
Contributor Author

cjgillot commented Jul 2, 2025

@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 Jul 2, 2025
@bors
Copy link
Collaborator

bors commented Jul 2, 2025

⌛ Trying commit 9298dfa with merge 00ffd2b...

bors added a commit that referenced this pull request Jul 2, 2025
Enable DestinationPropagation by default

This PR proposes to perform destination propagation on MIR. Most of the pass was fully rewritten by `@JakobDegen` in #96451.

This pass is quite heavy, as it needs to perform and save the results of a full liveness dataflow analysis. This accounts for ~50% of the pass' runtime.

Perf sees a few decent savings in later llvm passes, but also sizeable régressions when there are no savings to balance this pass' runtime.
@bors
Copy link
Collaborator

bors commented Jul 2, 2025

☀️ Try build successful - checks-actions
Build commit: 00ffd2b (00ffd2bf2b816d1f0df05611fccdd7dad0a8db22)

@rust-timer

This comment has been minimized.

@rust-timer
Copy link
Collaborator

Finished benchmarking commit (58abde7): 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)
0.3% [0.1%, 1.2%] 62
Regressions ❌
(secondary)
0.4% [0.0%, 1.6%] 98
Improvements ✅
(primary)
-0.5% [-2.0%, -0.1%] 29
Improvements ✅
(secondary)
-0.9% [-2.5%, -0.1%] 46
All ❌✅ (primary) 0.0% [-2.0%, 1.2%] 91

Max RSS (memory usage)

Results (primary 1.8%)

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

mean range count
Regressions ❌
(primary)
3.3% [2.2%, 4.5%] 2
Regressions ❌
(secondary)
- - 0
Improvements ✅
(primary)
-1.3% [-1.3%, -1.3%] 1
Improvements ✅
(secondary)
- - 0
All ❌✅ (primary) 1.8% [-1.3%, 4.5%] 3

Cycles

Results (primary -2.3%, secondary -4.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.9% [2.9%, 2.9%] 1
Improvements ✅
(primary)
-2.3% [-2.3%, -2.3%] 1
Improvements ✅
(secondary)
-4.8% [-7.8%, -1.9%] 13
All ❌✅ (primary) -2.3% [-2.3%, -2.3%] 1

Binary size

Results (primary -0.1%, secondary 0.0%)

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

mean range count
Regressions ❌
(primary)
0.1% [0.0%, 0.4%] 21
Regressions ❌
(secondary)
0.3% [0.0%, 1.1%] 57
Improvements ✅
(primary)
-0.1% [-2.4%, -0.0%] 73
Improvements ✅
(secondary)
-0.6% [-2.4%, -0.0%] 24
All ❌✅ (primary) -0.1% [-2.4%, 0.4%] 94

Bootstrap: 467.433s -> 465.765s (-0.36%)
Artifact size: 387.54 MiB -> 387.18 MiB (-0.09%)

@rustbot rustbot removed the S-waiting-on-perf Status: Waiting on a perf run to be completed. label Sep 9, 2025
@lqd
Copy link
Member

lqd commented Sep 9, 2025

It's possible destprop caused #146383, so we may want to hold on this PR until we have more information, or a fix.

@saethlin
Copy link
Member

saethlin commented Sep 9, 2025

It's possible

I am certain that DestinationPropagation is the cause. I've added some more text to make that clear.

@rustbot

This comment has been minimized.

@rustbot
Copy link
Collaborator

rustbot commented Sep 16, 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

#146383 is fixed.

@saethlin
Copy link
Member

I don't think this is particularly risky; this pass has had a fair bit of fuzzing by Rustlantis because I run with -Zmir-opt-level=4.

@bors r+ rollup=never

@bors
Copy link
Collaborator

bors commented Sep 17, 2025

📌 Commit 44c1a00 has been approved by saethlin

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

bors commented Sep 17, 2025

⌛ Testing commit 44c1a00 with merge ce6daf3...

@bors
Copy link
Collaborator

bors commented Sep 17, 2025

☀️ Test successful - checks-actions
Approved by: saethlin
Pushing ce6daf3 to master...

@bors bors added the merged-by-bors This PR was explicitly merged by bors. label Sep 17, 2025
@bors bors merged commit ce6daf3 into rust-lang:master Sep 17, 2025
11 checks passed
@rustbot rustbot added this to the 1.92.0 milestone Sep 17, 2025
@github-actions
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 2ebb126 (parent) -> ce6daf3 (this PR)

Test differences

Show 16 test diffs

Stage 1

  • [mir-opt] tests/mir-opt/dest-prop/nrvo_borrowed.rs: [missing] -> pass (J1)
  • [mir-opt] tests/mir-opt/dest-prop/nrvo_miscompile_111005.rs: [missing] -> pass (J1)
  • [mir-opt] tests/mir-opt/nrvo_miscompile_111005.rs: pass -> [missing] (J1)
  • [mir-opt] tests/mir-opt/nrvo_simple.rs: pass -> [missing] (J1)

Stage 2

  • [mir-opt] tests/mir-opt/dest-prop/nrvo_borrowed.rs: [missing] -> pass (J0)
  • [mir-opt] tests/mir-opt/dest-prop/nrvo_miscompile_111005.rs: [missing] -> pass (J0)
  • [mir-opt] tests/mir-opt/nrvo_miscompile_111005.rs: pass -> [missing] (J0)
  • [mir-opt] tests/mir-opt/nrvo_simple.rs: pass -> [missing] (J0)

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

Job group index

Test dashboard

Run

cargo run --manifest-path src/ci/citool/Cargo.toml -- \
    test-dashboard ce6daf3d5a5bffb2a00264197f92dc31608df0da --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-apple-various: 4430.5s -> 3369.0s (-24.0%)
  2. aarch64-apple: 5511.1s -> 6624.5s (20.2%)
  3. x86_64-rust-for-linux: 3107.5s -> 2645.6s (-14.9%)
  4. x86_64-gnu-llvm-20-1: 3720.3s -> 3228.5s (-13.2%)
  5. aarch64-gnu-llvm-20-1: 3787.9s -> 3328.0s (-12.1%)
  6. i686-gnu-nopt-1: 8261.1s -> 7258.6s (-12.1%)
  7. pr-check-1: 1537.1s -> 1358.2s (-11.6%)
  8. i686-gnu-2: 6028.3s -> 5400.6s (-10.4%)
  9. x86_64-gnu-debug: 7132.4s -> 6532.8s (-8.4%)
  10. arm-android: 6173.2s -> 5670.9s (-8.1%)
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 (ce6daf3): 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)
0.3% [0.1%, 1.1%] 62
Regressions ❌
(secondary)
0.4% [0.1%, 1.6%] 98
Improvements ✅
(primary)
-0.4% [-1.7%, -0.1%] 31
Improvements ✅
(secondary)
-0.7% [-2.5%, -0.1%] 60
All ❌✅ (primary) 0.0% [-1.7%, 1.1%] 93

Max RSS (memory usage)

Results (primary 1.5%, secondary -2.0%)

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

mean range count
Regressions ❌
(primary)
2.8% [0.9%, 4.6%] 2
Regressions ❌
(secondary)
- - 0
Improvements ✅
(primary)
-1.1% [-1.1%, -1.1%] 1
Improvements ✅
(secondary)
-2.0% [-2.4%, -1.5%] 3
All ❌✅ (primary) 1.5% [-1.1%, 4.6%] 3

Cycles

Results (primary -1.4%, 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)
3.5% [2.1%, 5.3%] 6
Improvements ✅
(primary)
-1.4% [-1.4%, -1.4%] 1
Improvements ✅
(secondary)
-3.7% [-6.1%, -1.3%] 7
All ❌✅ (primary) -1.4% [-1.4%, -1.4%] 1

Binary size

Results (primary -0.1%, secondary -0.0%)

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

mean range count
Regressions ❌
(primary)
0.1% [0.0%, 0.4%] 25
Regressions ❌
(secondary)
0.3% [0.0%, 1.0%] 62
Improvements ✅
(primary)
-0.1% [-2.0%, -0.0%] 56
Improvements ✅
(secondary)
-1.0% [-3.5%, -0.0%] 23
All ❌✅ (primary) -0.1% [-2.0%, 0.4%] 81

Bootstrap: 472.767s -> 472.939s (0.04%)
Artifact size: 390.62 MiB -> 387.93 MiB (-0.69%)

@Kobzol
Copy link
Member

Kobzol commented Sep 23, 2025

The compile-time effects seem to be a wash, while this nicely reduced the binary size of the compiler itself, and is expected to improve runtime performance.

@rustbot label: +perf-regression-triaged

@rustbot rustbot added the perf-regression-triaged The performance regression has been triaged. label Sep 23, 2025
makai410 pushed a commit to makai410/rust that referenced this pull request Nov 8, 2025
Enable DestinationPropagation by default

This PR proposes to perform destination propagation on MIR. Most of the pass was fully rewritten by `@JakobDegen` in rust-lang#96451.

This pass is quite heavy, as it needs to perform and save the results of a full liveness dataflow analysis. This accounts for ~50% of the pass' runtime.

Perf sees a few decent savings in later llvm passes, but also sizeable régressions when there are no savings to balance this pass' runtime.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

A-mir-opt Area: MIR optimizations 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.

10 participants