Skip to content

[perf] Cache the canonical *instantiation* of param-envs #142316

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Draft
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

compiler-errors
Copy link
Member

r? lcnr

@rustbot rustbot added the T-compiler Relevant to the compiler team, which will review and decide on the PR/issue. label Jun 10, 2025
@compiler-errors
Copy link
Member Author

@bors2 try @rust-timer queue

@rust-timer

This comment has been minimized.

@rust-bors
Copy link

rust-bors bot commented Jun 10, 2025

⌛ Trying commit 10849bc with merge 41eb046

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

rust-bors bot added a commit that referenced this pull request Jun 10, 2025
[perf] Cache the canonical *instantiation* of param-envs

r? lcnr
@rustbot rustbot added the S-waiting-on-perf Status: Waiting on a perf run to be completed. label Jun 10, 2025
@rust-bors
Copy link

rust-bors bot commented Jun 11, 2025

☀️ Try build successful (CI)
Build commit: 41eb046 (41eb046262521d4f258e161c937b19a16cb53f37)

@rust-timer

This comment has been minimized.

@rust-timer
Copy link
Collaborator

Finished benchmarking commit (41eb046): comparison URL.

Overall result: ✅ improvements - no action needed

Benchmarking this pull request means it may be perf-sensitive – we'll automatically label it not fit for rolling up. You can override this, but we strongly advise not to, due to possible changes in compiler perf.

@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
Improvements ✅
(primary)
-0.5% [-0.9%, -0.1%] 18
Improvements ✅
(secondary)
-4.0% [-20.1%, -0.1%] 19
All ❌✅ (primary) -0.5% [-0.9%, -0.1%] 18

Max RSS (memory usage)

Results (primary -1.9%)

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

Cycles

Results (primary -1.0%, secondary -7.8%)

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)
-1.0% [-1.1%, -0.8%] 8
Improvements ✅
(secondary)
-7.8% [-14.1%, -1.1%] 6
All ❌✅ (primary) -1.0% [-1.1%, -0.8%] 8

Binary size

This benchmark run did not return any relevant results for this metric.

Bootstrap: 755.415s -> 752.897s (-0.33%)
Artifact size: 372.14 MiB -> 372.01 MiB (-0.04%)

@rustbot rustbot removed the S-waiting-on-perf Status: Waiting on a perf run to be completed. label Jun 11, 2025
@compiler-errors
Copy link
Member Author

Let's try this again w/o the "highest var in clauses" optimization.

@compiler-errors
Copy link
Member Author

Let's try this but with highest_var_in_clauses not cached.

@bors2 try @rust-timer queue

@rust-timer

This comment has been minimized.

@rust-bors
Copy link

rust-bors bot commented Jun 11, 2025

⌛ Trying commit a74d247 with merge 98d94a4

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

rust-bors bot added a commit that referenced this pull request Jun 11, 2025
[perf] Cache the canonical *instantiation* of param-envs

r? lcnr
@rustbot rustbot added the S-waiting-on-perf Status: Waiting on a perf run to be completed. label Jun 11, 2025
@rust-bors
Copy link

rust-bors bot commented Jun 12, 2025

☀️ Try build successful (CI)
Build commit: 98d94a4 (98d94a4710e69795b88dc65dc9526c47d10f54d6, parent: e703dff8fe220b78195c53478e83fb2f68d8499c)

@rust-timer

This comment has been minimized.

@rust-timer
Copy link
Collaborator

Finished benchmarking commit (98d94a4): comparison URL.

Overall result: ❌✅ regressions and improvements - please read the text below

Benchmarking this pull request means it may be perf-sensitive – we'll automatically label it not fit for rolling up. You can override this, but we strongly advise not to, due to possible changes in compiler perf.

Next Steps: If you can justify the regressions found in this try perf run, please do so in sufficient writing along with @rustbot label: +perf-regression-triaged. If not, please fix the regressions and do another perf run. If its results are neutral or positive, the label will be automatically removed.

@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.5% [0.5%, 0.6%] 6
Regressions ❌
(secondary)
0.3% [0.3%, 0.3%] 1
Improvements ✅
(primary)
-0.3% [-0.6%, -0.1%] 13
Improvements ✅
(secondary)
-2.6% [-15.9%, -0.1%] 24
All ❌✅ (primary) -0.0% [-0.6%, 0.6%] 19

Max RSS (memory usage)

Results (primary -3.5%)

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

Cycles

Results (secondary -7.1%)

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)
-7.1% [-12.2%, -2.1%] 6
All ❌✅ (primary) - - 0

Binary size

This benchmark run did not return any relevant results for this metric.

Bootstrap: 754.802s -> 754.047s (-0.10%)
Artifact size: 372.09 MiB -> 372.03 MiB (-0.02%)

@rustbot rustbot added perf-regression Performance regression. and removed S-waiting-on-perf Status: Waiting on a perf run to be completed. labels Jun 12, 2025
fn fold_clauses(&mut self, c: ty::Clauses<'tcx>) -> ty::Clauses<'tcx> {
if c.has_vars_bound_at_or_above(self.current_index) {
if self.current_index == ty::INNERMOST {
let index = highest_var_in_clauses(c);
Copy link
Contributor

@lcnr lcnr Jun 12, 2025

Choose a reason for hiding this comment

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

instead have a separate Clauses -> usize hashmap in the tcx?

as in

   pub instantiate_clauses_cache: Lock<(
       FxHashMap<ty::Clauses<'tcx>, usize>,
       FxHashMap<(ty::Clauses<'tcx>, &'tcx [ty::GenericArg<'tcx>]), ty::Clauses<'tcx>>)
   >,

Copy link
Member Author

Choose a reason for hiding this comment

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

that was the previous perf run

Copy link
Contributor

Choose a reason for hiding this comment

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

ah 😅 👍 u just too smart

Copy link
Member Author

Choose a reason for hiding this comment

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

specifically i was double checking that the caching of the max var in the clauses was worth it, and it seems like it is

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
perf-regression Performance regression. T-compiler Relevant to the compiler team, which will review and decide on the PR/issue.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants