Skip to content

Unschedule moved locals#159577

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

Unschedule moved locals#159577
cjgillot wants to merge 4 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

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)
---- [ui] tests/ui/mir/issue-80949.rs stdout ----

error: test compilation failed although it shouldn't!
status: exit status: 1
command: env -u RUSTC_LOG_COLOR RUSTC_ICE="0" RUST_BACKTRACE="short" "/checkout/obj/build/aarch64-unknown-linux-gnu/stage2/bin/rustc" "/checkout/tests/ui/mir/issue-80949.rs" "-Zthreads=1" "-Zsimulate-remapped-rust-src-base=/rustc/FAKE_PREFIX" "-Ztranslate-remapped-path-to-local-path=no" "-Z" "ignore-directory-in-diagnostics-source-blocks=/cargo" "-Z" "ignore-directory-in-diagnostics-source-blocks=/checkout/vendor" "--sysroot" "/checkout/obj/build/aarch64-unknown-linux-gnu/stage2" "--target=aarch64-unknown-linux-gnu" "--check-cfg" "cfg(test,FALSE)" "--error-format" "json" "--json" "future-incompat" "-Ccodegen-units=1" "-Zui-testing" "-Zdeduplicate-diagnostics=no" "-Zwrite-long-types-to-disk=no" "-Cstrip=debuginfo" "-C" "prefer-dynamic" "--out-dir" "/checkout/obj/build/aarch64-unknown-linux-gnu/test/ui/mir/issue-80949" "-A" "unused" "-W" "unused_attributes" "-A" "internal_features" "-A" "incomplete_features" "-A" "unused_parens" "-A" "unused_braces" "-Crpath" "-Cdebuginfo=0" "-Lnative=/checkout/obj/build/aarch64-unknown-linux-gnu/native/rust-test-helpers"
stdout: none
--- stderr -------------------------------
error[E0597]: `storage` does not live long enough
##[error]  --> /checkout/tests/ui/mir/issue-80949.rs:32:23
   |
---
LL |     diff(dyn_trait, storage_ref);
LL | }
   | -
   | |
   | `storage` dropped here while still borrowed
   | borrow might be used here, when `dyn_trait` is dropped and runs the destructor for type `Box<dyn Trait<Item = &()>>`
   |
   = note: values in a scope are dropped in the opposite order they are defined

error: aborting due to 1 previous error

@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
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