Skip to content

Computing crate_hash from metadata encoding instead of HIR (implements #94878) (very draft)#154724

Draft
Daniel-B-Smith wants to merge 6 commits intorust-lang:mainfrom
Daniel-B-Smith:smithdb3/fix-94878
Draft

Computing crate_hash from metadata encoding instead of HIR (implements #94878) (very draft)#154724
Daniel-B-Smith wants to merge 6 commits intorust-lang:mainfrom
Daniel-B-Smith:smithdb3/fix-94878

Conversation

@Daniel-B-Smith
Copy link
Copy Markdown
Contributor

@Daniel-B-Smith Daniel-B-Smith commented Apr 2, 2026

View all comments

Adds a parallel process of hashing along with the metadata encoding. It does add metadata encoding in a few places to ensure that the hash was available. Currently, the metadata encoding always generates both the metadata and the hash even if only one is needed.

Known issue: one test failure due to #137108 (pre-existing repr(simd) projection bug. The new metadata pass trips some MIR validation. This will need to catch the issue earlier.

Local profiling on laptop shows roughly neutral (~0.5%), requesting CI perf run for precise measurement

@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 2, 2026
@rust-log-analyzer

This comment has been minimized.

@Daniel-B-Smith Daniel-B-Smith force-pushed the smithdb3/fix-94878 branch 5 times, most recently from 24c04d5 to c826667 Compare April 7, 2026 15:59
@rust-log-analyzer

This comment has been minimized.

@rust-log-analyzer

This comment has been minimized.

@Daniel-B-Smith Daniel-B-Smith force-pushed the smithdb3/fix-94878 branch 2 times, most recently from 43a7704 to 338aba3 Compare April 8, 2026 19:34
@rust-log-analyzer

This comment has been minimized.

@Daniel-B-Smith Daniel-B-Smith force-pushed the smithdb3/fix-94878 branch 2 times, most recently from 0ddcd96 to d27cca5 Compare April 8, 2026 21:34
@rust-log-analyzer

This comment has been minimized.

@Daniel-B-Smith Daniel-B-Smith force-pushed the smithdb3/fix-94878 branch 3 times, most recently from 1e5f269 to 4171895 Compare April 9, 2026 14:56
@rust-log-analyzer

This comment has been minimized.

@rust-bors

This comment has been minimized.

@Daniel-B-Smith Daniel-B-Smith changed the title #94878 Computing crate_hash from metadata encoding instead of HIR (implements #94878) (very draft) Apr 9, 2026
@nnethercote
Copy link
Copy Markdown
Contributor

@bors try @rust-timer queue

@rust-timer

This comment has been minimized.

@rust-bors

This comment has been minimized.

@rustbot rustbot added the S-waiting-on-perf Status: Waiting on a perf run to be completed. label Apr 9, 2026
@rust-log-analyzer

This comment has been minimized.

@rust-timer

This comment has been minimized.

@rust-timer
Copy link
Copy Markdown
Collaborator

Finished benchmarking commit (34256d3): 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.5% [0.2%, 1.0%] 46
Regressions ❌
(secondary)
0.9% [0.1%, 3.9%] 31
Improvements ✅
(primary)
-0.6% [-5.4%, -0.2%] 13
Improvements ✅
(secondary)
-0.4% [-1.6%, -0.0%] 18
All ❌✅ (primary) 0.3% [-5.4%, 1.0%] 59

Max RSS (memory usage)

Results (primary 0.5%, secondary -1.0%)

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

mean range count
Regressions ❌
(primary)
5.6% [5.6%, 5.6%] 1
Regressions ❌
(secondary)
- - 0
Improvements ✅
(primary)
-4.5% [-4.5%, -4.5%] 1
Improvements ✅
(secondary)
-1.0% [-1.0%, -1.0%] 1
All ❌✅ (primary) 0.5% [-4.5%, 5.6%] 2

Cycles

Results (primary -2.6%, secondary 3.0%)

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

mean range count
Regressions ❌
(primary)
2.2% [2.2%, 2.2%] 1
Regressions ❌
(secondary)
3.8% [2.5%, 4.8%] 5
Improvements ✅
(primary)
-7.3% [-7.3%, -7.3%] 1
Improvements ✅
(secondary)
-1.3% [-1.3%, -1.3%] 1
All ❌✅ (primary) -2.6% [-7.3%, 2.2%] 2

Binary size

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

Bootstrap: 487.089s -> 487.591s (0.10%)
Artifact size: 393.44 MiB -> 393.40 MiB (-0.01%)

@rustbot rustbot removed the S-waiting-on-perf Status: Waiting on a perf run to be completed. label Apr 28, 2026
@rust-log-analyzer

This comment has been minimized.

@ZuseZ4
Copy link
Copy Markdown
Member

ZuseZ4 commented May 1, 2026

@bors try @rust-timer queue

@rust-timer

This comment has been minimized.

@rust-bors

This comment has been minimized.

@rustbot rustbot added the S-waiting-on-perf Status: Waiting on a perf run to be completed. label May 1, 2026
rust-bors Bot pushed a commit that referenced this pull request May 1, 2026
Computing crate_hash from metadata encoding instead of HIR (implements #94878) (very draft)
@Daniel-B-Smith
Copy link
Copy Markdown
Contributor Author

Before the next perf numbers come back, there are two optimizations this time. First, I removed a few inputs into the crate_hash for the tcx.needs_crate_hash() && !tcx.needs_metadata() case. I also changed the hashing of the metadata bytes to be a straight stable hash of the byte stream instead of using a stable hashing context.

@rust-bors
Copy link
Copy Markdown
Contributor

rust-bors Bot commented May 1, 2026

☀️ Try build successful (CI)
Build commit: d73a833 (d73a8336e43c291c192ed07d1d4c5f82597e3d86, parent: f53b654a8882fd5fc036c4ca7a4ff41ce32497a6)

@rust-timer

This comment has been minimized.

@rust-timer
Copy link
Copy Markdown
Collaborator

Finished benchmarking commit (d73a833): 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.6% [0.2%, 1.0%] 47
Regressions ❌
(secondary)
0.8% [0.1%, 3.7%] 30
Improvements ✅
(primary)
-0.7% [-5.4%, -0.2%] 12
Improvements ✅
(secondary)
-0.4% [-1.6%, -0.2%] 15
All ❌✅ (primary) 0.3% [-5.4%, 1.0%] 59

Max RSS (memory usage)

Results (primary -3.4%, secondary 3.0%)

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)
3.0% [2.1%, 3.4%] 4
Improvements ✅
(primary)
-3.4% [-4.4%, -2.5%] 2
Improvements ✅
(secondary)
- - 0
All ❌✅ (primary) -3.4% [-4.4%, -2.5%] 2

Cycles

Results (primary -6.5%, 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)
4.1% [3.8%, 4.4%] 2
Improvements ✅
(primary)
-6.5% [-6.5%, -6.5%] 1
Improvements ✅
(secondary)
-4.2% [-4.2%, -4.2%] 1
All ❌✅ (primary) -6.5% [-6.5%, -6.5%] 1

Binary size

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

Bootstrap: 487.787s -> 499.567s (2.41%)
Artifact size: 390.97 MiB -> 390.94 MiB (-0.01%)

@rustbot rustbot removed the S-waiting-on-perf Status: Waiting on a perf run to be completed. label May 1, 2026
@Daniel-B-Smith
Copy link
Copy Markdown
Contributor Author

The next performance test is to see if removing the no_hash I added from the hir_crate would improve performance. That seems like the culprit of the IncrUnchanged regressions. I somewhat expect regressions in IncrPatched, but I don't know the relative magnitude of the two options.

@JonathanBrouwer
Copy link
Copy Markdown
Contributor

@bors try @rust-timer queue

@rust-timer
Copy link
Copy Markdown
Collaborator

Awaiting bors try build completion.

@rustbot label: +S-waiting-on-perf

@rustbot rustbot added the S-waiting-on-perf Status: Waiting on a perf run to be completed. label May 1, 2026
@rust-bors

This comment has been minimized.

rust-bors Bot pushed a commit that referenced this pull request May 1, 2026
Computing crate_hash from metadata encoding instead of HIR (implements #94878) (very draft)
@rust-bors
Copy link
Copy Markdown
Contributor

rust-bors Bot commented May 2, 2026

💔 Test for 9e15878 failed: CI

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

Labels

A-query-system Area: The rustc query system (https://rustc-dev-guide.rust-lang.org/query.html) perf-regression Performance regression. S-waiting-on-author Status: This is awaiting some action (such as code changes or more information) from the author. S-waiting-on-perf Status: Waiting on a perf run to be completed. 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