Computing crate_hash from metadata encoding instead of HIR (implements #94878) #154724
Computing crate_hash from metadata encoding instead of HIR (implements #94878) #154724Daniel-B-Smith wants to merge 1 commit into
Conversation
This comment has been minimized.
This comment has been minimized.
24c04d5 to
c826667
Compare
This comment has been minimized.
This comment has been minimized.
c826667 to
1fe48e6
Compare
This comment has been minimized.
This comment has been minimized.
43a7704 to
338aba3
Compare
This comment has been minimized.
This comment has been minimized.
0ddcd96 to
d27cca5
Compare
This comment has been minimized.
This comment has been minimized.
1e5f269 to
4171895
Compare
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
|
@bors try @rust-timer queue |
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
4171895 to
bb57d62
Compare
This comment has been minimized.
This comment has been minimized.
bb57d62 to
1ad9d87
Compare
|
If this needs an extra pair of eyes, feel free to assign me after cjgillot reviews. |
|
Is there any ordering dependency between this PR and #155871? |
|
These are independent. The one getting in later will have to do a bit of merge conflict resolution, but nothing too bad. |
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
|
@bors try @rust-timer queue |
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
|
Finished benchmarking commit (f0dc837): 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 @bors rollup=never Instruction countOur most reliable metric. Used to determine the overall result above. However, even this metric can be noisy.
Max RSS (memory usage)Results (primary 1.9%, secondary 0.3%)A less reliable metric. May be of interest, but not used to determine the overall result above.
CyclesResults (secondary -2.1%)A less reliable metric. May be of interest, but not used to determine the overall result above.
Binary sizeResults (primary 0.0%, secondary 0.1%)A less reliable metric. May be of interest, but not used to determine the overall result above.
Bootstrap: 516.831s -> 540.55s (4.59%) |
This comment has been minimized.
This comment has been minimized.
|
The remaining big comment from the review is to decide on extending the existing FileEncoder interface to support hashing before flush or keeping the fork. After that, I can resolve the existing comments, add the disable flag and create a gist with the testing strategy I've been using with other crates. |
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
|
Some changes occurred to the intrinsics. Make sure the CTFE / Miri interpreter cc @rust-lang/miri, @RalfJung, @oli-obk, @lcnr The parser was modified, potentially altering the grammar of (stable) Rust cc @fmease HIR ty lowering was modified cc @fmease
If you want to modify Some changes occurred to MIR optimizations cc @rust-lang/wg-mir-opt Some changes occurred in src/tools/compiletest cc @jieyouxu
cc @rust-lang/clippy The reflection data structures are tied exactly to the implementation cc @oli-obk Some changes occurred in match checking cc @Nadrieril |
This comment has been minimized.
This comment has been minimized.
|
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. |
Apologies for the noise. There was a rebase snafu, so I accidentally a version that pushed included a bunch of changes from upstream. None of those files are in this PR. |
|
@cjgillot this should be ready for another round of review. I want to spend a little bit more time doing iterative incremental compilation on a couple of crates, but the revert flag should make the risk relatively low (/it might need more than 12 weeks of nightly before being merged into stable). |
View all comments
This PR converts the crate_hash/SVH to depend on metadata instead of HIR whenever metadata is needed. A trimmed down crate_hash is kept for dylib/binary cases where metadata is not present. It is believed that the metadata will be a more sound way to track dependency changes.
Related to #94878
The metadata hash is calculated on the raw bytes before flush because hashing the elements incrementally turned out to be too expensive.
The change to the HIR hash is potentially safe even without the metadata crate_hash change. Without that change, this PR is a performance regression. I am bundling them because I believe the HIR hash change is more likely to be safe in light of the HIR hash being less load bearing on the SVH.
The dylib/binary crate_hash removes components that I believe are not relevant to those cases. Analysis:
The comment says: "Hash visibility information since it does not appear in HIR." Visibilities only matter to external users of the crate (i.e. consumers of metadata). Without metadata, visibility differences are not observable, so this contributes nothing for incremental correctness.
The comment says: "that content is exported into crate metadata, so any changes to it need to be reflected in the crate hash." Without metadata, there is nothing to export, so this is purely metadata-motivated. The visualizer file path is already covered by HIR (the attribute) and the content is loaded later only if metadata is being written.
These exist solely so that the crate-hash reflects remapped source paths that get embedded into metadata (the comment explicitly says "If we included the full mapping in the SVH, we could only have reproducible builds…"). The remapping itself is already captured via dep_tracking_hash, so for incremental this is redundant.
The crate hash calculation can be reverted via
-Z metadata-crate-hash=no. I manually confirmed that setting that flag generates the same hash as the commit prior to my change. The test for that flag only checks that it changes the value of the hash and does not check the specific value of the hash. I could add a check for the latter, but I'm nervous that a hash golden test would be a maintenance headache.DO NOT SUBMIT: Incremental compilation testing is ongoing and a way to revert the hash is necessary.