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

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

This comment has been minimized.

@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
@compiler-errors compiler-errors force-pushed the incr-more-characteristic branch from 3695a33 to 2b34e6f Compare June 13, 2025 18:15
@compiler-errors
Copy link
Member Author

@bors2 try @rust-timer queue

@rust-timer

This comment has been minimized.

@rust-bors
Copy link

rust-bors bot commented Jun 13, 2025

⌛ Trying commit 2b34e6f with merge 70425c9

To cancel the try build, run the command @bors2 try cancel.

rust-bors bot added a commit that referenced this pull request Jun 13, 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`
@rustbot rustbot added the S-waiting-on-perf Status: Waiting on a perf run to be completed. label Jun 13, 2025
@rust-log-analyzer

This comment has been minimized.

@rust-bors
Copy link

rust-bors bot commented Jun 13, 2025

💔 Test failed

@compiler-errors compiler-errors force-pushed the incr-more-characteristic branch from 2b34e6f to edf7485 Compare June 13, 2025 19:53
@compiler-errors
Copy link
Member Author

@bors2 try @rust-timer queue

@rust-timer

This comment has been minimized.

@rust-bors
Copy link

rust-bors bot commented Jun 13, 2025

⌛ Trying commit edf7485 with merge c500484

To cancel the try build, run the command @bors2 try cancel.

rust-bors bot added a commit that referenced this pull request Jun 13, 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`
@rust-log-analyzer
Copy link
Collaborator

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

Click to see the possible cause of the failure (guessed by this bot)
---- [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
note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace

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

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

@rust-bors
Copy link

rust-bors bot commented Jun 13, 2025

☀️ Try build successful (CI)
Build commit: c500484 (c5004842700e4d9f3f326347878229ff0f2dae11, parent: 0d6ab209c525e276cbe7544cbd39a3c3619b6b18)

@rust-timer

This comment has been minimized.

@rust-timer
Copy link
Collaborator

Finished benchmarking commit (c500484): comparison URL.

Overall result: ❌✅ regressions and improvements - 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)
4.6% [0.3%, 18.0%] 30
Regressions ❌
(secondary)
3.9% [0.1%, 23.7%] 9
Improvements ✅
(primary)
-1.8% [-4.1%, -0.3%] 5
Improvements ✅
(secondary)
-2.3% [-2.8%, -1.8%] 3
All ❌✅ (primary) 3.7% [-4.1%, 18.0%] 35

Max RSS (memory usage)

Results (primary 0.9%, secondary -5.7%)

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

mean range count
Regressions ❌
(primary)
2.3% [1.2%, 4.5%] 6
Regressions ❌
(secondary)
- - 0
Improvements ✅
(primary)
-3.6% [-4.6%, -2.5%] 2
Improvements ✅
(secondary)
-5.7% [-5.7%, -5.7%] 1
All ❌✅ (primary) 0.9% [-4.6%, 4.5%] 8

Cycles

Results (primary 6.7%, secondary 6.0%)

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

mean range count
Regressions ❌
(primary)
8.5% [0.8%, 19.6%] 16
Regressions ❌
(secondary)
10.0% [2.4%, 26.1%] 4
Improvements ✅
(primary)
-2.6% [-3.9%, -1.8%] 3
Improvements ✅
(secondary)
-2.0% [-2.3%, -1.8%] 2
All ❌✅ (primary) 6.7% [-3.9%, 19.6%] 19

Binary size

Results (primary 0.4%, 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)
0.6% [0.0%, 1.8%] 61
Regressions ❌
(secondary)
5.2% [0.1%, 14.3%] 9
Improvements ✅
(primary)
-0.3% [-1.4%, -0.1%] 26
Improvements ✅
(secondary)
-2.4% [-5.3%, -0.0%] 14
All ❌✅ (primary) 0.4% [-1.4%, 1.8%] 87

Bootstrap: 755.964s -> 756.21s (0.03%)
Artifact size: 372.26 MiB -> 372.23 MiB (-0.01%)

@rustbot rustbot removed the S-waiting-on-perf Status: Waiting on a perf run to be completed. label Jun 14, 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