Skip to content

Remove WithCachedTypeInfo::stable_hash.#155329

Open
nnethercote wants to merge 1 commit intorust-lang:mainfrom
nnethercote:rm-WithCachedTypeInfo-stable_hash
Open

Remove WithCachedTypeInfo::stable_hash.#155329
nnethercote wants to merge 1 commit intorust-lang:mainfrom
nnethercote:rm-WithCachedTypeInfo-stable_hash

Conversation

@nnethercote
Copy link
Copy Markdown
Contributor

@nnethercote nnethercote commented Apr 15, 2026

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.

| ^^^^^^^^^^^^^^^^^^^^^^^^^

error: demangling(issue_60925::foo::Foo<issue_60925::llvm::Foo>::foo::h4b3099ec5dc5d306)
error: demangling(issue_60925::foo::Foo<issue_60925::llvm::Foo>::foo::h91bf17e30395b22a)
Copy link
Copy Markdown
Member

@bjorn3 bjorn3 Apr 15, 2026

Choose a reason for hiding this comment

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

Why do these hashes change? Is there some impurity in the hashing?

View changes since the review

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

It's because impl<T: HashStable<Hcx>, Hcx> HashStable<Hcx> for WithCachedTypeInfo<T> has changed from a two-step hash to a one-step hash. (Search for "hash that hash" in the diff.) The old code would hash the T to create a Fingerprint, and then hash that Fingerprint. The new code just hashes T.

(To double check this, I just tried reinstating the two-step hash and the symbol names reverted to their previous values.)

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

Labels

perf-regression Performance regression. perf-regression-triaged The performance regression has been triaged. 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.

9 participants