Skip to content

Conversation

@jsgf
Copy link
Contributor

@jsgf jsgf commented Nov 10, 2025

Build rustc and tools with -Zannotate-moves by default, both to exercise the feature and because could be useful for doing performance measurement on rustc and its tools. This has no effect on generated code, it just adds extra debug info in
the form of some new inlined functions.

This also adds bootstrap.toml config options

# rust.annotate-moves = true
# rust.annotate-moves-size-limit = 65

to allow this to be controlled locally.

This is only added for stage 1 and later. Stage 0 (the bootstrap compiler) doesn't yet support -Zannotate-moves.

#148197

@rustbot
Copy link
Collaborator

rustbot commented Nov 10, 2025

This PR modifies src/bootstrap/src/core/config.

If appropriate, please update CONFIG_CHANGE_HISTORY in src/bootstrap/src/utils/change_tracker.rs.

This PR modifies bootstrap.example.toml.

If appropriate, please update CONFIG_CHANGE_HISTORY in src/bootstrap/src/utils/change_tracker.rs.

@rustbot rustbot added S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. T-bootstrap Relevant to the bootstrap subteam: Rust's build system (x.py and src/bootstrap) labels Nov 10, 2025
@rustbot
Copy link
Collaborator

rustbot commented Nov 10, 2025

r? @Kobzol

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

@jsgf
Copy link
Contributor Author

jsgf commented Nov 10, 2025

cc @saethlin @madsmtm who have context on this.

@jsgf jsgf force-pushed the rust-annotate-default branch from 2d5c26c to 550107b Compare November 10, 2025 20:48
@Kobzol
Copy link
Member

Kobzol commented Nov 10, 2025

Hi, just to clarify, the move annotations are represented in actual debuginfo, e.g. DWARF? Because we don't currently have an easy way of shipping that to end users (and thus we don't ship it), so doing it by default would be pretty useless.

@jsgf
Copy link
Contributor Author

jsgf commented Nov 10, 2025

I was thinking it would primarily be useful to Rust developers doing profiling. But it would also apply to sysroot which does have shipped debuginfo, right?

Comment on lines 657 to 665
// Enable move/copy annotations for profiler visibility if configured
// Skip stage 0 since the bootstrap compiler doesn't support this flag yet
if self.config.rust_annotate_moves.unwrap_or(true) && build_compiler_stage >= 1 {
if let Some(limit) = self.config.rust_annotate_moves_size_limit {
rustflags.arg(&format!("-Zannotate-moves={}", limit));
} else {
rustflags.arg("-Zannotate-moves");
}
}
Copy link
Member

Choose a reason for hiding this comment

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

Question: hold on, won't this affect stable compiler dist builds too? Or maybe I'm misunderstanding?

Copy link
Contributor Author

@jsgf jsgf Nov 11, 2025

Choose a reason for hiding this comment

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

Yeah, that should be fine. It will have no functional effect, aside from some extra debug info.

Copy link
Member

Choose a reason for hiding this comment

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

There won't be any debuginfo, we strip it.

@Kobzol
Copy link
Member

Kobzol commented Nov 11, 2025

I was thinking it would primarily be useful to Rust developers doing profiling. But it would also apply to sysroot which does have shipped debuginfo, right?

Disted rustc itself can't be profiled currently, as we don't ship enough information with it for that (we strip debuginfo). For stdlib it might be useful, in theory. Let's measure the size changes.

@bors try @rust-timer queue

@rust-timer

This comment has been minimized.

rust-bors bot added a commit that referenced this pull request Nov 11, 2025
Build with -Zannotate-moves by default (non-stage-0 only)
@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 Nov 11, 2025
@rust-bors
Copy link

rust-bors bot commented Nov 11, 2025

☀️ Try build successful (CI)
Build commit: 7a0bdae (7a0bdae64447b62dab90586b62ff9bb97b2baf5d, parent: c8f22ca269a1f2653ac962fe2bc21105065fd6cd)

@rust-timer

This comment has been minimized.

@rust-timer
Copy link
Collaborator

Finished benchmarking commit (7a0bdae): 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.3% [0.3%, 0.4%] 3
Regressions ❌
(secondary)
0.3% [0.3%, 0.4%] 5
Improvements ✅
(primary)
- - 0
Improvements ✅
(secondary)
- - 0
All ❌✅ (primary) 0.3% [0.3%, 0.4%] 3

Max RSS (memory usage)

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

Cycles

Results (primary 3.5%, 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.5% [1.7%, 5.1%] 13
Regressions ❌
(secondary)
3.5% [3.5%, 3.5%] 1
Improvements ✅
(primary)
- - 0
Improvements ✅
(secondary)
-2.5% [-2.5%, -2.5%] 1
All ❌✅ (primary) 3.5% [1.7%, 5.1%] 13

Binary size

Results (primary 0.4%, secondary 0.6%)

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

mean range count
Regressions ❌
(primary)
0.4% [0.2%, 0.7%] 12
Regressions ❌
(secondary)
0.6% [0.0%, 0.7%] 45
Improvements ✅
(primary)
- - 0
Improvements ✅
(secondary)
- - 0
All ❌✅ (primary) 0.4% [0.2%, 0.7%] 12

Bootstrap: 476.181s -> 477.274s (0.23%)
Artifact size: 391.36 MiB -> 391.42 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 Nov 11, 2025
@jsgf
Copy link
Contributor Author

jsgf commented Nov 11, 2025

@Kobzol:

Disted rustc itself can't be profiled currently, as we don't ship enough information with it for that (we strip debuginfo). For stdlib it might be useful, in theory. Let's measure the size changes.

Yeah, by "Rust developers" I meant people checking out the git repo and building the toolchain for themselves.

Those perf differences look spurious and the binary size increase is about what's expected, esp "Artifact size: 391.36 MiB -> 391.42 MiB (0.01%)". Which artifact is that? All of them? librustc_driver.so? There should be no increase to shipped artifacts if their debuginfo is stripped.

@saethlin
Copy link
Member

The artifact size change is very close to, if not within noise. rustc-perf doesn't track artifact sizes over time like the other metrics so you have to squint at other perf runs to understand the build-to-build variation.

I agree that setting the threshold to 65 is a good default.

@Kobzol
Copy link
Member

Kobzol commented Nov 12, 2025

I see. Tbh I wouldn't even create a new bootstrap option for this, and just do it unconditionally when at least some debuginfo is requested for the compiler. It shouldn't make compilation time much slower, and binary size is not that important with debuginfo.

@jsgf
Copy link
Contributor Author

jsgf commented Nov 13, 2025

I just wanted a way to control the threshold size in case you're using it to investigate something specific. But I'd be happy to remove all that if its excessive.

@Kobzol
Copy link
Member

Kobzol commented Nov 13, 2025

Right, makes sense. A single flag should be enough for that, though. So I would suggest either:

  1. Always apply -Zannotate-moves when some debuginfo was requested, and use a flag to control the threshold size.
  2. Change the meaning of the threshold so that when you set it, you both set the threshold and enable the flag. So without setting the threshold size, moves won't be annotated.

What do you think?

@jsgf
Copy link
Contributor Author

jsgf commented Nov 13, 2025

I guess 1 of those two options, but all other things being equal I think I prefer it as it is now. Removing the second option wouldn't significantly reduce the PR size or complexity, but it would map more directly to the semantics of the option itself and give full control. (I did experiment with exactly matching the option semantics with boolean-or-number, but the additional complexity of the toml deserialization didn't seem worth it.)

reproducible_artifacts: flags_reproducible_artifact,
reuse: build_reuse.map(PathBuf::from),
rust_analyzer_info,
rust_annotate_moves,
Copy link
Member

Choose a reason for hiding this comment

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

Let's store bool, and not Option<bool>, in the config, and set the default value to false.

Or the default could be true if any debuginfo is enabled.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

The option itself is a no-op unless you specify debuginfo, so there's no need to do it here.

Copy link
Member

Choose a reason for hiding this comment

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

I see, I didn't check the implementation of the pass before. Ok, in that case I think that we can just enable it unconditionally (just hardcode passing -Zannotate-moves in bootstrap), because the binary size regression seems minimal (or it's just noise). And only allow configuring the size limit.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

OK updated so its always enabled and the only option is the size limit.

@jsgf jsgf force-pushed the rust-annotate-default branch from 550107b to 60c2cbf Compare November 16, 2025 19:32
@rustbot

This comment has been minimized.

@rust-log-analyzer

This comment has been minimized.

@jsgf jsgf force-pushed the rust-annotate-default branch from e32883f to eeaa992 Compare November 17, 2025 18:37
@jsgf
Copy link
Contributor Author

jsgf commented Nov 17, 2025

OK updated comment wording and change tracker.

@jsgf jsgf force-pushed the rust-annotate-default branch from eeaa992 to bc8d28e Compare November 17, 2025 18:52
Build rustc and tools with -Zannotate-moves by default. Adds toml config
options to set the annotation size limit.

This has no measurable effect on output binary size or compile time.
@jsgf jsgf force-pushed the rust-annotate-default branch from bc8d28e to 972498c Compare November 17, 2025 19:01
@jsgf
Copy link
Contributor Author

jsgf commented Nov 17, 2025

Rebased to resolve merge conflict.

@rustbot
Copy link
Collaborator

rustbot commented Nov 17, 2025

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.

@Kobzol
Copy link
Member

Kobzol commented Nov 17, 2025

Thank you!

@bors r+

@bors
Copy link
Collaborator

bors commented Nov 17, 2025

📌 Commit 972498c has been approved by Kobzol

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 Nov 17, 2025
bors added a commit that referenced this pull request Nov 18, 2025
Build with -Zannotate-moves by default (non-stage-0 only)

Build rustc and tools with -Zannotate-moves by default, both to exercise the feature and because could be useful for doing performance measurement on rustc and its tools. This has no effect on generated code, it just adds extra debug info in
the form of some new inlined functions.

This also adds bootstrap.toml config options
```
# rust.annotate-moves = true
# rust.annotate-moves-size-limit = 65
```
to allow this to be controlled locally.

This is only added for stage 1 and later. Stage 0 (the bootstrap compiler) doesn't yet support -Zannotate-moves.
@bors
Copy link
Collaborator

bors commented Nov 18, 2025

⌛ Testing commit 972498c with merge 8b3adc1...

@bors
Copy link
Collaborator

bors commented Nov 18, 2025

💔 Test failed - checks-actions

@bors bors added S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. and removed S-waiting-on-bors Status: Waiting on bors to run and complete tests. Bors will change the label on completion. labels Nov 18, 2025
@jsgf
Copy link
Contributor Author

jsgf commented Nov 18, 2025

The failure seems like it might be spurious.

@Kobzol
Copy link
Member

Kobzol commented Nov 18, 2025

Yeah, probably runner went down.

@bors retry

@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 Nov 18, 2025
@bors
Copy link
Collaborator

bors commented Nov 18, 2025

⌛ Testing commit 972498c with merge c199562...

@bors
Copy link
Collaborator

bors commented Nov 18, 2025

☀️ Test successful - checks-actions
Approved by: Kobzol
Pushing c199562 to main...

@bors bors added the merged-by-bors This PR was explicitly merged by bors. label Nov 18, 2025
@bors bors merged commit c199562 into rust-lang:main Nov 18, 2025
12 checks passed
@rustbot rustbot added this to the 1.93.0 milestone Nov 18, 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 217cb73 (parent) -> c199562 (this PR)

Test differences

Show 4 test diffs

4 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 c1995621a44398ac33ab368adbfb69753218b49e --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: 8693.5s -> 7130.6s (-18.0%)
  2. x86_64-gnu-llvm-21-2: 4955.9s -> 5782.9s (+16.7%)
  3. i686-gnu-2: 5395.0s -> 6191.7s (+14.8%)
  4. dist-aarch64-apple: 7794.6s -> 6791.1s (-12.9%)
  5. i686-gnu-1: 7406.1s -> 8293.5s (+12.0%)
  6. x86_64-gnu-llvm-20: 2538.8s -> 2257.8s (-11.1%)
  7. i686-msvc-2: 8380.7s -> 7591.2s (-9.4%)
  8. dist-aarch64-msvc: 5707.9s -> 6224.0s (+9.0%)
  9. dist-apple-various: 3480.3s -> 3793.9s (+9.0%)
  10. i686-gnu-nopt-1: 7539.4s -> 8208.4s (+8.9%)
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 (c199562): comparison URL.

Overall result: ❌ regressions - no action needed

@rustbot label: -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.3%, 0.3%] 1
Regressions ❌
(secondary)
0.3% [0.3%, 0.4%] 5
Improvements ✅
(primary)
- - 0
Improvements ✅
(secondary)
- - 0
All ❌✅ (primary) 0.3% [0.3%, 0.3%] 1

Max RSS (memory usage)

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

Cycles

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

Binary size

Results (primary 0.4%, secondary 0.6%)

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

mean range count
Regressions ❌
(primary)
0.4% [0.2%, 0.7%] 12
Regressions ❌
(secondary)
0.6% [0.0%, 0.7%] 45
Improvements ✅
(primary)
- - 0
Improvements ✅
(secondary)
- - 0
All ❌✅ (primary) 0.4% [0.2%, 0.7%] 12

Bootstrap: 474.105s -> 474.876s (0.16%)
Artifact size: 388.71 MiB -> 388.76 MiB (0.01%)

@rustbot rustbot removed the perf-regression Performance regression. label Nov 18, 2025
@jsgf jsgf deleted the rust-annotate-default branch November 19, 2025 00:43
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. S-waiting-on-bors Status: Waiting on bors to run and complete tests. Bors will change the label on completion. T-bootstrap Relevant to the bootstrap subteam: Rust's build system (x.py and src/bootstrap)

Projects

None yet

Development

Successfully merging this pull request may close these issues.

8 participants