Skip to content

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

Draft
Daniel-B-Smith wants to merge 4 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 4 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.

@mejrs
Copy link
Copy Markdown
Contributor

mejrs commented Apr 27, 2026

@bors try cancel

@rust-bors
Copy link
Copy Markdown
Contributor

rust-bors Bot commented Apr 27, 2026

❗ There is currently no try build in progress on this PR.

@mejrs
Copy link
Copy Markdown
Contributor

mejrs commented Apr 27, 2026

@bors try @rust-timer queue

@rust-timer

This comment has been minimized.

@rust-bors

This comment has been minimized.

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

The latest update reverts crate_hash to use the HIR hash in cases where metadata is not otherwise generated. That fixed the large performance regression for compilations that depend heavily on cases where metadata is not generated.

The big performance open question right now is whether or not the less invasive metadata hashing strategy is fast enough. Hashing the bytes of each item one at a time has substantial overhead relative to hashing all of the bytes as they are flushed to disk. The latter is a much more invasive change to FileEncoder, so I'm holding off until it's clear that is needed.

@rust-log-analyzer

This comment has been minimized.

@rust-bors
Copy link
Copy Markdown
Contributor

rust-bors Bot commented Apr 27, 2026

☀️ Try build successful (CI)
Build commit: ec2b0e4 (ec2b0e4e0b51187e1b740843ecf29588eaa02a0f, parent: 52b6e2c208b73276ccb36ec0b68456913a801c96)

@rust-timer

This comment has been minimized.

@rust-timer
Copy link
Copy Markdown
Collaborator

Finished benchmarking commit (ec2b0e4): 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.9% [0.2%, 2.8%] 152
Regressions ❌
(secondary)
0.8% [0.2%, 3.9%] 89
Improvements ✅
(primary)
-1.3% [-5.5%, -0.2%] 5
Improvements ✅
(secondary)
-0.3% [-0.6%, -0.0%] 9
All ❌✅ (primary) 0.9% [-5.5%, 2.8%] 157

Max RSS (memory usage)

Results (primary -4.2%, 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)
5.2% [3.5%, 6.9%] 2
Improvements ✅
(primary)
-4.2% [-4.2%, -4.2%] 1
Improvements ✅
(secondary)
-1.3% [-1.3%, -1.3%] 1
All ❌✅ (primary) -4.2% [-4.2%, -4.2%] 1

Cycles

Results (primary -2.4%, secondary 2.4%)

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

mean range count
Regressions ❌
(primary)
2.8% [2.8%, 2.8%] 1
Regressions ❌
(secondary)
4.7% [4.2%, 5.3%] 4
Improvements ✅
(primary)
-5.0% [-7.3%, -2.6%] 2
Improvements ✅
(secondary)
-2.2% [-2.9%, -1.5%] 2
All ❌✅ (primary) -2.4% [-7.3%, 2.8%] 3

Binary size

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

Bootstrap: 487.959s -> 489.335s (0.28%)
Artifact size: 393.44 MiB -> 393.45 MiB (0.00%)

@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.

@rust-log-analyzer

This comment has been minimized.

@Kobzol
Copy link
Copy Markdown
Member

Kobzol commented Apr 28, 2026

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

This comment has been minimized.

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

For posterity, the big change behind the ongoing perf run is to hash the metadata as it is being flushed to disk instead of as each individual writes into the buffer. That reduces the hashing overhead substantially.

@rust-bors
Copy link
Copy Markdown
Contributor

rust-bors Bot commented Apr 28, 2026

☀️ Try build successful (CI)
Build commit: 34256d3 (34256d3644315502924b8c0bd4c52aecb65b8136, parent: 03c609abb6638f9d7f49f34326d4137d07f5cd61)

@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
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. 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.

8 participants