Skip to content

[wip] terminator perf experiments - #159928

Draft
panstromek wants to merge 9 commits into
rust-lang:mainfrom
panstromek:shrink-terminator-kind
Draft

[wip] terminator perf experiments#159928
panstromek wants to merge 9 commits into
rust-lang:mainfrom
panstromek:shrink-terminator-kind

Conversation

@panstromek

@panstromek panstromek commented Jul 25, 2026

Copy link
Copy Markdown
Contributor

@rustbot rustbot added S-waiting-on-author Status: This is awaiting some action (such as code changes or more information) from the author. T-compiler Relevant to the compiler team, which will review and decide on the PR/issue. labels Jul 25, 2026
@panstromek

Copy link
Copy Markdown
Contributor Author

hoping for no impact here for now

@bors try @rust-timer queue

@rust-timer

This comment has been minimized.

@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 Jul 25, 2026
rust-bors Bot pushed a commit that referenced this pull request Jul 25, 2026
@rust-bors

rust-bors Bot commented Jul 25, 2026

Copy link
Copy Markdown
Contributor

☀️ Try build successful (CI)
Build commit: c9696d1 (c9696d172403366b5d28ed4bee1020bea22674ce)
Base parent: 008fa22 (008fa22ce3f8d3c8dfaca2e6486043c2b21851eb)

@rust-timer

This comment has been minimized.

@rust-timer

Copy link
Copy Markdown
Collaborator

Finished benchmarking commit (c9696d1): comparison URL.

Overall result: ❌ regressions - 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

Our most reliable metric. Used to determine the overall result above. However, even this metric can be noisy.

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

Max RSS (memory usage)

Results (primary 4.3%, secondary -4.1%)

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

mean range count
Regressions ❌
(primary)
4.3% [4.3%, 4.3%] 1
Regressions ❌
(secondary)
- - 0
Improvements ✅
(primary)
- - 0
Improvements ✅
(secondary)
-4.1% [-6.5%, -1.7%] 2
All ❌✅ (primary) 4.3% [4.3%, 4.3%] 1

Cycles

Results (secondary -1.0%)

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

mean range count
Regressions ❌
(primary)
- - 0
Regressions ❌
(secondary)
4.1% [4.1%, 4.1%] 1
Improvements ✅
(primary)
- - 0
Improvements ✅
(secondary)
-6.0% [-6.0%, -6.0%] 1
All ❌✅ (primary) - - 0

Binary size

Results (primary 0.1%, secondary 0.1%)

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

mean range count
Regressions ❌
(primary)
0.1% [0.0%, 0.2%] 41
Regressions ❌
(secondary)
0.1% [0.0%, 0.1%] 41
Improvements ✅
(primary)
- - 0
Improvements ✅
(secondary)
- - 0
All ❌✅ (primary) 0.1% [0.0%, 0.2%] 41

Bootstrap: 489.346s -> 488.243s (-0.23%)
Artifact size: 387.69 MiB -> 387.82 MiB (0.03%)

@rustbot rustbot removed the S-waiting-on-perf Status: Waiting on a perf run to be completed. label Jul 26, 2026
@panstromek

panstromek commented Jul 26, 2026

Copy link
Copy Markdown
Contributor Author

Good, but looks like the metadata is slightly bigger. Probably because it encodes enum instead of just values & targets arrays. We could optimize that by encoding it as two arrays in all cases.

@panstromek

Copy link
Copy Markdown
Contributor 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 Jul 26, 2026
@rust-bors

This comment has been minimized.

rust-bors Bot pushed a commit that referenced this pull request Jul 26, 2026
@rust-log-analyzer

This comment has been minimized.

@rust-bors

rust-bors Bot commented Jul 26, 2026

Copy link
Copy Markdown
Contributor

☀️ Try build successful (CI)
Build commit: a75e38e (a75e38eed3fb412c5725c75ad8ccb15cbc512bd2)
Base parent: fdbd8ee (fdbd8ee70d9b68d98be873e1095d74cf9441f0c8)

@rust-timer

This comment has been minimized.

@rust-timer

Copy link
Copy Markdown
Collaborator

Finished benchmarking commit (a75e38e): comparison URL.

Overall result: ❌ regressions - 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

Our most reliable metric. Used to determine the overall result above. However, even this metric can be noisy.

mean range count
Regressions ❌
(primary)
- - 0
Regressions ❌
(secondary)
0.2% [0.2%, 0.2%] 1
Improvements ✅
(primary)
- - 0
Improvements ✅
(secondary)
- - 0
All ❌✅ (primary) - - 0

Max RSS (memory usage)

Results (primary 0.6%, secondary 4.4%)

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

mean range count
Regressions ❌
(primary)
3.0% [3.0%, 3.0%] 1
Regressions ❌
(secondary)
4.4% [4.4%, 4.4%] 1
Improvements ✅
(primary)
-1.7% [-1.7%, -1.7%] 1
Improvements ✅
(secondary)
- - 0
All ❌✅ (primary) 0.6% [-1.7%, 3.0%] 2

Cycles

Results (secondary 3.4%)

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

mean range count
Regressions ❌
(primary)
- - 0
Regressions ❌
(secondary)
3.4% [3.0%, 3.8%] 3
Improvements ✅
(primary)
- - 0
Improvements ✅
(secondary)
- - 0
All ❌✅ (primary) - - 0

Binary size

Results (primary 0.1%, secondary 0.1%)

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

mean range count
Regressions ❌
(primary)
0.1% [0.0%, 0.2%] 37
Regressions ❌
(secondary)
0.1% [0.0%, 0.1%] 40
Improvements ✅
(primary)
- - 0
Improvements ✅
(secondary)
- - 0
All ❌✅ (primary) 0.1% [0.0%, 0.2%] 37

Bootstrap: 487.865s -> 487.9s (0.01%)
Artifact size: 387.69 MiB -> 387.68 MiB (-0.00%)

@rustbot rustbot added A-attributes Area: Attributes (`#[…]`, `#![…]`) and removed S-waiting-on-perf Status: Waiting on a perf run to be completed. labels Jul 26, 2026
@panstromek

panstromek commented Jul 26, 2026

Copy link
Copy Markdown
Contributor Author

This is the first one that's supposed to have some impact - one byte down from TerminatorKind (and consequently Terminator and BasicBlockData), but achieved with ThinVec for Call args. That is less shrink_to_fit calls and possible reallocs, but also more heap usage for non-empty args.

@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 Jul 26, 2026
@rust-bors

This comment has been minimized.

rust-bors Bot pushed a commit that referenced this pull request Jul 26, 2026
@rust-log-analyzer

This comment has been minimized.

@rust-bors

rust-bors Bot commented Jul 26, 2026

Copy link
Copy Markdown
Contributor

☀️ Try build successful (CI)
Build commit: 1338b91 (1338b91d2abc3d1e9cca32ce60d67321e973062f)
Base parent: 9451e06 (9451e069c34e1d7db23a155dcf9c25d1bc127055)

@rust-timer

This comment has been minimized.

@rust-timer

Copy link
Copy Markdown
Collaborator

Finished benchmarking commit (1338b91): comparison URL.

Overall result: ❌ regressions - please read:

Benchmarking means the PR may be perf-sensitive. It's automatically marked not fit for rolling up. Overriding is possible but disadvised: it risks changing compiler perf.

Next, please: If you can, justify the regressions found in this try perf run in writing along with @rustbot label: +perf-regression-triaged. If not, fix the regressions and do another perf run. Neutral or positive results will clear the label automatically.

@bors rollup=never rustc-perf
@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
Regressions ❌
(secondary)
0.6% [0.2%, 2.6%] 19
Improvements ✅
(primary)
- - 0
Improvements ✅
(secondary)
-0.2% [-0.2%, -0.2%] 1
All ❌✅ (primary) - - 0

Max RSS (memory usage)

Results (primary 0.7%, secondary 0.4%)

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

mean range count
Regressions ❌
(primary)
1.0% [0.5%, 2.1%] 12
Regressions ❌
(secondary)
1.8% [1.2%, 2.4%] 2
Improvements ✅
(primary)
-3.1% [-3.1%, -3.1%] 1
Improvements ✅
(secondary)
-2.3% [-2.3%, -2.3%] 1
All ❌✅ (primary) 0.7% [-3.1%, 2.1%] 13

Cycles

Results (secondary 3.7%)

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

mean range count
Regressions ❌
(primary)
- - 0
Regressions ❌
(secondary)
3.7% [2.2%, 5.2%] 2
Improvements ✅
(primary)
- - 0
Improvements ✅
(secondary)
- - 0
All ❌✅ (primary) - - 0

Binary size

Results (primary 0.1%, secondary 0.1%)

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

mean range count
Regressions ❌
(primary)
0.1% [0.0%, 0.2%] 38
Regressions ❌
(secondary)
0.1% [0.0%, 0.1%] 40
Improvements ✅
(primary)
- - 0
Improvements ✅
(secondary)
- - 0
All ❌✅ (primary) 0.1% [0.0%, 0.2%] 38

Bootstrap: 489.176s -> 487.69s (-0.30%)
Artifact size: 387.73 MiB -> 387.69 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 Jul 26, 2026
@panstromek

Copy link
Copy Markdown
Contributor Author

hm. I wonder what's up with the new solver that it stresses this code that much. That doesn't seem super related.

@rust-bors

This comment has been minimized.

@panstromek
panstromek force-pushed the shrink-terminator-kind branch from 8a6e1dc to 4067656 Compare July 31, 2026 15:51
@panstromek

panstromek commented Jul 31, 2026

Copy link
Copy Markdown
Contributor Author

new solver changes were caused by thin-vec update. Those were resolved in other PRs, I also got a better Decodable impl from review on other PR. Let's try to test the impact after all those changes. I also tweaked take_array to avoid reallocating thinvec to box on error (bug!) path (probably negligible, but maybe optimizes better?).

@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 Jul 31, 2026
@rust-bors

This comment has been minimized.

rust-bors Bot pushed a commit that referenced this pull request Jul 31, 2026
@rust-bors

rust-bors Bot commented Jul 31, 2026

Copy link
Copy Markdown
Contributor

☀️ Try build successful (CI)
Build commit: ec6ec96 (ec6ec96bab4d0725e243de12ac839706103c3552)
Base parent: fc0f51f (fc0f51f5ca44d4586b0e309181382608cd6a8441)

@rust-timer

This comment has been minimized.

@rust-timer

Copy link
Copy Markdown
Collaborator

Finished benchmarking commit (ec6ec96): comparison URL.

Overall result: ❌✅ regressions and improvements - 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

Our most reliable metric. Used to determine the overall result above. However, even this metric can be noisy.

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

Max RSS (memory usage)

Results (primary 0.9%, secondary -0.1%)

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

mean range count
Regressions ❌
(primary)
1.1% [0.6%, 3.6%] 20
Regressions ❌
(secondary)
1.4% [0.4%, 2.4%] 2
Improvements ✅
(primary)
-0.5% [-0.6%, -0.5%] 4
Improvements ✅
(secondary)
-0.6% [-1.0%, -0.5%] 6
All ❌✅ (primary) 0.9% [-0.6%, 3.6%] 24

Cycles

Results (primary -0.7%, secondary 0.7%)

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

mean range count
Regressions ❌
(primary)
0.5% [0.5%, 0.5%] 1
Regressions ❌
(secondary)
1.7% [0.5%, 4.0%] 8
Improvements ✅
(primary)
-0.9% [-1.5%, -0.5%] 10
Improvements ✅
(secondary)
-0.7% [-0.9%, -0.4%] 6
All ❌✅ (primary) -0.7% [-1.5%, 0.5%] 11

Binary size

Results (primary 0.1%, secondary 0.0%)

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

mean range count
Regressions ❌
(primary)
0.1% [0.0%, 0.2%] 48
Regressions ❌
(secondary)
0.1% [0.0%, 0.1%] 41
Improvements ✅
(primary)
- - 0
Improvements ✅
(secondary)
-0.1% [-0.1%, -0.0%] 9
All ❌✅ (primary) 0.1% [0.0%, 0.2%] 48

Bootstrap: 491.246s -> 488.936s (-0.47%)
Artifact size: 390.66 MiB -> 390.59 MiB (-0.02%)

@rustbot rustbot removed S-waiting-on-perf Status: Waiting on a perf run to be completed. perf-regression Performance regression. labels Jul 31, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

A-attributes Area: Attributes (`#[…]`, `#![…]`) S-waiting-on-author Status: This is awaiting some action (such as code changes or more information) from the author. 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.

4 participants