Skip to content

Assorted opt-dist fixes and improvements - #165561

Merged
rust-bors[bot] merged 8 commits into
rust-lang:mainfrom
lqd:opt-dist
Nov 7, 2026
Merged

rust-bors[bot] merged 8 commits into
rust-lang:mainfrom
lqd:opt-dist

Conversation

@lqd

@lqd lqd commented Nov 6, 2026

Copy link
Copy Markdown
Member

r? kobzol

I've been looking at PGO again, and encountered some issues running opt-dist locally:

  • it currently panics because it seems to expect the metrics file to be always present, so I've made the metrics update optional
  • it will copy and build rustc-perf every time you run it, even when specifying the "pre-built rustc-perf" config, so I've changed this to only happen if you don't use this pre-built arg.
  • the recent additions to PGO more tools are mandatory, but it takes a really long time to build all the tools multiple times and run benchmarks, so I've made these opt-in on the CLI for local runs, but they are still on by default for CI runs of course.

Since these are a bit random and kind of unrelated, I've kept them in separate commits to make review easier.

Note that I've already done a perf run for these changes, and there were no changes in the x64 or aarch64 results. So that's I think at least rustc and rustdoc tested, but I don't know if we can use the perf collector to test everything? (clippy + clif maybe and if so we should do that, but I don't know about cargo itself?)

Local runs don't emit metrics, trying to update the metrics.json file
will always fail.
@rustbot

rustbot commented Nov 6, 2026

Copy link
Copy Markdown
Collaborator

Some changes occurred in src/tools/opt-dist

cc @Kobzol

@rustbot rustbot added the S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. label Nov 6, 2026
@rustbot

rustbot commented Nov 6, 2026

Copy link
Copy Markdown
Collaborator

kobzol is not on the review rotation at the moment.
They may take a while to respond.

@Kobzol Kobzol left a comment •

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Looks good! Left one nit, you can r=me after (in parallel to the benchmark). We should see Cargo changes in rustc-perf if PGO somehow went sideways.

@bors r+ rollup

@bors try @rust-timer queue

View changes since this review

Comment thread src/tools/opt-dist/src/environment.rs Resolved
@rust-bors

rust-bors Bot commented Nov 6, 2026

Copy link
Copy Markdown
Contributor

📌 Commit 5b405ab has been tentatively approved by Kobzol

It will be put into the queue for this repository once PR CI succeeds.

@rust-bors rust-bors Bot 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 6, 2026
@rust-bors

This comment has been minimized.

rust-bors Bot pushed a commit that referenced this pull request Nov 6, 2026
Assorted opt-dist fixes and improvements
@Kobzol

Kobzol commented Nov 6, 2026

Copy link
Copy Markdown
Member

Lol, I told you to r=me and then r+-ed the PR.

@bors r-

@rust-bors rust-bors Bot added S-waiting-on-author Status: This is awaiting some action (such as code changes or more information) from the author. and removed S-waiting-on-bors Status: Waiting on bors to run and complete tests. Bors will change the label on completion. labels Nov 6, 2026
@rust-bors

rust-bors Bot commented Nov 6, 2026

Copy link
Copy Markdown
Contributor

This pull request was unapproved.

View changes since this unapproval

lqd added 7 commits November 6, 2026 21:13
right now, an opt-dist run starts with:
- clear its opt-artifacts folder
- copy a rustc-perf tree there
- build the collector

So, on every run, the built rustc-perf is deleted and rebuilt, even though
there is a "prebuilt rustc-perf" configuration.

This commit does not rebuild rustc-perf if there's a prebuilt dir,
and returning that as the rustc-perf path to run benchmarks in.
Local runs are usually more concerned about optimizing the compiler, so
optimizing rustdoc is off by default for these, but it still is on
by default otherwise, to keep optimizing it on CI as we do today.
Make optimizing cranelift and clippy off by default for local runs.
The default is still on for CI, because we optimize by default, but off
for local runs.
@lqd

lqd commented Nov 6, 2026

Copy link
Copy Markdown
Member Author

Ah fun, I think bors can now read GH reviews, but not rust-timer.

@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 Nov 6, 2026
@rust-bors

rust-bors Bot commented Nov 6, 2026

Copy link
Copy Markdown
Contributor

☀️ Try build successful (CI)
Build commit: fb116aa (fb116aa3736ee12c8f47637d6fe7418033fb822d)
Base parent: 249c1e4 (249c1e4e31111b54ad2483cfd4cea06c7020c653)

@rust-timer

This comment has been minimized.

@rust-timer

Copy link
Copy Markdown
Collaborator

Finished benchmarking commit (fb116aa): comparison URL.

Overall result: no relevant changes - no action needed

Benchmarking means the PR may be perf-sensitive. Consider adding rollup=never if this change is not fit for rolling up.

@rustbot label: -S-waiting-on-perf -perf-regression

Instruction count

This perf run didn't have relevant results for this metric.

Max RSS (memory usage)

Results (primary 0.3%)

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

mean range count
Regressions ❌
(primary)
2.7% [2.7%, 2.7%] 1
Regressions ❌
(secondary)
- - 0
Improvements ✅
(primary)
-2.1% [-2.1%, -2.1%] 1
Improvements ✅
(secondary)
- - 0
All ❌✅ (primary) 0.3% [-2.1%, 2.7%] 2

Cycles

Results (primary 2.4%)

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

mean range count
Regressions ❌
(primary)
2.4% [2.1%, 2.9%] 3
Regressions ❌
(secondary)
- - 0
Improvements ✅
(primary)
- - 0
Improvements ✅
(secondary)
- - 0
All ❌✅ (primary) 2.4% [2.1%, 2.9%] 3

Binary size

This perf run didn't have relevant results for this metric.

Bootstrap: 481.055s -> 481.429s (0.08%)
Artifact size: 406.29 MiB -> 406.39 MiB (0.02%)

@rustbot rustbot removed the S-waiting-on-perf Status: Waiting on a perf run to be completed. label Nov 6, 2026
@lqd

lqd commented Nov 6, 2026

Copy link
Copy Markdown
Member Author

Same lack of results as the earlier run, on both targets, so this doesn't change behavior, as expected.

@bors r=kobzol

@rust-bors

rust-bors Bot commented Nov 6, 2026

Copy link
Copy Markdown
Contributor

📌 Commit 5cd5686 has been approved by kobzol

It is now in the queue for this repository.

@rust-bors rust-bors Bot 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-author Status: This is awaiting some action (such as code changes or more information) from the author. labels Nov 6, 2026
rust-bors Bot pushed a commit that referenced this pull request Nov 7, 2026
Rollup of 13 pull requests

Successful merges:

 - #164914 (Specialize more builtin types for `<[MaybeUninit<_>]>::write_default()`)
 - #165078 (Use the `2.38` binutils version in CI)
 - #165427 (rustdoc: Make implementors collapseable if there is more than one line of docs)
 - #165444 (Suggest using `ExitCode` instead of calling `exit`)
 - #165571 (Support mutable captures in move expressions)
 - #165379 (Autolabel `std::sys` modules)
 - #165503 (update Enzyme submodule)
 - #165519 (Update books)
 - #165534 (rename MIR_borrow_checking timing scope to less confusing name)
 - #165546 (Expose `str::split_at_[mut_]unchecked` and `OsStr::split_at_unchecked`)
 - #165561 (Assorted opt-dist fixes and improvements)
 - #165564 (fix: Remove confusing self-links from Diag docs)
 - #165570 (fix `-Zvirtual-function-elimination` error message)
@rust-bors
rust-bors Bot merged commit afbb9ff into rust-lang:main Nov 7, 2026
14 checks passed
@rustbot rustbot added this to the 1.102.0 milestone Nov 7, 2026
rust-bors Bot pushed a commit that referenced this pull request Nov 7, 2026
Rollup merge of #165561 - lqd:opt-dist, r=kobzol

Assorted opt-dist fixes and improvements

r? kobzol

I've been looking at PGO again, and encountered some issues running `opt-dist` locally:
- it currently panics because it seems to expect the metrics file to be always present, so I've made the metrics update optional
- it will copy and build rustc-perf every time you run it, even when specifying the "pre-built rustc-perf" config, so I've changed this to only happen if you don't use this pre-built arg.
- the recent additions to PGO more tools are mandatory, but it takes a really long time to build all the tools multiple times and run benchmarks, so I've made these opt-in on the CLI for local runs, but they are still on by default for CI runs of course.

Since these are a bit random and kind of unrelated, I've kept them in separate commits to make review easier.

Note that I've already done a perf run for these changes, and there were no changes in the x64 or aarch64 results. So that's I think at least rustc and rustdoc tested, but I don't know if we can use the perf collector to test everything? (clippy + clif maybe and if so we should do that, but I don't know about cargo itself?)
@lqd
lqd deleted the opt-dist branch November 7, 2026 15:37
JonathanBrouwer added a commit to JonathanBrouwer/rust that referenced this pull request Nov 12, 2026
More opt-dist improvements

Following up on rust-lang#165561, this PR fixes a small issue I saw locally: since we can now choose whether to optimize cargo, we need to pick the correct stage to pass to the collector when running benchmarks. We want the instrumented stage2 most of the time (e.g. on CI) but locally, we most likely don't want to instrument cargo and thus want to use stage0 (there won't be a stage2 cargo anyways)

(I've removed the second commit as I want to test it more on actual CI, so not in this PR)

r? kobzol
Zalathar added a commit to Zalathar/rust that referenced this pull request Nov 13, 2026
More opt-dist improvements

Following up on rust-lang#165561, this PR fixes a small issue I saw locally: since we can now choose whether to optimize cargo, we need to pick the correct stage to pass to the collector when running benchmarks. We want the instrumented stage2 most of the time (e.g. on CI) but locally, we most likely don't want to instrument cargo and thus want to use stage0 (there won't be a stage2 cargo anyways)

(I've removed the second commit as I want to test it more on actual CI, so not in this PR)

r? kobzol
Zalathar added a commit to Zalathar/rust that referenced this pull request Nov 13, 2026
More opt-dist improvements

Following up on rust-lang#165561, this PR fixes a small issue I saw locally: since we can now choose whether to optimize cargo, we need to pick the correct stage to pass to the collector when running benchmarks. We want the instrumented stage2 most of the time (e.g. on CI) but locally, we most likely don't want to instrument cargo and thus want to use stage0 (there won't be a stage2 cargo anyways)

(I've removed the second commit as I want to test it more on actual CI, so not in this PR)

r? kobzol
JonathanBrouwer added a commit to JonathanBrouwer/rust that referenced this pull request Nov 13, 2026
More opt-dist improvements

Following up on rust-lang#165561, this PR fixes a small issue I saw locally: since we can now choose whether to optimize cargo, we need to pick the correct stage to pass to the collector when running benchmarks. We want the instrumented stage2 most of the time (e.g. on CI) but locally, we most likely don't want to instrument cargo and thus want to use stage0 (there won't be a stage2 cargo anyways)

(I've removed the second commit as I want to test it more on actual CI, so not in this PR)

r? kobzol
JonathanBrouwer added a commit to JonathanBrouwer/rust that referenced this pull request Nov 13, 2026
More opt-dist improvements

Following up on rust-lang#165561, this PR fixes a small issue I saw locally: since we can now choose whether to optimize cargo, we need to pick the correct stage to pass to the collector when running benchmarks. We want the instrumented stage2 most of the time (e.g. on CI) but locally, we most likely don't want to instrument cargo and thus want to use stage0 (there won't be a stage2 cargo anyways)

(I've removed the second commit as I want to test it more on actual CI, so not in this PR)

r? kobzol
rust-bors Bot pushed a commit that referenced this pull request Nov 13, 2026
Rollup merge of #165849 - lqd:opt-dist-again, r=Kobzol

More opt-dist improvements

Following up on #165561, this PR fixes a small issue I saw locally: since we can now choose whether to optimize cargo, we need to pick the correct stage to pass to the collector when running benchmarks. We want the instrumented stage2 most of the time (e.g. on CI) but locally, we most likely don't want to instrument cargo and thus want to use stage0 (there won't be a stage2 cargo anyways)

(I've removed the second commit as I want to test it more on actual CI, so not in this PR)

r? kobzol
github-actions Bot pushed a commit to rust-lang/rustc-dev-guide that referenced this pull request Nov 16, 2026
More opt-dist improvements

Following up on rust-lang/rust#165561, this PR fixes a small issue I saw locally: since we can now choose whether to optimize cargo, we need to pick the correct stage to pass to the collector when running benchmarks. We want the instrumented stage2 most of the time (e.g. on CI) but locally, we most likely don't want to instrument cargo and thus want to use stage0 (there won't be a stage2 cargo anyways)

(I've removed the second commit as I want to test it more on actual CI, so not in this PR)

r? kobzol
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

S-waiting-on-bors Status: Waiting on bors to run and complete tests. Bors will change the label on completion.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants