Skip to content

Preintern some TyKind::Bound values #144434

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

Open
wants to merge 2 commits into
base: master
Choose a base branch
from

Conversation

nnethercote
Copy link
Contributor

@nnethercote nnethercote commented Jul 25, 2025

The new trait solver produces a lot of these.

r? @compiler-errors

- Cover `DebruijnIndex(2)`, for slightly better coverage.
- Rename some things, to account for other region things that were
  renamed.
We already do the same thing for bound regions. This is a small perf win
for the new trait solver.
@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. labels Jul 25, 2025
@nnethercote
Copy link
Contributor Author

@bors try @rust-timer queue

@rust-timer

This comment has been minimized.

@rust-bors
Copy link

rust-bors bot commented Jul 25, 2025

⌛ Trying commit 837b610 with merge 06fbedc

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

rust-bors bot added a commit that referenced this pull request Jul 25, 2025
@rust-bors
Copy link

rust-bors bot commented Jul 25, 2025

☀️ Try build successful (CI)
Build commit: 06fbedc (06fbedc70773f4b817a3a111c862cd846e4706c5, parent: b56aaec52bc0fa35591a872fb4aac81f606e265c)

@rust-timer

This comment has been minimized.

@rust-timer
Copy link
Collaborator

Finished benchmarking commit (06fbedc): 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.2% [0.2%, 0.2%] 1
Regressions ❌
(secondary)
0.2% [0.2%, 0.2%] 1
Improvements ✅
(primary)
-0.3% [-0.5%, -0.1%] 17
Improvements ✅
(secondary)
-0.7% [-1.7%, -0.1%] 25
All ❌✅ (primary) -0.3% [-0.5%, 0.2%] 18

Max RSS (memory usage)

Results (primary 0.4%, secondary -2.6%)

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

mean range count
Regressions ❌
(primary)
3.1% [3.1%, 3.1%] 1
Regressions ❌
(secondary)
3.3% [3.3%, 3.3%] 1
Improvements ✅
(primary)
-2.4% [-2.4%, -2.4%] 1
Improvements ✅
(secondary)
-3.6% [-6.7%, -1.2%] 6
All ❌✅ (primary) 0.4% [-2.4%, 3.1%] 2

Cycles

Results (secondary 2.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)
2.2% [0.8%, 3.5%] 2
Improvements ✅
(primary)
- - 0
Improvements ✅
(secondary)
- - 0
All ❌✅ (primary) - - 0

Binary size

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

Bootstrap: 469.891s -> 470.107s (0.05%)
Artifact size: 374.63 MiB -> 374.66 MiB (0.01%)

@lqd
Copy link
Member

lqd commented Jul 25, 2025

(note about results: I saw in other PRs that a handful of benchmarks are currently bimodal)

@nnethercote
Copy link
Contributor Author

nnethercote commented Jul 25, 2025

The new-solver benchmark wins are all real, they are the target of the change and I saw them locally:

image

The new trait solver produces a lot more Bound types. They are mostly produced by the call to Ty::new_anon_bound at the bottom of Canonicalizer::cached_fold_ty. Could there be a deeper optimization that would avoid the need to create these types at all, rather than making them cheaper to create? That would be nice...

@rustbot
Copy link
Collaborator

rustbot commented Jul 25, 2025

compiler-errors is not on the review rotation at the moment.
They may take a while to respond.

@nnethercote
Copy link
Contributor Author

r? @lcnr

@rustbot rustbot assigned lcnr and unassigned compiler-errors Jul 25, 2025
Copy link
Member

@compiler-errors compiler-errors left a comment

Choose a reason for hiding this comment

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

Is this still a draft? I think that this is fine for now.

@compiler-errors
Copy link
Member

Could there be a deeper optimization that would avoid the need to create these types at all, rather than making them cheaper to create? That would be nice...

This seems pretty difficult and probably not worth blocking this on that.

@nnethercote nnethercote marked this pull request as ready for review July 25, 2025 23:14
@rustbot rustbot added S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. and removed S-waiting-on-author Status: This is awaiting some action (such as code changes or more information) from the author. labels Jul 25, 2025
@nnethercote
Copy link
Contributor Author

Correct, this no longer needs to be a draft.

This seems pretty difficult and probably not worth blocking this on that.

Ok. Any time I do a shallow "make operation X faster" micro-optimization I always wonder if there is a deeper and better "avoid operation X altogether" change that could be done instead.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
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.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

6 participants