Skip to content

perf: Use 1 bit to track splatting in FnDecl#155852

Draft
teor2345 wants to merge 10 commits intorust-lang:mainfrom
teor2345:fn-arg-splat-fndecl-bit
Draft

perf: Use 1 bit to track splatting in FnDecl#155852
teor2345 wants to merge 10 commits intorust-lang:mainfrom
teor2345:fn-arg-splat-fndecl-bit

Conversation

@teor2345
Copy link
Copy Markdown
Contributor

@teor2345 teor2345 commented Apr 27, 2026

This PR is based on #153697, and is waiting for it to merge.

This PR reduces the perf impact of #153697, resulting in an average 0.24% primary benchmark improvement, and no primary regressions.

This experiment stores one bit for "any argument is splatted" in FnDecl, then searches the arguments' attributes for the actual splatted index (if needed).

It also inlines some hot functions, which likely contributes to the improvement.

@rustbot rustbot added 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. T-rust-analyzer Relevant to the rust-analyzer team, which will review and decide on the PR/issue. labels Apr 27, 2026
@makai410
Copy link
Copy Markdown
Member

@bors try @rust-timer queue

1 similar comment
@Kivooeo

This comment was marked as duplicate.

@rust-timer

This comment has been minimized.

@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 Apr 27, 2026
rust-bors Bot pushed a commit that referenced this pull request Apr 27, 2026
[perf experiment]: Use 1 bit to track splatting in FnDecl
@rust-bors

This comment has been minimized.

rust-bors Bot pushed a commit that referenced this pull request Apr 27, 2026
[perf experiment]: Use 1 bit to track splatting in FnDecl
@rust-bors
Copy link
Copy Markdown
Contributor

rust-bors Bot commented Apr 27, 2026

☀️ Try build successful (CI)
Build commit: 95d605f (95d605f06120a8779456a7f48b4edbc65b46f1b4, parent: ca9a134e0985765ded9cfdde4030a5df4db7e2bd)

@rust-timer

This comment has been minimized.

@rust-timer
Copy link
Copy Markdown
Collaborator

Finished benchmarking commit (95d605f): 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
@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.2% [0.1%, 0.2%] 7
Regressions ❌
(secondary)
0.3% [0.2%, 0.4%] 11
Improvements ✅
(primary)
- - 0
Improvements ✅
(secondary)
-0.0% [-0.0%, -0.0%] 1
All ❌✅ (primary) 0.2% [0.1%, 0.2%] 7

Max RSS (memory usage)

Results (primary 1.0%, secondary -5.5%)

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

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

Cycles

Results (primary 2.3%, secondary 2.3%)

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

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

Binary size

Results (primary 0.1%, secondary 0.2%)

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%] 84
Regressions ❌
(secondary)
0.2% [0.0%, 0.7%] 58
Improvements ✅
(primary)
- - 0
Improvements ✅
(secondary)
- - 0
All ❌✅ (primary) 0.1% [0.0%, 0.2%] 84

Bootstrap: 488.117s -> 488.584s (0.10%)
Artifact size: 393.52 MiB -> 393.62 MiB (0.03%)

@rustbot rustbot added perf-regression Performance regression. and removed S-waiting-on-perf Status: Waiting on a perf run to be completed. labels Apr 27, 2026
@teor2345
Copy link
Copy Markdown
Contributor Author

teor2345 commented Apr 27, 2026

Perf between this PR and its parent #153697 is an 0.2% overall average improvement, with a few primary benchmarks regressing.

Perf between this PR and its grandparent (rollup) #155687 is an 0.24% average improvement, and no primary benchmarks regress.

So this is a win, new feature and better perf from the associated refactors.

Edit: secondary regressions (worst first) are issue #46449, then coercions, then wg-grammar/externs.

@teor2345 teor2345 changed the title [perf experiment]: Use 1 bit to track splatting in FnDecl perf: Use 1 bit to track splatting in FnDecl Apr 27, 2026
@jieyouxu
Copy link
Copy Markdown
Member

@bors try @rust-timer queue

@rust-timer

This comment has been minimized.

@rust-bors

This comment has been minimized.

rust-bors Bot pushed a commit that referenced this pull request Apr 27, 2026
perf: Use 1 bit to track splatting in FnDecl
@rust-bors
Copy link
Copy Markdown
Contributor

rust-bors Bot commented Apr 27, 2026

☀️ Try build successful (CI)
Build commit: 72799b4 (72799b4e5e6830b7189ffbb40f0362bd1b0d896e, parent: 4933094f25ba1edf2de0a203665976832fc85bc9)

@rust-timer

This comment has been minimized.

@rust-timer
Copy link
Copy Markdown
Collaborator

Finished benchmarking commit (72799b4): 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
@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.2% [0.1%, 0.2%] 11
Regressions ❌
(secondary)
0.3% [0.2%, 0.4%] 13
Improvements ✅
(primary)
- - 0
Improvements ✅
(secondary)
- - 0
All ❌✅ (primary) 0.2% [0.1%, 0.2%] 11

Max RSS (memory usage)

Results (primary 3.5%, secondary 3.5%)

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

mean range count
Regressions ❌
(primary)
3.5% [3.5%, 3.5%] 1
Regressions ❌
(secondary)
3.5% [1.1%, 5.8%] 2
Improvements ✅
(primary)
- - 0
Improvements ✅
(secondary)
- - 0
All ❌✅ (primary) 3.5% [3.5%, 3.5%] 1

Cycles

Results (secondary -2.2%)

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)
- - 0
Improvements ✅
(primary)
- - 0
Improvements ✅
(secondary)
-2.2% [-2.2%, -2.2%] 1
All ❌✅ (primary) - - 0

Binary size

Results (primary 0.1%, secondary 0.2%)

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%] 84
Regressions ❌
(secondary)
0.2% [0.0%, 0.7%] 58
Improvements ✅
(primary)
- - 0
Improvements ✅
(secondary)
- - 0
All ❌✅ (primary) 0.1% [0.0%, 0.2%] 84

Bootstrap: 488.817s -> 487.887s (-0.19%)
Artifact size: 393.48 MiB -> 393.56 MiB (0.02%)

@teor2345 teor2345 force-pushed the fn-arg-splat-fndecl-bit branch from 8a11dd0 to ca09339 Compare April 28, 2026 01:22
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

A-attributes Area: Attributes (`#[…]`, `#![…]`) perf-regression Performance regression. 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. T-rust-analyzer Relevant to the rust-analyzer 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