Skip to content

Improve caching by introducing TypingMode::ErasedNotCoherence#155443

Merged
rust-bors[bot] merged 15 commits intorust-lang:mainfrom
jdonszelmann:canonical
May 6, 2026
Merged

Improve caching by introducing TypingMode::ErasedNotCoherence#155443
rust-bors[bot] merged 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.

@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

@rust-bors

This comment has been minimized.

@rust-bors rust-bors Bot added merged-by-bors This PR was explicitly merged by bors. and removed S-waiting-on-bors Status: Waiting on bors to run and complete tests. Bors will change the label on completion. labels May 6, 2026
@rust-bors
Copy link
Copy Markdown
Contributor

rust-bors Bot commented May 6, 2026

☀️ Test successful - CI
Approved by: lcnr
Duration: 3h 19m 23s
Pushing 365c0e1 to main...

@rust-bors rust-bors Bot merged commit 365c0e1 into rust-lang:main May 6, 2026
12 checks passed
@rustbot rustbot added this to the 1.97.0 milestone May 6, 2026
@github-actions
Copy link
Copy Markdown
Contributor

github-actions Bot commented May 6, 2026

What is this? This is an experimental post-merge analysis report that shows differences in test outcomes between the merged PR and its parent PR.

Comparing ba1a955 (parent) -> 365c0e1 (this PR)

Test differences

Show 72 test diffs

Stage 1

  • [ui] tests/ui/traits/next-solver/canonical/erased-opaques.rs: [missing] -> pass (J0)

Stage 2

  • [ui] tests/ui/traits/next-solver/canonical/erased-opaques.rs: [missing] -> pass (J1)

Additionally, 70 doctest diffs were found. These are ignored, as they are noisy.

Job group index

Test dashboard

Run

cargo run --manifest-path src/ci/citool/Cargo.toml -- \
    test-dashboard 365c0e1d7a614ca94cb48431dcd2bc6d3b645db1 --output-dir test-dashboard

And then open test-dashboard/index.html in your browser to see an overview of all executed tests.

Job duration changes

  1. dist-x86_64-llvm-mingw: 1h 30m -> 2h (+33.3%)
  2. x86_64-gnu-distcheck: 1h 45m -> 2h 18m (+31.3%)
  3. dist-i686-msvc: 1h 48m -> 2h 19m (+28.2%)
  4. pr-check-1: 27m 43s -> 34m 27s (+24.3%)
  5. dist-loongarch64-linux: 1h 28m -> 1h 49m (+23.2%)
  6. dist-powerpc64le-linux-musl: 1h 42m -> 1h 18m (-22.8%)
  7. dist-ohos-x86_64: 1h 3m -> 1h 17m (+21.9%)
  8. x86_64-gnu-llvm-22-2: 1h 25m -> 1h 43m (+20.4%)
  9. x86_64-gnu-llvm-22-1: 1h 5m -> 1h 18m (+20.4%)
  10. x86_64-gnu-llvm-21-1: 1h 6m -> 1h 19m (+20.3%)
How to interpret the job duration changes?

Job durations can vary a lot, based on the actual runner instance
that executed the job, system noise, invalidated caches, etc. The table above is provided
mostly for t-infra members, for simpler debugging of potential CI slow-downs.

@rust-timer
Copy link
Copy Markdown
Collaborator

Finished benchmarking commit (365c0e1): comparison URL.

Overall result: ❌✅ regressions and improvements - please read:

Our benchmarks found a performance regression caused by this PR.
This might be an actual regression, but it can also be just noise.

Next Steps:

  • If the regression was expected or you think it can be justified,
    please write a comment with sufficient written justification, and add
    @rustbot label: +perf-regression-triaged to it, to mark the regression as triaged.
  • If you think that you know of a way to resolve the regression, try to create
    a new PR with a fix for the regression.
  • If you do not understand the regression or you think that it is just noise,
    you can ask the @rust-lang/wg-compiler-performance working group for help (members of this group
    were already notified of this PR).

@rustbot label: +perf-regression
cc @rust-lang/wg-compiler-performance

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)
2.5% [0.0%, 16.6%] 18
Improvements ✅
(primary)
- - 0
Improvements ✅
(secondary)
-9.0% [-26.2%, -0.1%] 11
All ❌✅ (primary) - - 0

Max RSS (memory usage)

Results (primary 0.8%, secondary 2.5%)

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

mean range count
Regressions ❌
(primary)
1.6% [0.8%, 2.0%] 3
Regressions ❌
(secondary)
4.3% [1.1%, 9.9%] 14
Improvements ✅
(primary)
-1.7% [-1.7%, -1.7%] 1
Improvements ✅
(secondary)
-3.8% [-8.0%, -2.1%] 4
All ❌✅ (primary) 0.8% [-1.7%, 2.0%] 4

Cycles

Results (primary 2.0%, secondary -2.9%)

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

mean range count
Regressions ❌
(primary)
2.0% [2.0%, 2.0%] 1
Regressions ❌
(secondary)
4.5% [1.8%, 9.8%] 10
Improvements ✅
(primary)
- - 0
Improvements ✅
(secondary)
-12.1% [-28.7%, -1.1%] 8
All ❌✅ (primary) 2.0% [2.0%, 2.0%] 1

Binary size

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

Bootstrap: 496.315s -> 501.88s (1.12%)
Artifact size: 396.48 MiB -> 395.21 MiB (-0.32%)

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

Labels

merged-by-bors This PR was explicitly merged by bors. perf-regression Performance regression. 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