Skip to content

Unschedule moved locals#159577

Draft
cjgillot wants to merge 5 commits into
rust-lang:mainfrom
cjgillot:unschedule-moved-locals
Draft

Unschedule moved locals#159577
cjgillot wants to merge 5 commits into
rust-lang:mainfrom
cjgillot:unschedule-moved-locals

Conversation

@cjgillot

@cjgillot cjgillot commented Jul 19, 2026

Copy link
Copy Markdown
Contributor

Alternative to #159537

This extracts part of the implementation from #125923.

Instead of maintaining a bit-set of locals that are moved from the innermost scope, this PR just removes the locals from the drop schedule.

r? @ghost for perf, and because of a borrowck corner case

cjgillot added 3 commits July 18, 2026 20:50
And some more cases along the way.

We have a specific optimization to avoid generating useless drops, use it.
In particular, aggregate construction are very similar to function calls
for which this is designed.
@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 Jul 19, 2026
@cjgillot

Copy link
Copy Markdown
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 Jul 19, 2026
@rust-bors

This comment has been minimized.

rust-bors Bot pushed a commit that referenced this pull request Jul 19, 2026
@rust-log-analyzer

This comment has been minimized.

@cjgillot
cjgillot force-pushed the unschedule-moved-locals branch from 53d969a to d9d6173 Compare July 19, 2026 20:40
@rust-log-analyzer

This comment has been minimized.

@rust-bors

rust-bors Bot commented Jul 19, 2026

Copy link
Copy Markdown
Contributor

☀️ Try build successful (CI)
Build commit: ab0430c (ab0430cfc09675383a04ad2a1b7877ec314aaac9)
Base parent: 9f36de7 (9f36de775bc636c8e88c31a173c2bcb6995956a0)

@rust-timer

This comment has been minimized.

@rust-timer

Copy link
Copy Markdown
Collaborator

Finished benchmarking commit (ab0430c): 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.5% [0.4%, 0.5%] 6
Regressions ❌
(secondary)
0.3% [0.2%, 0.3%] 2
Improvements ✅
(primary)
-0.5% [-1.0%, -0.2%] 53
Improvements ✅
(secondary)
-0.4% [-1.0%, -0.2%] 44
All ❌✅ (primary) -0.4% [-1.0%, 0.5%] 59

Max RSS (memory usage)

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

Cycles

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

Binary size

Results (primary -0.4%, 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.6% [0.6%, 0.6%] 1
Regressions ❌
(secondary)
- - 0
Improvements ✅
(primary)
-0.4% [-1.9%, -0.0%] 42
Improvements ✅
(secondary)
-0.2% [-1.9%, -0.0%] 30
All ❌✅ (primary) -0.4% [-1.9%, 0.6%] 43

Bootstrap: 484.26s -> 485.704s (0.30%)
Artifact size: 391.74 MiB -> 391.76 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 Jul 19, 2026
@cjgillot

Copy link
Copy Markdown
Contributor Author

@bors try @rust-timer queue

@rust-timer

This comment has been minimized.

@rust-bors

This comment has been minimized.

@rustbot rustbot added the S-waiting-on-perf Status: Waiting on a perf run to be completed. label Jul 20, 2026
rust-bors Bot pushed a commit that referenced this pull request Jul 20, 2026
@rust-log-analyzer

Copy link
Copy Markdown
Collaborator

The job aarch64-gnu-llvm-21-1 failed! Check out the build log: (web) (plain enhanced) (plain)

Click to see the possible cause of the failure (guessed by this bot)
test [mir-opt] tests/mir-opt/unusual_item_types.rs ... ok

failures:

---- [mir-opt] tests/mir-opt/nll/region_subtyping_basic.rs stdout ----
5 | '?1 | Local | ['?1]
6 |
7 | Inferred Region Values
- | '?0 | U0 | {bb0[0..=8], bb1[0..=8], bb2[0..=3], bb3[0..=3], bb4[0..=1], bb5[0..=2], bb6[0..=4], bb7[0], '?0, '?1}
- | '?1 | U0 | {bb0[0..=8], bb1[0..=8], bb2[0..=3], bb3[0..=3], bb4[0..=1], bb5[0..=2], bb6[0..=4], bb7[0], '?1}
+ | '?0 | U0 | {bb0[0..=8], bb1[0..=8], bb2[0..=3], bb3[0..=3], bb4[0..=1], bb5[0..=2], bb6[0..=4], bb7[0], bb8[0], bb9[0], bb10[0], '?0, '?1}
+ | '?1 | U0 | {bb0[0..=8], bb1[0..=8], bb2[0..=3], bb3[0..=3], bb4[0..=1], bb5[0..=2], bb6[0..=4], bb7[0], bb8[0], bb9[0], bb10[0], '?1}
10 | '?2 | U0 | {bb1[0..=8], bb2[0..=2]}
11 | '?3 | U0 | {bb1[1..=8], bb2[0..=2]}
12 | '?4 | U0 | {bb1[5..=8], bb2[0..=2]}

13 |
14 | Inference Constraints
- | '?0 live at {bb0[0..=8], bb1[0..=8], bb2[0..=3], bb3[0..=3], bb4[0..=1], bb5[0..=2], bb6[0..=4], bb7[0]}
- | '?1 live at {bb0[0..=8], bb1[0..=8], bb2[0..=3], bb3[0..=3], bb4[0..=1], bb5[0..=2], bb6[0..=4], bb7[0]}
+ | '?0 live at {bb0[0..=8], bb1[0..=8], bb2[0..=3], bb3[0..=3], bb4[0..=1], bb5[0..=2], bb6[0..=4], bb7[0], bb8[0], bb9[0], bb10[0]}
+ | '?1 live at {bb0[0..=8], bb1[0..=8], bb2[0..=3], bb3[0..=3], bb4[0..=1], bb5[0..=2], bb6[0..=4], bb7[0], bb8[0], bb9[0], bb10[0]}
17 | '?2 live at {bb1[0]}
18 | '?3 live at {bb1[1..=4]}
19 | '?4 live at {bb1[5..=8], bb2[0..=2]}

53         _3 = const ConstValue(Scalar(0x0000000000000000): usize);
54         FakeRead(ForIndex, _1);
55         _4 = Lt(copy _3, const ValTree(Leaf(0x0000000000000003): usize));
-         assert(move _4, "index out of bounds: the length is {} but the index is {}", const ValTree(Leaf(0x0000000000000003): usize), copy _3) -> [success: bb1, unwind: bb7];
+         assert(move _4, "index out of bounds: the length is {} but the index is {}", const ValTree(Leaf(0x0000000000000003): usize), copy _3) -> [success: bb1, unwind: bb8];
57     }
58 
59     bb1: {

72         StorageLive(_7);
73         StorageLive(_8);
74         _8 = copy (*_5);
-         _7 = ConstValue(ZeroSized: fn(usize) -> bool {use_x})(move _8) -> [return: bb3, unwind: bb7];
+         _7 = ConstValue(ZeroSized: fn(usize) -> bool {use_x})(move _8) -> [return: bb3, unwind: bb9];
76     }
77 
78     bb3: {

84 
85     bb4: {
86         StorageLive(_9);
-         _9 = ConstValue(ZeroSized: fn(usize) -> bool {use_x})(const ConstValue(Scalar(0x0000000000000016): usize)) -> [return: bb5, unwind: bb7];
+         _9 = ConstValue(ZeroSized: fn(usize) -> bool {use_x})(const ConstValue(Scalar(0x0000000000000016): usize)) -> [return: bb5, unwind: bb10];
88     }
89 
90     bb5: {

103 
---
107 }
108 


thread '[mir-opt] tests/mir-opt/nll/region_subtyping_basic.rs' panicked at src/tools/compiletest/src/runtest/mir_opt.rs:73:21:
Actual MIR output differs from expected MIR output /checkout/tests/mir-opt/nll/region_subtyping_basic.main.nll.0.64bit.mir
note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace
---- [mir-opt] tests/mir-opt/nll/region_subtyping_basic.rs stdout end ----

failures:
    [mir-opt] tests/mir-opt/nll/region_subtyping_basic.rs

@rust-bors

rust-bors Bot commented Jul 21, 2026

Copy link
Copy Markdown
Contributor

☀️ Try build successful (CI)
Build commit: 563ed1f (563ed1fa91907743b81f0cbaac99dc8c8ad29077)
Base parent: 87e5904 (87e5904f5eb6398af6b22eac2802c78934260c48)

@rust-timer

This comment has been minimized.

@rust-timer

Copy link
Copy Markdown
Collaborator

Finished benchmarking commit (563ed1f): 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)
1.3% [0.2%, 11.7%] 65
Regressions ❌
(secondary)
0.7% [0.1%, 2.0%] 66
Improvements ✅
(primary)
-0.3% [-0.6%, -0.2%] 10
Improvements ✅
(secondary)
-0.3% [-0.3%, -0.3%] 2
All ❌✅ (primary) 1.0% [-0.6%, 11.7%] 75

Max RSS (memory usage)

Results (primary 1.7%, secondary 2.4%)

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

mean range count
Regressions ❌
(primary)
6.9% [6.6%, 7.2%] 2
Regressions ❌
(secondary)
3.2% [2.1%, 6.0%] 4
Improvements ✅
(primary)
-1.7% [-3.5%, -0.8%] 3
Improvements ✅
(secondary)
-0.7% [-0.7%, -0.7%] 1
All ❌✅ (primary) 1.7% [-3.5%, 7.2%] 5

Cycles

Results (primary 10.9%, secondary -1.4%)

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

mean range count
Regressions ❌
(primary)
10.9% [1.9%, 23.2%] 6
Regressions ❌
(secondary)
5.9% [5.9%, 5.9%] 1
Improvements ✅
(primary)
- - 0
Improvements ✅
(secondary)
-3.8% [-4.2%, -3.5%] 3
All ❌✅ (primary) 10.9% [1.9%, 23.2%] 6

Binary size

Results (primary -0.4%, 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.6% [0.6%, 0.6%] 1
Regressions ❌
(secondary)
- - 0
Improvements ✅
(primary)
-0.4% [-1.9%, -0.0%] 42
Improvements ✅
(secondary)
-0.2% [-1.9%, -0.0%] 29
All ❌✅ (primary) -0.4% [-1.9%, 0.6%] 43

Bootstrap: 486.983s -> 486.82s (-0.03%)
Artifact size: 391.82 MiB -> 391.79 MiB (-0.01%)

@rustbot rustbot removed the S-waiting-on-perf Status: Waiting on a perf run to be completed. label Jul 21, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

perf-regression Performance regression. 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.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants