Repository navigation
Re-enable rustc profile generation for static linked llvm on Windows x64 builds - #164707
Conversation
|
Error: Failed to set assignee to
Failed to set assignee to
Failed to set assignee to
Please file an issue on GitHub at triagebot if there's a problem with this bot, or reach out on #triagebot on Zulip. |
|
Some changes occurred in src/tools/opt-dist cc @Kobzol |
|
Error: Failed to set assignee to
Please file an issue on GitHub at triagebot if there's a problem with this bot, or reach out on #triagebot on Zulip. |
|
Hey @wesleywiser @dpaoliello @ChrisDenton - could one of you take a look at this, or point it to the right reviewer? I've been talking with Marcus, who works on the Windows team and has been digging into Rust and LLVM build performance on Windows. This PR comes out of that work. On Windows x64, LLVM is statically linked into rustc, and the step that collects LLVM's PGO profile never rebuilds rustc against the instrumented LLVM. As a result, the shipped LLVM is "PGO optimized" with an almost empty profile. Marcus measured about a 14% compile-time improvement on x64 with the fix. Any help getting this reviewed would be much appreciated - it's a meaningful win for Rust on Windows, and there's more of this kind of work coming. |
|
👋 I just wanted to point out that the huge difference in Rust build performance was found through benchmarks I did on IronRDP, so I'm really looking forward to this big win for Windows Rust build performance! |
|
r? @Kobzol since you've been most heavily involved with PGO builds but anyone in @rust-lang/bootstrap could review 🙂 |
|
|
There was a problem hiding this comment.
Seems like there should also be a change to the workflows/actions configuration for x86_64-pc-windows-msvc to enable using opt-dist during builds right?
I think it would be helpful to push a change that enables this so we can do a try build and test this end-to-end even if we don't ultimately land that as part of this PR.
|
Just for future reference, it's usually best not to use That said, I am enthusiastic about the work being done here! |
There was a problem hiding this comment.
Hmm, that is strange, I think that LLVM was linked statically on Windows for a long time (i.e. no change was made there), and we did Windows benchmarks when we switched to opt-dist to confirm that PGO was still applied. Either we missed that one half of PGO was not being done in those benchmarks, or something regressed in the meantime.
Regarding the fix, I suspect that the whole pipeline is kind of ingrained on the notion of using dynamically linked LLVM. I wonder if we should have a separate pipeline for statically linked LLVM, because even with your fix, the first PGO optimized rustc is built unnecessarily, as it is immediately deleted and rebuilt from scratch. Or maybe we could change the build order, and optimize LLVM first.
In any case, I'm fine with this as a hotfix, modulo some nits.
Let's remove the tests, I think that they are kind of useless, because they are not testing the thing that actually gets run in CI or in opt-dist (it is of course very hard to test this quickly).
Let's check if Linux perf is unaffected, and do a try build to provide artifacts for checking Windows perf. locally:
@bors try jobs=dist-x86_64-linux,dist-x86_64-msvc
Seems like there should also be a change to the workflows/actions configuration for x86_64-pc-windows-msvc to enable using opt-dist during builds right?
We are already doing that (and have been doing it for the past N years :) ).
This comment has been minimized.
This comment has been minimized.
Re-enable rustc profile generation for static linked llvm on Windows x64 builds try-job: dist-x86_64-linux try-job: dist-x86_64-msvc
This comment has been minimized.
This comment has been minimized.
|
💔 Test for 4475788 failed: CI. Failed job:
|
|
Hey @Kobzol, can you kick the bot for the msvc run again please. I missed a one line for the dry-run that should be fixed now |
|
@bors try jobs=dist-x86_64-linux,dist-x86_64-msvc |
This comment has been minimized.
This comment has been minimized.
Re-enable rustc profile generation for static linked llvm on Windows x64 builds try-job: dist-x86_64-linux try-job: dist-x86_64-msvc
Rebuilding rustc against statically linked LLVM now reaches the code that locates clang’s profiling runtime that was previously skipped. Bootstrap checks during dry-run mode also need to discover clang-cl, so this change means now run_in_dry_run() adds clang-cl during the planning pass and avoids the panic check later.
|
I'll r+ it again if you can get rid of the merge commit, please :) |
3f795fe to
66162cb
Compare
|
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. |
|
ok that should be it |
|
Thanks. @bors r+ |
…ing, r=Kobzol Re-enable rustc profile generation for static linked llvm on Windows x64 builds Fix the sequence for LLVM’s PGO training with rust when LLVM is statically linked. Delivers ~14% compile time improvements for x64 build's (using rust v1.94.1 and IronRDP as a test project). Also (using LLM to generate) added a test validation step that checks the correct PGO training is taking place for each of the build flavours. This does not impact builds for Linux +Mac targets as LLVM is not statically linked. Neither does it directly impact Windows on Arm builds as PGO is disabled on those productions. Details: When rustc and llvm are linked statically the opt-dist now rebuilds rustc with the existing rustc PGO profile while generating LLVM instrumentation build. When LLVM is a shared component the existing behaviour remains, avoiding the additional rustc build. Static linked llvm needs to be rebuilt to use the instrumented LLVM before a profile will be correctly generated. The rest adds a regression test covering Linux and Windows hosts, both fast-try-build settings, and registers opt-dist in the normal bootstrap test suite. The snapshot updates reflect that new test-suite entry. Impact on the release-build wall-clock time for x64 is expected to be around 5-10 mins, keeping it well within the limits for a standard runner. UPDATE (23rd Oct) I re-ran this using v1.99.1 to validate on latest. Applying this to 1.99.1 and using IronRDP again as a measure, the compilation wall time reduction was 12.9% and CPU time was down by 13.7%. Tests and additional correctness passed. The cost of release-build was about the same (using a 16-core test machine) LLM disclosure: GPT-6 Astra was used to... - point out the absence of PGO page hits on release rustc builds - identify the cause of the PGO misses - suggest a new test scenario to validate - run multiple perf comparison runs to validate impact and robustness of the fix. Full investigation results available here: https://github.com/marcpems/IronRDP-ci-benchmark/blob/experiment/x64-pgo-comparison/ci-benchmark/X64-PROFILE-ONLY.md r? @Ciura r? @kennykerr r? @manbearian
…uwer Rollup of 12 pull requests Successful merges: - #164707 (Re-enable rustc profile generation for static linked llvm on Windows x64 builds ) - #165221 (Canonicalize more comparison operators) - #165880 (Remove dead code for returning `BackendRepr::Memory` with `PassMode::Direct`) - #164108 (Add unstable `-Zllvm-tpde` flag to `rustc_codegen_llvm`) - #165565 (view-types: lower view types from HIR) - #165771 (tests: cover MSVC ThinLTO exported symbol preservation) - #165810 (reflection: reflect attributes from adts, fields, and variants) - #165823 (Tweak crate error wording and turn them into fatal errors) - #165849 (More opt-dist improvements) - #165855 (Update `sysinfo` version to `0.40.3`) - #165861 (cg_llvm: Use an invariant lifetime brand for LLVM attributes) - #165872 (Some attribute related cleanups)
Re-enable rustc profile generation for static linked llvm on Windows x64 builds Fix the sequence for LLVM’s PGO training with rust when LLVM is statically linked. Delivers ~14% compile time improvements for x64 build's (using rust v1.94.1 and IronRDP as a test project). Also (using LLM to generate) added a test validation step that checks the correct PGO training is taking place for each of the build flavours. This does not impact builds for Linux +Mac targets as LLVM is not statically linked. Neither does it directly impact Windows on Arm builds as PGO is disabled on those productions. Details: When rustc and llvm are linked statically the opt-dist now rebuilds rustc with the existing rustc PGO profile while generating LLVM instrumentation build. When LLVM is a shared component the existing behaviour remains, avoiding the additional rustc build. Static linked llvm needs to be rebuilt to use the instrumented LLVM before a profile will be correctly generated. The rest adds a regression test covering Linux and Windows hosts, both fast-try-build settings, and registers opt-dist in the normal bootstrap test suite. The snapshot updates reflect that new test-suite entry. Impact on the release-build wall-clock time for x64 is expected to be around 5-10 mins, keeping it well within the limits for a standard runner. UPDATE (23rd Oct) I re-ran this using v1.99.1 to validate on latest. Applying this to 1.99.1 and using IronRDP again as a measure, the compilation wall time reduction was 12.9% and CPU time was down by 13.7%. Tests and additional correctness passed. The cost of release-build was about the same (using a 16-core test machine) LLM disclosure: GPT-6 Astra was used to... - point out the absence of PGO page hits on release rustc builds - identify the cause of the PGO misses - suggest a new test scenario to validate - run multiple perf comparison runs to validate impact and robustness of the fix. Full investigation results available here: https://github.com/marcpems/IronRDP-ci-benchmark/blob/experiment/x64-pgo-comparison/ci-benchmark/X64-PROFILE-ONLY.md r? @Ciura r? @kennykerr r? @manbearian
This comment has been minimized.
This comment has been minimized.
…ing, r=Kobzol Re-enable rustc profile generation for static linked llvm on Windows x64 builds Fix the sequence for LLVM’s PGO training with rust when LLVM is statically linked. Delivers ~14% compile time improvements for x64 build's (using rust v1.94.1 and IronRDP as a test project). Also (using LLM to generate) added a test validation step that checks the correct PGO training is taking place for each of the build flavours. This does not impact builds for Linux +Mac targets as LLVM is not statically linked. Neither does it directly impact Windows on Arm builds as PGO is disabled on those productions. Details: When rustc and llvm are linked statically the opt-dist now rebuilds rustc with the existing rustc PGO profile while generating LLVM instrumentation build. When LLVM is a shared component the existing behaviour remains, avoiding the additional rustc build. Static linked llvm needs to be rebuilt to use the instrumented LLVM before a profile will be correctly generated. The rest adds a regression test covering Linux and Windows hosts, both fast-try-build settings, and registers opt-dist in the normal bootstrap test suite. The snapshot updates reflect that new test-suite entry. Impact on the release-build wall-clock time for x64 is expected to be around 5-10 mins, keeping it well within the limits for a standard runner. UPDATE (23rd Oct) I re-ran this using v1.99.1 to validate on latest. Applying this to 1.99.1 and using IronRDP again as a measure, the compilation wall time reduction was 12.9% and CPU time was down by 13.7%. Tests and additional correctness passed. The cost of release-build was about the same (using a 16-core test machine) LLM disclosure: GPT-6 Astra was used to... - point out the absence of PGO page hits on release rustc builds - identify the cause of the PGO misses - suggest a new test scenario to validate - run multiple perf comparison runs to validate impact and robustness of the fix. Full investigation results available here: https://github.com/marcpems/IronRDP-ci-benchmark/blob/experiment/x64-pgo-comparison/ci-benchmark/X64-PROFILE-ONLY.md r? @Ciura r? @kennykerr r? @manbearian
|
@bors yield (enclosing rollup) |
|
Auto build was cancelled. Cancelled workflows: The next pull request likely to be tested is #165897. |
Rollup of 13 pull requests Successful merges: - #164707 (Re-enable rustc profile generation for static linked llvm on Windows x64 builds ) - #165068 (Change color usage for highlights) - #165841 (Tell Miri about the alignment handling in the Windows System allocator) - #165880 (Remove dead code for returning `BackendRepr::Memory` with `PassMode::Direct`) - #164108 (Add unstable `-Zllvm-tpde` flag to `rustc_codegen_llvm`) - #165565 (view-types: lower view types from HIR) - #165622 (small cleanups in rustc_codegen_llvm) - #165771 (tests: cover MSVC ThinLTO exported symbol preservation) - #165810 (reflection: reflect attributes from adts, fields, and variants) - #165823 (Tweak crate error wording and turn them into fatal errors) - #165849 (More opt-dist improvements) - #165855 (Update `sysinfo` version to `0.40.3`) - #165872 (Some attribute related cleanups) Failed merges: - #165861 (cg_llvm: Use an invariant lifetime brand for LLVM attributes)
This comment has been minimized.
This comment has been minimized.
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 8eb778d (parent) -> 75bb7a3 (this PR) Test differencesShow 2 test diffs2 doctest diffs were found. These are ignored, as they are noisy. Test dashboardRun cargo run --manifest-path src/ci/citool/Cargo.toml -- \
test-dashboard 75bb7a374ff3f5363432a17e8000b50a60a4530c --output-dir test-dashboardAnd then open Job duration changes
How to interpret the job duration changes?Job durations can vary a lot, based on the actual runner instance |
|
Finished benchmarking commit (75bb7a3): comparison URL. Overall result: no relevant changes - no action needed@rustbot label: -perf-regression Instruction countThis perf run didn't have relevant results for this metric. 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.
CyclesThis perf run didn't have relevant results for this metric. Binary sizeThis perf run didn't have relevant results for this metric. Bootstrap: 488.192s -> 483.141s (-1.03%) |
View all comments
Fix the sequence for LLVM’s PGO training with rust when LLVM is statically linked. Delivers ~14% compile time improvements for x64 build's (using rust v1.94.1 and IronRDP as a test project). Also (using LLM to generate) added a test validation step that checks the correct PGO training is taking place for each of the build flavours.
This does not impact builds for Linux +Mac targets as LLVM is not statically linked. Neither does it directly impact Windows on Arm builds as PGO is disabled on those productions.
Details:
When rustc and llvm are linked statically the opt-dist now rebuilds rustc with the existing rustc PGO profile while generating LLVM instrumentation build. When LLVM is a shared component the existing behaviour remains, avoiding the additional rustc build. Static linked llvm needs to be rebuilt to use the instrumented LLVM before a profile will be correctly generated.
The rest adds a regression test covering Linux and Windows hosts, both fast-try-build settings, and registers opt-dist in the normal bootstrap test suite. The snapshot updates reflect that new test-suite entry.
Impact on the release-build wall-clock time for x64 is expected to be around 5-10 mins, keeping it well within the limits for a standard runner.
UPDATE (23rd Oct)
I re-ran this using v1.99.1 to validate on latest. Applying this to 1.99.1 and using IronRDP again as a measure, the compilation wall time reduction was 12.9% and CPU time was down by 13.7%. Tests and additional correctness passed.
The cost of release-build was about the same (using a 16-core test machine)
LLM disclosure: GPT-6 Astra was used to...
Full investigation results available here: https://github.com/marcpems/IronRDP-ci-benchmark/blob/experiment/x64-pgo-comparison/ci-benchmark/X64-PROFILE-ONLY.md
r? @Ciura
r? @kennykerr
r? @manbearian