Skip to content

Improve caching by introducing TypingMode::ErasedNotCoherence#155443

Open
jdonszelmann wants to merge 15 commits intorust-lang:mainfrom
jdonszelmann:canonical
Open

Improve caching by introducing TypingMode::ErasedNotCoherence#155443
jdonszelmann wants to merge 15 commits intorust-lang:mainfrom
jdonszelmann:canonical

Conversation

@jdonszelmann
Copy link
Copy Markdown
Contributor

@jdonszelmann jdonszelmann commented Apr 17, 2026

View all comments

r? @lcnr

This introduces TypingMode::ErasedNotCoherence. Most typing modes contain a list of opaque types, which are quite often unused during canonicalization. With this change, any time we try canonicalization, we replace whichever typing mode we're currently in with ErasedNotcoherence, attempt to canonicalize, and if that fails retry in the original typing mode. If erased mode succeeds, this is beneficial because that way the opaque types don't end up in the cache key, allowing more cache reuse.

This seems to have a small (0.5%) slowdown on most programs, but a dramatic (>60%) speedup in specific cases like the rustc-perf wg-grammar benchmark. Some more improvements are expected with "eager normalization", which is work that's under way right now.

@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 Apr 17, 2026
@jdonszelmann
Copy link
Copy Markdown
Contributor Author

@bors try

@rust-bors

This comment has been minimized.

@jdonszelmann
Copy link
Copy Markdown
Contributor Author

@bors try parent=14196dbfa3eb7c30195251eac092b1b86c8a2d84

@rust-bors

This comment has been minimized.

rust-bors Bot pushed a commit that referenced this pull request Apr 17, 2026
[DO NOT MERGE] Improve canonicalization performance
@jdonszelmann
Copy link
Copy Markdown
Contributor Author

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

rust-bors Bot commented Apr 17, 2026

☀️ Try build successful (CI)
Build commit: db1df07 (db1df07682e37be559858ab003b949a2c17b5b3b, parent: 14196dbfa3eb7c30195251eac092b1b86c8a2d84)

@rust-timer

This comment has been minimized.

@rust-timer
Copy link
Copy Markdown
Collaborator

Finished benchmarking commit (db1df07): 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.8% [0.2%, 1.8%] 11
Improvements ✅
(primary)
- - 0
Improvements ✅
(secondary)
-0.6% [-1.0%, -0.2%] 2
All ❌✅ (primary) - - 0

Max RSS (memory usage)

Results (primary -0.9%, secondary 1.7%)

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

mean range count
Regressions ❌
(primary)
1.1% [1.1%, 1.1%] 1
Regressions ❌
(secondary)
1.7% [1.0%, 2.6%] 7
Improvements ✅
(primary)
-2.8% [-2.8%, -2.8%] 1
Improvements ✅
(secondary)
- - 0
All ❌✅ (primary) -0.9% [-2.8%, 1.1%] 2

Cycles

Results (primary -2.4%, secondary 28.5%)

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

Binary size

This perf run didn't have relevant results for this metric.

Bootstrap: 491.114s -> 492.029s (0.19%)
Artifact size: 394.23 MiB -> 394.80 MiB (0.14%)

@rustbot rustbot added perf-regression Performance regression. and removed S-waiting-on-perf Status: Waiting on a perf run to be completed. labels Apr 17, 2026
@jdonszelmann jdonszelmann marked this pull request as ready for review April 28, 2026 08:12
@rustbot rustbot added the S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. label Apr 28, 2026
@rustbot
Copy link
Copy Markdown
Collaborator

rustbot commented Apr 28, 2026

changes to the core type system

cc @lcnr

Some changes occurred to MIR optimizations

cc @rust-lang/wg-mir-opt

Some changes occurred to the CTFE machinery

cc @RalfJung, @oli-obk, @lcnr

Some changes occurred to the core trait solver

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

Some changes occurred to the CTFE / Miri interpreter

cc @rust-lang/miri

@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 Apr 28, 2026
@rust-log-analyzer

This comment has been minimized.

@rust-log-analyzer

This comment has been minimized.

@rust-log-analyzer

This comment has been minimized.

@jdonszelmann jdonszelmann changed the title [DO NOT MERGE] Improve canonicalization performance Improve canonicalization performance by introducing TypingMode::ErasedNotCoherence Apr 28, 2026
@rust-log-analyzer

This comment has been minimized.

@rust-timer
Copy link
Copy Markdown
Collaborator

This pull request is already queued and waiting for a try build to finish.

@rust-bors
Copy link
Copy Markdown
Contributor

rust-bors Bot commented May 5, 2026

⌛ Trying commit cf2f7aa with merge 92f830b

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

Workflow: https://github.com/rust-lang/rust/actions/runs/25374278223

rust-bors Bot pushed a commit that referenced this pull request May 5, 2026
Improve caching by introducing `TypingMode::ErasedNotCoherence`
@jdonszelmann
Copy link
Copy Markdown
Contributor Author

jdonszelmann commented May 5, 2026

actually, there's no need, perf will run on the big CI @bors try cancel
was curious how this PR would do with the new benchmarks in the perf suite

@rust-bors
Copy link
Copy Markdown
Contributor

rust-bors Bot commented May 5, 2026

Try build cancelled. Cancelled workflows:

@rust-log-analyzer

This comment has been minimized.

@rust-bors

This comment has been minimized.

@rustbot
Copy link
Copy Markdown
Collaborator

rustbot commented May 6, 2026

This PR was rebased onto a different main commit. Here's a range-diff highlighting what actually changed.

Rebasing is a normal part of keeping PRs up to date, so no action is needed—this note is just to help reviewers.

@jdonszelmann
Copy link
Copy Markdown
Contributor Author

@bors p=1 rollup=never (has been quite bitrotty, also perf)

@jdonszelmann
Copy link
Copy Markdown
Contributor Author

@bors r=lcnr

@rust-bors
Copy link
Copy Markdown
Contributor

rust-bors Bot commented May 6, 2026

📌 Commit 36b6eeb has been approved by lcnr

It is now in the queue for this repository.

@rust-bors rust-bors Bot added S-waiting-on-bors Status: Waiting on bors to run and complete tests. Bors will change the label on completion. and removed S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. labels May 6, 2026
@JonathanBrouwer
Copy link
Copy Markdown
Contributor

@bors p=6
Scheduling this before the next rollup

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

perf-regression Performance regression. S-waiting-on-bors Status: Waiting on bors to run and complete tests. Bors will change the label on completion. S-waiting-on-perf Status: Waiting on a perf run to be completed. 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