Skip to content

Move fast paths around to gain a bit of new-solver perf#158249

Open
jdonszelmann wants to merge 8 commits into
rust-lang:mainfrom
jdonszelmann:move-checks
Open

Move fast paths around to gain a bit of new-solver perf#158249
jdonszelmann wants to merge 8 commits into
rust-lang:mainfrom
jdonszelmann:move-checks

Conversation

@jdonszelmann

@jdonszelmann jdonszelmann commented Jun 22, 2026

Copy link
Copy Markdown
Contributor

Change in % compared to previous commit on 4 benchmarks. All measured locally on ragdoll (AMD RYZEN 3990X, x86_64). These benchmarks have been quite repeatable in the past, but don't exactly match perf runs. All benchmarks show change in instruction count
First change is compared to baseline
Commit ids may change on rebases, so these links may become outdated.

nalgebra [check,debug,opt] serde [check,debug, opt] syn [check, debug, opt] wg-grammar [check, debug, opt]
move overflow check $${\color{green}-0.04\%}$$
$${\color{green}-0.03\%}$$
$${\color{green}-0.02\%}$$
$${\color{green}-0.15\%}$$
$${\color{green}-0.12\%}$$
$${\color{green}-0.11\%}$$
$${\color{green}-0.08\%}$$
$${\color{green}-0.04\%}$$
$${\color{green}-0.01\%}$$
$${\color{green}-0.32\%}$$
$${\color{green}-0.31\%}$$
$${\color{green}-0.29\%}$$
move fast path into evaluate_goal $${\color{red}+0.61\%}$$
$${\color{red}+0.60\%}$$
$${\color{red}+0.43\%}$$
$${\color{red}+0.75\%}$$
$${\color{red}+0.69\%}$$
$${\color{red}+0.65\%}$$
$${\color{red}+0.55\%}$$
$${\color{red}+0.36\%}$$
$${\color{red}+0.14\%}$$
$${\color{red}+0.13\%}$$
$${\color{red}+0.21\%}$$
$${\color{red}+0.15\%}$$
remove fastpath from fullfilment loop $${\color{red}+0.56\%}$$
$${\color{red}+0.50\%}$$
$${\color{red}+0.35\%}$$
$${\color{red}+3.33\%}$$
$${\color{red}+2.76\%}$$
$${\color{red}+2.55\%}$$
$${\color{red}+1.65\%}$$
$${\color{red}+0.93\%}$$
$${\color{red}+0.33\%}$$
$${\color{green}-5.06\%}$$
$${\color{green}-5.00\%}$$
$${\color{green}-4.65\%}$$
return stalled info from fast path $${\color{red}+0.16\%}$$
$${\color{red}+0.16\%}$$
$${\color{red}+0.12\%}$$
$${\color{red}+0.01\%}$$
$${\color{red}+0.01\%}$$
$${\color{red}+0.01\%}$$
$${\color{red}+0.24\%}$$
$${\color{red}+0.15\%}$$
$${\color{red}+0.05\%}$$
$${\color{green}-0.24\%}$$
$${\color{green}-0.24\%}$$
$${\color{green}-0.25\%}$$
move goal fast path into evaluate_goal_cold $${\color{red}+0.01\%}$$
$${\color{red}+0.01\%}$$
$${\color{red}+0.01\%}$$
$${\color{red}+0.02\%}$$
$${\color{red}+0.02\%}$$
$${\color{red}+0.02\%}$$
$${\color{red}+0.02\%}$$
$${\color{red}+0.02\%}$$
$${\color{red}+0.01\%}$$
$${\color{green}-0.01\%}$$
$${\color{green}-0.01\%}$$
$${\color{green}-0.01\%}$$
shuffle fastpaths around to before creating an evalctxt $${\color{green}-0.44\%}$$
$${\color{green}-0.41\%}$$
$${\color{green}-0.30\%}$$
$${\color{green}-2.31\%}$$
$${\color{green}-1.93\%}$$
$${\color{green}-1.80\%}$$
$${\color{green}-1.29\%}$$
$${\color{green}-0.77\%}$$
$${\color{green}-0.29\%}$$
$${\color{green}-6.06\%}$$
$${\color{green}-5.90\%}$$
$${\color{green}-5.48\%}$$
fast path when adding goals $${\color{green}-0.62\%}$$
$${\color{green}-0.58\%}$$
$${\color{green}-0.41\%}$$
$${\color{green}-0.78\%}$$
$${\color{green}-0.66\%}$$
$${\color{green}-0.61\%}$$
$${\color{green}-0.36\%}$$
$${\color{green}-0.28\%}$$
$${\color{green}-0.10\%}$$
$${\color{green}-0.12\%}$$
$${\color{green}-0.09\%}$$
$${\color{green}-0.04\%}$$
overall from baseline $${\color{red}+0.24\%}$$
$${\color{red}+0.23\%}$$
$${\color{red}+0.16\%}$$
$${\color{red}+0.79\%}$$
$${\color{red}+0.70\%}$$
$${\color{red}+0.66\%}$$
$${\color{red}+0.60\%}$$
$${\color{red}+0.36\%}$$
$${\color{red}+0.13\%}$$
$${\color{green}-11.31\%}$$
$${\color{green}-11.00\%}$$
$${\color{green}-10.27\%}$$

View all comments

@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. WG-trait-system-refactor The Rustc Trait System Refactor Initiative (-Znext-solver) labels Jun 22, 2026
@jdonszelmann

Copy link
Copy Markdown
Contributor Author

This tests a bunch of changes together. I've done diffs locally suggesting ~5% speedup across these 7 commits. Moving fast path checks to evaluate_goal_raw ~2%, making it return stalled_on another 3% or so and using TyOrConstInferVar ~0.5%

@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 Jun 22, 2026
rust-bors Bot pushed a commit that referenced this pull request Jun 22, 2026
Move fast path checks to `evaluate_goal_raw`
@rust-bors

This comment has been minimized.

@rust-log-analyzer

This comment has been minimized.

@rust-bors

rust-bors Bot commented Jun 22, 2026

Copy link
Copy Markdown
Contributor

☀️ Try build successful (CI)
Build commit: 3f4f44d (3f4f44d99c410d3aadeb2731ddd6c5446c89eb72)
Base parent: 9030e34 (9030e345fe92df1ccefd0a8cdf61a9a9a5b73cb0)

@rust-timer

This comment has been minimized.

@rust-timer

Copy link
Copy Markdown
Collaborator

Finished benchmarking commit (3f4f44d): comparison URL.

Overall result: ❌✅ regressions and improvements - 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
Regressions ❌
(secondary)
1.1% [0.1%, 3.7%] 18
Improvements ✅
(primary)
- - 0
Improvements ✅
(secondary)
-2.9% [-4.9%, -0.0%] 5
All ❌✅ (primary) - - 0

Max RSS (memory usage)

Results (primary 0.6%, secondary 1.6%)

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

mean range count
Regressions ❌
(primary)
2.7% [2.7%, 2.7%] 1
Regressions ❌
(secondary)
2.2% [1.7%, 2.7%] 9
Improvements ✅
(primary)
-1.4% [-1.4%, -1.4%] 1
Improvements ✅
(secondary)
-1.2% [-1.2%, -1.1%] 2
All ❌✅ (primary) 0.6% [-1.4%, 2.7%] 2

Cycles

Results (secondary 3.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)
4.1% [2.1%, 6.2%] 6
Improvements ✅
(primary)
- - 0
Improvements ✅
(secondary)
-2.3% [-2.3%, -2.3%] 1
All ❌✅ (primary) - - 0

Binary size

Results (primary 0.0%, 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.0% [0.0%, 0.0%] 4
Regressions ❌
(secondary)
0.1% [0.0%, 0.1%] 20
Improvements ✅
(primary)
- - 0
Improvements ✅
(secondary)
- - 0
All ❌✅ (primary) 0.0% [0.0%, 0.0%] 4

Bootstrap: 503.321s -> 505.38s (0.41%)
Artifact size: 353.40 MiB -> 353.04 MiB (-0.10%)

@rustbot rustbot added perf-regression Performance regression. and removed S-waiting-on-perf Status: Waiting on a perf run to be completed. labels Jun 22, 2026
Comment thread compiler/rustc_infer/src/infer/context.rs Outdated
@jdonszelmann jdonszelmann force-pushed the move-checks branch 2 times, most recently from c340366 to 987b1a0 Compare June 25, 2026 13:16
@jdonszelmann

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 Jun 25, 2026
@rust-bors

This comment has been minimized.

rust-bors Bot pushed a commit that referenced this pull request Jun 25, 2026
Move fast path checks to `evaluate_goal_raw`
@rustbot rustbot added A-tidy Area: The tidy tool T-bootstrap Relevant to the bootstrap subteam: Rust's build system (x.py and src/bootstrap) labels Jun 25, 2026
@rust-bors

rust-bors Bot commented Jun 25, 2026

Copy link
Copy Markdown
Contributor

☀️ Try build successful (CI)
Build commit: b2fad67 (b2fad672d15ed85bb352e25461a99b01bf10a0de)
Base parent: 973ad0d (973ad0d0ab149bde2e96422833c1265c7a5be217)

@rust-timer

This comment has been minimized.

@rust-bors

This comment has been minimized.

@rust-timer

Copy link
Copy Markdown
Collaborator

Finished benchmarking commit (b2fad67): comparison URL.

Overall result: ❌✅ regressions and improvements - 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
Regressions ❌
(secondary)
0.6% [0.2%, 1.2%] 12
Improvements ✅
(primary)
- - 0
Improvements ✅
(secondary)
-6.9% [-11.7%, -2.0%] 6
All ❌✅ (primary) - - 0

Max RSS (memory usage)

Results (primary 4.0%, secondary 3.3%)

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

mean range count
Regressions ❌
(primary)
4.0% [3.4%, 4.7%] 2
Regressions ❌
(secondary)
4.8% [0.9%, 22.7%] 7
Improvements ✅
(primary)
- - 0
Improvements ✅
(secondary)
-1.6% [-2.4%, -0.9%] 2
All ❌✅ (primary) 4.0% [3.4%, 4.7%] 2

Cycles

Results (secondary -6.6%)

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)
-6.6% [-8.2%, -2.1%] 4
All ❌✅ (primary) - - 0

Binary size

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

Bootstrap: 509.16s -> 507.92s (-0.24%)
Artifact size: 353.81 MiB -> 353.75 MiB (-0.02%)

@rustbot rustbot removed the S-waiting-on-perf Status: Waiting on a perf run to be completed. label Jun 25, 2026
@jdonszelmann jdonszelmann changed the title Move fast path checks to evaluate_goal_raw Move fast paths around to gain a bit of new-solver perf Jun 26, 2026
@jdonszelmann jdonszelmann marked this pull request as ready for review June 26, 2026 09:16
@rustbot

rustbot commented Jun 26, 2026

Copy link
Copy Markdown
Collaborator

Some changes occurred to the core trait solver

cc @rust-lang/initiative-trait-system-refactor

@rustbot rustbot added the S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. label Jun 26, 2026
@rustbot rustbot removed the S-waiting-on-author Status: This is awaiting some action (such as code changes or more information) from the author. label Jun 26, 2026
@rustbot

rustbot commented Jun 26, 2026

Copy link
Copy Markdown
Collaborator

r? @dingxiangfei2009

rustbot has assigned @dingxiangfei2009.
They will have a look at your PR within the next two weeks and either review your PR or reassign to another reviewer.

Use r? to explicitly pick a reviewer

Why was this reviewer chosen?

The reviewer was selected based on:

  • Owners of files modified in this PR: compiler
  • compiler expanded to 73 candidates
  • Random selection from 18 candidates

@jdonszelmann

Copy link
Copy Markdown
Contributor Author

r? @lcnr

@rustbot rustbot assigned lcnr and unassigned dingxiangfei2009 Jun 26, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

A-tidy Area: The tidy tool perf-regression Performance regression. S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. T-bootstrap Relevant to the bootstrap subteam: Rust's build system (x.py and src/bootstrap) T-compiler Relevant to the compiler team, which will review and decide on the PR/issue. WG-trait-system-refactor The Rustc Trait System Refactor Initiative (-Znext-solver)

Projects

None yet

Development

Successfully merging this pull request may close these issues.

6 participants