Skip to content

[perf] Reuse CanonicalVarKinds if no new variables were added - #164304

Merged
rust-bors[bot] merged 1 commit into
rust-lang:mainfrom
Randl:perf-reuse
Nov 4, 2026
Merged

rust-bors[bot] merged 1 commit into
rust-lang:mainfrom
Randl:perf-reuse

Conversation

@Randl

@Randl Randl commented Oct 14, 2026 •

Copy link
Copy Markdown
Contributor

View all comments

Have seen a perf improvement locally.
The idea is to reuse the output of mk_canonical_var_kinds if self.state.var_kinds is unchanged

@rustbot rustbot added S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. 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 Oct 14, 2026
@rustbot

rustbot commented Oct 14, 2026

Copy link
Copy Markdown
Collaborator

r? @mati865

rustbot has assigned @mati865.
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 77 candidates
  • Random selection from 18 candidates

@mati865

mati865 commented Oct 14, 2026

Copy link
Copy Markdown
Member

@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 Oct 14, 2026
rust-bors Bot pushed a commit that referenced this pull request Oct 14, 2026
[perf] Reuse CanonicalVarKinds if no new variables were added
@rust-bors

This comment has been minimized.

@rust-bors

rust-bors Bot commented Oct 14, 2026

Copy link
Copy Markdown
Contributor

☀️ Try build successful (CI)
Build commit: e2f1d32 (e2f1d325b097337a5b5f4eec8db11898130cf82f)
Base parent: 2d37576 (2d37576c3d7134aa2d5c2f2396712a8b4a38ef6f)

@rust-timer

This comment has been minimized.

@rust-timer

Copy link
Copy Markdown
Collaborator

Finished benchmarking commit (e2f1d32): comparison URL.

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

Benchmarking means the PR may be perf-sensitive. Consider adding rollup=never if this change is not fit for rolling up.

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=iffy 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.2% [0.2%, 0.3%] 2
Regressions ❌
(secondary)
0.1% [0.1%, 0.1%] 1
Improvements ✅
(primary)
- - 0
Improvements ✅
(secondary)
-0.8% [-1.6%, -0.3%] 9
All ❌✅ (primary) 0.2% [0.2%, 0.3%] 2

Max RSS (memory usage)

Results (secondary -1.3%)

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

Cycles

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

Binary size

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

Bootstrap: 487.613s -> 494.35s (1.38%)
Artifact size: 406.81 MiB -> 406.85 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 Oct 14, 2026
@Randl

Randl commented Oct 15, 2026

Copy link
Copy Markdown
Contributor Author

Are regressions noise? I believe it should have only influence the new solver

@mati865

mati865 commented Oct 15, 2026

Copy link
Copy Markdown
Member

Yes, those are noise.
I'm too unfamiliar with the code to tell whether this caching won't cause bugs, r? project-trait-system-refactor

@rustbot rustbot assigned ShoyuVanilla and unassigned mati865 Oct 15, 2026

@ShoyuVanilla ShoyuVanilla left a comment •

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

IIUC, the idea behind this PR is that we reuse the param_env's var_kind if the rest of the canonicalized value doesn't have any other var.

That sounds plausible, as we may try to intern things less, but perhaps not in some pathological cases that we have to intern things twice for the param_env's var_kinds and that of the value. So I'm not entirely sure whether is this desirable but the perf looks good anyway 🤔

I'd like to try out an extra perf run after some changes:

View changes since this review

Comment thread compiler/rustc_type_ir/src/canonical.rs Resolved
@rustbot rustbot added S-waiting-on-author Status: This is awaiting some action (such as code changes or more information) from the author. and removed S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. labels Oct 15, 2026
@rustbot

rustbot commented Oct 15, 2026

Copy link
Copy Markdown
Collaborator

Reminder, once the PR becomes ready for a review, use @rustbot ready.

@ShoyuVanilla

Copy link
Copy Markdown
Member

@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 Oct 18, 2026
@rust-bors

This comment has been minimized.

rust-bors Bot pushed a commit that referenced this pull request Oct 18, 2026
[perf] Reuse CanonicalVarKinds if no new variables were added
@rust-bors

rust-bors Bot commented Oct 18, 2026

Copy link
Copy Markdown
Contributor

☀️ Try build successful (CI)
Build commit: f6e6dd9 (f6e6dd9401b66428a346b0a4fc02d47ae3796a26)
Base parent: 02fb0a1 (02fb0a16311c3411fa373627706da085cd8fbd3c)

@rust-timer

This comment has been minimized.

@rust-bors rust-bors Bot removed the S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. label Nov 3, 2026
JonathanBrouwer added a commit to JonathanBrouwer/rust that referenced this pull request Nov 3, 2026
[perf] Reuse CanonicalVarKinds if no new variables were added

Have seen a perf improvement locally.
The idea is to reuse the output of `mk_canonical_var_kinds` if `self.state.var_kinds` is unchanged
JonathanBrouwer added a commit to JonathanBrouwer/rust that referenced this pull request Nov 3, 2026
[perf] Reuse CanonicalVarKinds if no new variables were added

Have seen a perf improvement locally.
The idea is to reuse the output of `mk_canonical_var_kinds` if `self.state.var_kinds` is unchanged
rust-bors Bot pushed a commit that referenced this pull request Nov 3, 2026
…uwer

Rollup of 15 pull requests

Successful merges:

 - #165378 (rustfmt subtree update (v1.12.0))
 - #149245 (Make inline attributes apply to the generated `poll` in async fn)
 - #164304 ([perf] Reuse CanonicalVarKinds if no new variables were added)
 - #165109 (Avoid building a region map when erasing bound regions)
 - #163393 (std: Use getexecpath() for current_exe() on OpenBSD)
 - #164896 (offload: pass the linked device image to the host pass)
 - #165358 (Reenable some cg_gcc tests that were disabled)
 - #165371 (Don't use `llvm_type` as the type of `static`s.)
 - #162232 (Replace `builtin #` with `k#`)
 - #162608 (Avoid oscillating line wrapping due to symbol indices)
 - #165029 (Use `MalformedLintAttributeInput` in more places)
 - #165203 (AIX: Implement TLS destructor guard in std and update dynamic-loading-cdylib test)
 - #165230 (Fix rigidity assertion ICE)
 - #165354 (Remove `AbiAlign`)
 - #165374 (Refactorings in preparation for the move trait)
JonathanBrouwer added a commit to JonathanBrouwer/rust that referenced this pull request Nov 3, 2026
[perf] Reuse CanonicalVarKinds if no new variables were added

Have seen a perf improvement locally.
The idea is to reuse the output of `mk_canonical_var_kinds` if `self.state.var_kinds` is unchanged
rust-bors Bot pushed a commit that referenced this pull request Nov 3, 2026
…uwer

Rollup of 14 pull requests

Successful merges:

 - #165378 (rustfmt subtree update (v1.12.0))
 - #149245 (Make inline attributes apply to the generated `poll` in async fn)
 - #164304 ([perf] Reuse CanonicalVarKinds if no new variables were added)
 - #165109 (Avoid building a region map when erasing bound regions)
 - #163393 (std: Use getexecpath() for current_exe() on OpenBSD)
 - #164896 (offload: pass the linked device image to the host pass)
 - #165358 (Reenable some cg_gcc tests that were disabled)
 - #165371 (Don't use `llvm_type` as the type of `static`s.)
 - #162232 (Replace `builtin #` with `k#`)
 - #162608 (Avoid oscillating line wrapping due to symbol indices)
 - #165029 (Use `MalformedLintAttributeInput` in more places)
 - #165203 (AIX: Implement TLS destructor guard in std and update dynamic-loading-cdylib test)
 - #165230 (Fix rigidity assertion ICE)
 - #165374 (Refactorings in preparation for the move trait)
JonathanBrouwer added a commit to JonathanBrouwer/rust that referenced this pull request Nov 3, 2026
[perf] Reuse CanonicalVarKinds if no new variables were added

Have seen a perf improvement locally.
The idea is to reuse the output of `mk_canonical_var_kinds` if `self.state.var_kinds` is unchanged
rust-bors Bot pushed a commit that referenced this pull request Nov 3, 2026
…uwer

Rollup of 14 pull requests

Successful merges:

 - #149245 (Make inline attributes apply to the generated `poll` in async fn)
 - #164304 ([perf] Reuse CanonicalVarKinds if no new variables were added)
 - #165109 (Avoid building a region map when erasing bound regions)
 - #163393 (std: Use getexecpath() for current_exe() on OpenBSD)
 - #164896 (offload: pass the linked device image to the host pass)
 - #165358 (Reenable some cg_gcc tests that were disabled)
 - #165371 (Don't use `llvm_type` as the type of `static`s.)
 - #162232 (Replace `builtin #` with `k#`)
 - #162608 (Avoid oscillating line wrapping due to symbol indices)
 - #164241 (make the safety documentation consistent in Ptr module)
 - #165029 (Use `MalformedLintAttributeInput` in more places)
 - #165203 (AIX: Implement TLS destructor guard in std and update dynamic-loading-cdylib test)
 - #165230 (Fix rigidity assertion ICE)
 - #165374 (Refactorings in preparation for the move trait)
JonathanBrouwer added a commit to JonathanBrouwer/rust that referenced this pull request Nov 3, 2026
[perf] Reuse CanonicalVarKinds if no new variables were added

Have seen a perf improvement locally.
The idea is to reuse the output of `mk_canonical_var_kinds` if `self.state.var_kinds` is unchanged
rust-bors Bot pushed a commit that referenced this pull request Nov 3, 2026
…uwer

Rollup of 13 pull requests

Successful merges:

 - #149245 (Make inline attributes apply to the generated `poll` in async fn)
 - #164304 ([perf] Reuse CanonicalVarKinds if no new variables were added)
 - #165109 (Avoid building a region map when erasing bound regions)
 - #163393 (std: Use getexecpath() for current_exe() on OpenBSD)
 - #165358 (Reenable some cg_gcc tests that were disabled)
 - #165371 (Don't use `llvm_type` as the type of `static`s.)
 - #162232 (Replace `builtin #` with `k#`)
 - #162608 (Avoid oscillating line wrapping due to symbol indices)
 - #164241 (make the safety documentation consistent in Ptr module)
 - #165029 (Use `MalformedLintAttributeInput` in more places)
 - #165203 (AIX: Implement TLS destructor guard in std and update dynamic-loading-cdylib test)
 - #165230 (Fix rigidity assertion ICE)
 - #165374 (Refactorings in preparation for the move trait)
JonathanBrouwer added a commit to JonathanBrouwer/rust that referenced this pull request Nov 3, 2026
[perf] Reuse CanonicalVarKinds if no new variables were added

Have seen a perf improvement locally.
The idea is to reuse the output of `mk_canonical_var_kinds` if `self.state.var_kinds` is unchanged
rust-bors Bot pushed a commit that referenced this pull request Nov 3, 2026
…uwer

Rollup of 20 pull requests

Successful merges:

 - #149245 (Make inline attributes apply to the generated `poll` in async fn)
 - #163495 (Parallelize AST -> HIR lowering)
 - #164304 ([perf] Reuse CanonicalVarKinds if no new variables were added)
 - #165109 (Avoid building a region map when erasing bound regions)
 - #163393 (std: Use getexecpath() for current_exe() on OpenBSD)
 - #163625 (Add a lint helper attribute namespace )
 - #164414 (Add `let_underscore_drop_guard` lint.)
 - #165342 (Avoid unnecessary MIR traversals in CheckPackedRef lint)
 - #165351 (delegation: insert probing adjustments before args check adjustments)
 - #165358 (Reenable some cg_gcc tests that were disabled)
 - #165377 (Make `no_implicit_prelude` not suppress tool attributes)
 - #165397 (Add codegen test for unused match arms removed after inlining)
 - #165398 (Rework parallel reproducibility tests)
 - #162608 (Avoid oscillating line wrapping due to symbol indices)
 - #164241 (make the safety documentation consistent in Ptr module)
 - #165029 (Use `MalformedLintAttributeInput` in more places)
 - #165203 (AIX: Implement TLS destructor guard in std and update dynamic-loading-cdylib test)
 - #165230 (Fix rigidity assertion ICE)
 - #165293 (unstable-book: update default-visibility.md to link to tracking issue)
 - #165374 (Refactorings in preparation for the move trait)
JonathanBrouwer added a commit to JonathanBrouwer/rust that referenced this pull request Nov 3, 2026
[perf] Reuse CanonicalVarKinds if no new variables were added

Have seen a perf improvement locally.
The idea is to reuse the output of `mk_canonical_var_kinds` if `self.state.var_kinds` is unchanged
rust-bors Bot pushed a commit that referenced this pull request Nov 3, 2026
…uwer

Rollup of 21 pull requests

Successful merges:

 - #165416 (fix unsoundness when compiling `[diverging_const; 0]`)
 - #149245 (Make inline attributes apply to the generated `poll` in async fn)
 - #163495 (Parallelize AST -> HIR lowering)
 - #164304 ([perf] Reuse CanonicalVarKinds if no new variables were added)
 - #165109 (Avoid building a region map when erasing bound regions)
 - #163393 (std: Use getexecpath() for current_exe() on OpenBSD)
 - #163625 (Add a lint helper attribute namespace )
 - #164414 (Add `let_underscore_drop_guard` lint.)
 - #165342 (Avoid unnecessary MIR traversals in CheckPackedRef lint)
 - #165351 (delegation: insert probing adjustments before args check adjustments)
 - #165358 (Reenable some cg_gcc tests that were disabled)
 - #165377 (Make `no_implicit_prelude` not suppress tool attributes)
 - #165397 (Add codegen test for unused match arms removed after inlining)
 - #165398 (Rework parallel reproducibility tests)
 - #162608 (Avoid oscillating line wrapping due to symbol indices)
 - #164241 (make the safety documentation consistent in Ptr module)
 - #165029 (Use `MalformedLintAttributeInput` in more places)
 - #165203 (AIX: Implement TLS destructor guard in std and update dynamic-loading-cdylib test)
 - #165230 (Fix rigidity assertion ICE)
 - #165293 (unstable-book: update default-visibility.md to link to tracking issue)
 - #165374 (Refactorings in preparation for the move trait)
JonathanBrouwer added a commit to JonathanBrouwer/rust that referenced this pull request Nov 3, 2026
[perf] Reuse CanonicalVarKinds if no new variables were added

Have seen a perf improvement locally.
The idea is to reuse the output of `mk_canonical_var_kinds` if `self.state.var_kinds` is unchanged
rust-bors Bot pushed a commit that referenced this pull request Nov 3, 2026
…uwer

Rollup of 20 pull requests

Successful merges:

 - #149245 (Make inline attributes apply to the generated `poll` in async fn)
 - #163495 (Parallelize AST -> HIR lowering)
 - #164304 ([perf] Reuse CanonicalVarKinds if no new variables were added)
 - #165109 (Avoid building a region map when erasing bound regions)
 - #163393 (std: Use getexecpath() for current_exe() on OpenBSD)
 - #163625 (Add a lint helper attribute namespace )
 - #164414 (Add `let_underscore_drop_guard` lint.)
 - #165342 (Avoid unnecessary MIR traversals in CheckPackedRef lint)
 - #165351 (delegation: insert probing adjustments before args check adjustments)
 - #165358 (Reenable some cg_gcc tests that were disabled)
 - #165377 (Make `no_implicit_prelude` not suppress tool attributes)
 - #165397 (Add codegen test for unused match arms removed after inlining)
 - #165398 (Rework parallel reproducibility tests)
 - #162608 (Avoid oscillating line wrapping due to symbol indices)
 - #164241 (make the safety documentation consistent in Ptr module)
 - #165029 (Use `MalformedLintAttributeInput` in more places)
 - #165203 (AIX: Implement TLS destructor guard in std and update dynamic-loading-cdylib test)
 - #165230 (Fix rigidity assertion ICE)
 - #165293 (unstable-book: update default-visibility.md to link to tracking issue)
 - #165374 (Refactorings in preparation for the move trait)
rust-bors Bot pushed a commit that referenced this pull request Nov 3, 2026
…uwer

Rollup of 22 pull requests

Successful merges:

 - #149245 (Make inline attributes apply to the generated `poll` in async fn)
 - #164304 ([perf] Reuse CanonicalVarKinds if no new variables were added)
 - #165109 (Avoid building a region map when erasing bound regions)
 - #163393 (std: Use getexecpath() for current_exe() on OpenBSD)
 - #163625 (Add a lint helper attribute namespace )
 - #164414 (Add `let_underscore_drop_guard` lint.)
 - #165342 (Avoid unnecessary MIR traversals in CheckPackedRef lint)
 - #165351 (delegation: insert probing adjustments before args check adjustments)
 - #165358 (Reenable some cg_gcc tests that were disabled)
 - #165377 (Make `no_implicit_prelude` not suppress tool attributes)
 - #165397 (Add codegen test for unused match arms removed after inlining)
 - #165398 (Rework parallel reproducibility tests)
 - #162232 (Replace `builtin #` with `k#`)
 - #162608 (Avoid oscillating line wrapping due to symbol indices)
 - #164241 (make the safety documentation consistent in Ptr module)
 - #164258 (clarify when `Vec::into_boxed_slice()` is in-place)
 - #165029 (Use `MalformedLintAttributeInput` in more places)
 - #165203 (AIX: Implement TLS destructor guard in std and update dynamic-loading-cdylib test)
 - #165230 (Fix rigidity assertion ICE)
 - #165293 (unstable-book: update default-visibility.md to link to tracking issue)
 - #165374 (Refactorings in preparation for the move trait)
 - #165421 (another Enzyme submodule update for nested autodiff)
@rust-bors
rust-bors Bot merged commit 5082d3e into rust-lang:main Nov 4, 2026
15 checks passed
@rustbot rustbot added this to the 1.101.0 milestone Nov 4, 2026
rust-bors Bot pushed a commit that referenced this pull request Nov 4, 2026
Rollup merge of #164304 - Randl:perf-reuse, r=ShoyuVanilla

[perf] Reuse CanonicalVarKinds if no new variables were added

Have seen a perf improvement locally.
The idea is to reuse the output of `mk_canonical_var_kinds` if `self.state.var_kinds` is unchanged
@rust-timer

Copy link
Copy Markdown
Collaborator

Note

This PR was benchmarked as part of triage of its containing rollup: triage URL.

Finished benchmarking commit (666da1f): comparison URL.

Overall result: ✅ improvements - no action needed

@rustbot label: -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
Improvements ✅
(primary)
- - 0
Improvements ✅
(secondary)
-1.0% [-2.1%, -0.4%] 9
All ❌✅ (primary) - - 0

Max RSS (memory usage)

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

Cycles

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

Binary size

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

Artifact size: 406.38 MiB -> 406.36 MiB (-0.00%)

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

Labels

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

5 participants