Skip to content

Remove WithCachedTypeInfo::stable_hash.#155329

Merged
rust-bors[bot] merged 1 commit intorust-lang:mainfrom
nnethercote:rm-WithCachedTypeInfo-stable_hash
Apr 28, 2026
Merged

Remove WithCachedTypeInfo::stable_hash.#155329
rust-bors[bot] merged 1 commit intorust-lang:mainfrom
nnethercote:rm-WithCachedTypeInfo-stable_hash

Conversation

@nnethercote
Copy link
Copy Markdown
Contributor

@nnethercote nnethercote commented Apr 15, 2026

View all comments

We store a stable hash value in the most common interned values (e.g. types, predicates, regions). This is 16 bytes of data.

  • In non-incremental builds it's a straightforward performance loss: the stable hash isn't computed or used, and the 16 bytes of space goes to waste (but it still gets hashed when interning).
  • In incremental builds it avoids some hashing but doesn't seem to actually be a genuine performance win, and the complexity doesn't seem worth it.

r? @oli-obk

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

@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 Apr 15, 2026
@rust-bors

This comment has been minimized.

rust-bors Bot pushed a commit that referenced this pull request Apr 15, 2026
…, r=<try>

Remove `WithCachedTypeInfo::stable_hash`.
@rust-log-analyzer

This comment has been minimized.

@rust-bors
Copy link
Copy Markdown
Contributor

rust-bors Bot commented Apr 15, 2026

☀️ Try build successful (CI)
Build commit: aef2982 (aef29827df2a13132c3307473c209a99baedf470, parent: bd1e7c79485d6a4113bb11dd98cb8b415cd4a55e)

@rust-timer

This comment has been minimized.

@rust-timer
Copy link
Copy Markdown
Collaborator

Finished benchmarking commit (aef2982): 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.7% [0.2%, 1.4%] 117
Regressions ❌
(secondary)
0.7% [0.1%, 2.8%] 71
Improvements ✅
(primary)
-0.4% [-0.8%, -0.2%] 33
Improvements ✅
(secondary)
-0.3% [-0.8%, -0.0%] 24
All ❌✅ (primary) 0.5% [-0.8%, 1.4%] 150

Max RSS (memory usage)

Results (primary -1.5%, secondary -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)
2.9% [2.5%, 3.3%] 2
Improvements ✅
(primary)
-1.5% [-2.7%, -0.6%] 28
Improvements ✅
(secondary)
-2.4% [-4.0%, -1.4%] 18
All ❌✅ (primary) -1.5% [-2.7%, -0.6%] 28

Cycles

Results (secondary -3.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)
- - 0
Improvements ✅
(secondary)
-3.8% [-6.5%, -2.0%] 3
All ❌✅ (primary) - - 0

Binary size

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

Bootstrap: 495.503s -> 489.042s (-1.30%)
Artifact size: 394.22 MiB -> 394.04 MiB (-0.05%)

@rustbot rustbot added perf-regression Performance regression. and removed S-waiting-on-perf Status: Waiting on a perf run to be completed. labels Apr 15, 2026
afurm

This comment was marked as low quality.

@rustbot
Copy link
Copy Markdown
Collaborator

rustbot commented Apr 15, 2026

Pull request author cannot be assigned as reviewer.

Please choose another assignee.

@nnethercote nnethercote force-pushed the rm-WithCachedTypeInfo-stable_hash branch from 0b026be to 27f66fe Compare April 15, 2026 10:29
@nnethercote
Copy link
Copy Markdown
Contributor Author

nnethercote commented Apr 15, 2026

Perf is pretty interesting here.

  • icounts perf is worse overall, due to worse results for the incremental cases. (Non-incremental icounts are improved, which makes sense.)
  • cycles and wall-time are both similar: very few results above the threshold; not much of a signal there. If you click "show non-relevant results" it's a mix but there is more green than red.
  • max-rss results are great, with lots of green. This makes sense because some very common interned types have gotten 16-20 bytes smaller. Faults are also improved, if that's meaningful.
  • bootstrap is down 1.3%. Not sure if that's big enough to be meaningful.
  • Artifact size is slightly down.

I think this is one of those cases where icounts is misleading, and overall the perf here is slightly positive. Combine that with it being a code simplification, and I'm inclined to pursue this.

@rustbot label: +perf-regression-triaged

@nnethercote nnethercote marked this pull request as ready for review April 15, 2026 10:42
@rustbot rustbot added the S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. label Apr 15, 2026
@rustbot
Copy link
Copy Markdown
Collaborator

rustbot commented Apr 15, 2026

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

@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 15, 2026
@rustbot
Copy link
Copy Markdown
Collaborator

rustbot commented Apr 15, 2026

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

@rustbot rustbot added the perf-regression-triaged The performance regression has been triaged. label Apr 15, 2026
@panstromek
Copy link
Copy Markdown
Contributor

panstromek commented Apr 15, 2026

The bootstrap time might be noise again. Base commit had a similarly big regression, and the next one on main is down by the same amount again.

I guess this might also make the wall-time numbers tricky to analyze. It depends on whether the source of noise is something on the machine or something in the artifact. If it's on the machine, then those wall-time improvements might also be noise.

Comment thread tests/ui/symbol-names/issue-60925.legacy.stderr Outdated
Comment thread compiler/rustc_type_ir/src/ty_info.rs
@nnethercote nnethercote force-pushed the rm-WithCachedTypeInfo-stable_hash branch from 27f66fe to 515530e Compare April 15, 2026 20:45
@nnethercote
Copy link
Copy Markdown
Contributor Author

As an experiment I tried removing WithCachedTypeInfo::outer_exclusive_binder. That increased icounts on a number of benchmarks ranging from 1--30%, and deepy-nested-multi was 75,000% worse. So that field is definitely load-bearing.

@rust-bors

This comment has been minimized.

@nnethercote nnethercote force-pushed the rm-WithCachedTypeInfo-stable_hash branch from 515530e to 1f1c4cd Compare April 19, 2026 22:08
@rustbot

This comment has been minimized.

@nnethercote
Copy link
Copy Markdown
Contributor Author

I rebased.

@rust-bors

This comment has been minimized.

We store a stable hash value in the most common interned values (e.g.
types, predicates, regions). This is 16 bytes of data.

- In non-incremental builds it's a straightforward performance loss: the
  stable hash isn't computed or used, and the 16 bytes of space goes to
  waste (but it still gets hashed when interning).

- In incremental builds it avoids some hashing but doesn't seem to
  actually be a genuine performance win, and the complexity doesn't seem
  worth it.
@nnethercote nnethercote force-pushed the rm-WithCachedTypeInfo-stable_hash branch from 1f1c4cd to d944ea1 Compare April 23, 2026 02:19
@rustbot
Copy link
Copy Markdown
Collaborator

rustbot commented Apr 23, 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.

Copy link
Copy Markdown
Contributor

@oli-obk oli-obk left a comment

Choose a reason for hiding this comment

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

@rust-bors
Copy link
Copy Markdown
Contributor

rust-bors Bot commented Apr 28, 2026

📌 Commit d944ea1 has been approved by oli-obk

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

rust-bors Bot commented Apr 28, 2026

☀️ Test successful - CI
Approved by: oli-obk
Duration: 3h 16m 50s
Pushing 4ddb0b7 to main...

@rust-bors rust-bors Bot merged commit 4ddb0b7 into rust-lang:main Apr 28, 2026
12 checks passed
@rustbot rustbot added this to the 1.97.0 milestone Apr 28, 2026
@github-actions
Copy link
Copy Markdown
Contributor

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 b806d39 (parent) -> 4ddb0b7 (this PR)

Test differences

Show 2 test diffs

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

Test dashboard

Run

cargo run --manifest-path src/ci/citool/Cargo.toml -- \
    test-dashboard 4ddb0b7f8ecda9dbdbcbc0519c9988badbd65d1c --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. x86_64-msvc-1: 2h 3m -> 2h 36m (+26.0%)
  2. dist-x86_64-apple: 2h 1m -> 2h 30m (+23.8%)
  3. dist-ohos-x86_64: 1h 3m -> 1h 16m (+21.7%)
  4. x86_64-gnu-distcheck: 2h 11m -> 1h 47m (-18.0%)
  5. dist-powerpc-linux: 1h 30m -> 1h 14m (-17.5%)
  6. x86_64-gnu-debug: 1h 47m -> 2h 5m (+16.7%)
  7. dist-apple-various: 1h 49m -> 1h 32m (-16.1%)
  8. i686-gnu-1: 2h 9m -> 1h 49m (-15.0%)
  9. dist-ohos-armv7: 1h 3m -> 1h 12m (+14.8%)
  10. i686-gnu-nopt-1: 2h 3m -> 1h 46m (-14.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 (4ddb0b7): 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.7% [0.3%, 1.5%] 113
Regressions ❌
(secondary)
0.7% [0.1%, 2.4%] 70
Improvements ✅
(primary)
-0.4% [-0.7%, -0.2%] 32
Improvements ✅
(secondary)
-0.3% [-0.7%, -0.0%] 36
All ❌✅ (primary) 0.5% [-0.7%, 1.5%] 145

Max RSS (memory usage)

Results (primary -1.7%, secondary -1.4%)

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)
5.7% [3.7%, 6.8%] 3
Improvements ✅
(primary)
-1.7% [-4.0%, -0.8%] 36
Improvements ✅
(secondary)
-2.6% [-9.0%, -0.8%] 18
All ❌✅ (primary) -1.7% [-4.0%, -0.8%] 36

Cycles

Results (secondary 0.7%)

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.6% [2.3%, 2.8%] 2
Improvements ✅
(primary)
- - 0
Improvements ✅
(secondary)
-2.9% [-2.9%, -2.9%] 1
All ❌✅ (primary) - - 0

Binary size

Results (primary 0.1%, secondary 0.1%)

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

mean range count
Regressions ❌
(primary)
0.1% [0.0%, 0.2%] 49
Regressions ❌
(secondary)
0.1% [0.0%, 0.2%] 23
Improvements ✅
(primary)
- - 0
Improvements ✅
(secondary)
- - 0
All ❌✅ (primary) 0.1% [0.0%, 0.2%] 49

Bootstrap: 489.748s -> 489.39s (-0.07%)
Artifact size: 393.29 MiB -> 393.41 MiB (0.03%)

@nnethercote nnethercote deleted the rm-WithCachedTypeInfo-stable_hash branch April 28, 2026 12:09
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. perf-regression-triaged The performance regression has been triaged. 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.

10 participants