Skip to content

[PERF] partition shims into CGU of their characteristic types, if possible #141560

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Draft
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

compiler-errors
Copy link
Member

@compiler-errors compiler-errors commented May 25, 2025

We throw all non-InstanceKind::Item mono items into the same fallback CGU. This seems to have been a thing since #32779. This PR investigates: what happens to incremental codegen if we didn't do that, but tried a bit harder to partition shims into the same CGU as their characteristic types?

r? @ghost

@rustbot rustbot added the T-compiler Relevant to the compiler team, which will review and decide on the PR/issue. label May 25, 2025
@compiler-errors compiler-errors changed the title More characteristic def ids [PERF] partition shims into CGU of their characteristic types, if possible May 25, 2025
@compiler-errors
Copy link
Member 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 May 25, 2025
@bors
Copy link
Collaborator

bors commented May 25, 2025

⌛ Trying commit 8ce6e6e with merge 01c9c97...

bors added a commit that referenced this pull request May 25, 2025
…try>

[PERF] partition shims into CGU of their characteristic types, if possible

We throw all non-`InstanceKind::Item` mono items into the same fallback CGU. What happens to incremental codegen if we didn't do that, but tried a bit harder to partition shims into the same CGU as their characteristic types?

r? `@ghost`
@rust-log-analyzer

This comment has been minimized.

@compiler-errors compiler-errors force-pushed the incr-more-characteristic branch from 8ce6e6e to 3695a33 Compare May 25, 2025 22:04
@compiler-errors
Copy link
Member Author

@bors try @rust-timer queue

@rust-timer

This comment has been minimized.

bors added a commit that referenced this pull request May 25, 2025
…try>

[PERF] partition shims into CGU of their characteristic types, if possible

We throw all non-`InstanceKind::Item` mono items into the same fallback CGU. This seems to have been a thing since #32779. This PR investigates: what happens to incremental codegen if we didn't do that, but tried a bit harder to partition shims into the same CGU as their characteristic types?

r? `@ghost`
@bors
Copy link
Collaborator

bors commented May 25, 2025

⌛ Trying commit 3695a33 with merge 155e6b9...

@rust-log-analyzer
Copy link
Collaborator

The job x86_64-gnu-llvm-19 failed! Check out the build log: (web) (plain)

Click to see the possible cause of the failure (guessed by this bot)
#18 exporting to docker image format
#18 sending tarball 21.0s done
#18 DONE 27.7s
##[endgroup]
Setting extra environment values for docker:  --env ENABLE_GCC_CODEGEN=1 --env GCC_EXEC_PREFIX=/usr/lib/gcc/
[CI_JOB_NAME=x86_64-gnu-llvm-19]
[CI_JOB_NAME=x86_64-gnu-llvm-19]
debug: `DISABLE_CI_RUSTC_IF_INCOMPATIBLE` configured.
---
sccache: Listening on address 127.0.0.1:4226
##[group]Configure the build
configure: processing command line
configure: 
configure: build.configure-args := ['--build=x86_64-unknown-linux-gnu', '--llvm-root=/usr/lib/llvm-19', '--enable-llvm-link-shared', '--set', 'rust.randomize-layout=true', '--set', 'rust.thin-lto-import-instr-limit=10', '--set', 'build.print-step-timings', '--enable-verbose-tests', '--set', 'build.metrics', '--enable-verbose-configure', '--enable-sccache', '--disable-manage-submodules', '--enable-locked-deps', '--enable-cargo-native-static', '--set', 'rust.codegen-units-std=1', '--set', 'dist.compression-profile=balanced', '--dist-compression-formats=xz', '--set', 'rust.lld=false', '--disable-dist-src', '--release-channel=nightly', '--enable-debug-assertions', '--enable-overflow-checks', '--enable-llvm-assertions', '--set', 'rust.verify-llvm-ir', '--set', 'rust.codegen-backends=llvm,cranelift,gcc', '--set', 'llvm.static-libstdcpp', '--set', 'gcc.download-ci-gcc=true', '--enable-new-symbol-mangling']
configure: build.build          := x86_64-unknown-linux-gnu
configure: target.x86_64-unknown-linux-gnu.llvm-config := /usr/lib/llvm-19/bin/llvm-config
configure: llvm.link-shared     := True
configure: rust.randomize-layout := True
configure: rust.thin-lto-import-instr-limit := 10
---
---- [codegen-units] tests/codegen-units/partitioning/local-drop-glue.rs stdout ----

The following items were assigned to wrong codegen units:

fn <Struct as std::ops::Drop>::drop
  expected: local_drop_glue-fallback.cgu[External] 
  actual:   local_drop_glue[External] 

fn std::ptr::drop_in_place::<(u32, Struct)> - shim(Some((u32, Struct)))
  expected: local_drop_glue-fallback.cgu[External] 
  actual:   local_drop_glue.volatile[External] 

fn std::ptr::drop_in_place::<Outer> - shim(Some(Outer))
  expected: local_drop_glue-fallback.cgu[External] 
  actual:   local_drop_glue.volatile[External] 

fn std::ptr::drop_in_place::<Struct> - shim(Some(Struct))
  expected: local_drop_glue-fallback.cgu[External] 
  actual:   local_drop_glue.volatile[External] 

fn std::ptr::drop_in_place::<mod1::Struct2> - shim(Some(mod1::Struct2))
  expected: local_drop_glue-fallback.cgu[External] 
  actual:   local_drop_glue-mod1.volatile[External] 


thread '[codegen-units] tests/codegen-units/partitioning/local-drop-glue.rs' panicked at src/tools/compiletest/src/runtest/codegen_units.rs:103:13:
explicit panic
note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace

---- [codegen-units] tests/codegen-units/partitioning/vtable-through-const.rs stdout ----

The following items were assigned to wrong codegen units:

fn <mod1::NeedsDrop as std::ops::Drop>::drop
  expected: vtable_through_const-fallback.cgu[External] 
  actual:   vtable_through_const-mod1[External] 

fn std::ptr::drop_in_place::<mod1::NeedsDrop> - shim(Some(mod1::NeedsDrop))
  expected: vtable_through_const-fallback.cgu[External] 
  actual:   vtable_through_const-mod1.volatile[External] 


thread '[codegen-units] tests/codegen-units/partitioning/vtable-through-const.rs' panicked at src/tools/compiletest/src/runtest/codegen_units.rs:103:13:
explicit panic

---- [codegen-units] tests/codegen-units/partitioning/extern-drop-glue.rs stdout ----

The following items were assigned to wrong codegen units:

fn std::ptr::drop_in_place::<LocalStruct> - shim(Some(LocalStruct))
  expected: extern_drop_glue-fallback.cgu[External] 
  actual:   extern_drop_glue.volatile[External] 

fn std::ptr::drop_in_place::<cgu_extern_drop_glue::Struct> - shim(Some(cgu_extern_drop_glue::Struct))
  expected: extern_drop_glue-fallback.cgu[External] 
  actual:   cgu_extern_drop_glue-in-extern_drop_glue.volatile[External] 

fn std::ptr::drop_in_place::<mod1::LocalStruct> - shim(Some(mod1::LocalStruct))
  expected: extern_drop_glue-fallback.cgu[External] 
  actual:   extern_drop_glue-mod1.volatile[External] 


thread '[codegen-units] tests/codegen-units/partitioning/extern-drop-glue.rs' panicked at src/tools/compiletest/src/runtest/codegen_units.rs:103:13:
explicit panic

@bors
Copy link
Collaborator

bors commented May 26, 2025

☀️ Try build successful - checks-actions
Build commit: 155e6b9 (155e6b96fcb60833ff6194a1e370d66371850f47)

@rust-timer

This comment has been minimized.

@rust-timer
Copy link
Collaborator

Finished benchmarking commit (155e6b9): comparison URL.

Overall result: ❌✅ regressions and improvements - please read the text below

Benchmarking this pull request likely means that it is perf-sensitive, so we're automatically marking it as not fit for rolling up. While you can manually mark this PR as fit for rollup, we strongly recommend not doing so since this PR may lead to changes in compiler perf.

Next Steps: If you can justify the regressions found in this try perf run, please indicate this with @rustbot label: +perf-regression-triaged along with sufficient written justification. If you cannot justify the regressions please fix the regressions and do another perf run. If the next run shows neutral or positive results, the label will be automatically removed.

@bors rollup=never
@rustbot label: -S-waiting-on-perf +perf-regression

Instruction count

This is the most reliable metric that we have; it was used to determine the overall result at the top of this comment. However, even this metric can sometimes exhibit noise.

mean range count
Regressions ❌
(primary)
4.9% [0.2%, 17.9%] 30
Regressions ❌
(secondary)
4.3% [0.2%, 23.6%] 8
Improvements ✅
(primary)
-2.0% [-4.2%, -0.3%] 5
Improvements ✅
(secondary)
-1.2% [-2.7%, -0.2%] 8
All ❌✅ (primary) 3.9% [-4.2%, 17.9%] 35

Max RSS (memory usage)

Results (primary 0.4%, secondary -0.7%)

This is a less reliable metric that may be of interest but was not used to determine the overall result at the top of this comment.

mean range count
Regressions ❌
(primary)
3.4% [1.2%, 9.9%] 8
Regressions ❌
(secondary)
2.5% [2.3%, 2.8%] 3
Improvements ✅
(primary)
-3.7% [-5.0%, -1.2%] 6
Improvements ✅
(secondary)
-3.9% [-5.2%, -2.1%] 3
All ❌✅ (primary) 0.4% [-5.0%, 9.9%] 14

Cycles

Results (primary 6.6%, secondary 5.3%)

This is a less reliable metric that may be of interest but was not used to determine the overall result at the top of this comment.

mean range count
Regressions ❌
(primary)
8.2% [0.8%, 19.7%] 18
Regressions ❌
(secondary)
9.1% [0.8%, 26.4%] 4
Improvements ✅
(primary)
-2.7% [-4.2%, -1.7%] 3
Improvements ✅
(secondary)
-2.3% [-2.9%, -1.7%] 2
All ❌✅ (primary) 6.6% [-4.2%, 19.7%] 21

Binary size

Results (primary 0.4%, secondary 0.5%)

This is a less reliable metric that may be of interest but was not used to determine the overall result at the top of this comment.

mean range count
Regressions ❌
(primary)
0.6% [0.0%, 1.8%] 59
Regressions ❌
(secondary)
4.6% [0.0%, 14.4%] 10
Improvements ✅
(primary)
-0.3% [-0.7%, -0.0%] 25
Improvements ✅
(secondary)
-2.5% [-5.4%, -0.0%] 14
All ❌✅ (primary) 0.4% [-0.7%, 1.8%] 84

Bootstrap: 775.708s -> 776.167s (0.06%)
Artifact size: 366.25 MiB -> 366.31 MiB (0.02%)

@rustbot rustbot added perf-regression Performance regression. and removed S-waiting-on-perf Status: Waiting on a perf run to be completed. labels May 26, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
perf-regression Performance regression. 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.

6 participants