Properly re-use def path hash in incremental mode#79721
Properly re-use def path hash in incremental mode#79721bors merged 1 commit intorust-lang:masterfrom
Conversation
Fixes rust-lang#79661 In incremental compilation mode, we update a `DefPathHash -> DefId` mapping every time we create a `DepNode` for a foreign `DefId`. This mapping is written out to the on-disk incremental cache, and is read by the next compilation session to allow us to lazily decode `DefId`s. When we decode a `DepNode` from the current incremental cache, we need to ensure that any previously-recorded `DefPathHash -> DefId` mapping gets recorded in the new mapping that we write out. However, PR rust-lang#74967 didn't do this in all cases, leading to us being unable to decode a `DefPathHash` in certain circumstances. This PR refactors some of the code around `DepNode` deserialization to prevent this kind of mistake from happening again.
|
r? @oli-obk (rust-highfive has picked a reviewer for you, use r? to override) |
| #[derive(Clone, Copy, PartialEq, Eq, PartialOrd, Ord, Hash, Encodable, Decodable)] | ||
| pub struct DepNode<K> { | ||
| pub kind: K, | ||
| // Important - whenever a `DepNode` is constructed, we need to make |
There was a problem hiding this comment.
Nit: This comment seems like it applies to the DepNode type as a whole and not just the hash field so I would move this to above the struct declaration.
|
Let's do a perf run before merging @bors try @rust-timer queue |
|
Awaiting bors try build completion |
|
⌛ Trying commit c294640 with merge 5c94f1727f83b41b9a3c5b59145fdc2b1ddf8a02... |
|
☀️ Try build successful - checks-actions |
|
Queued 5c94f1727f83b41b9a3c5b59145fdc2b1ddf8a02 with parent 1700ca0, future comparison URL. |
|
Finished benchmarking try commit (5c94f1727f83b41b9a3c5b59145fdc2b1ddf8a02): comparison url. Benchmarking this pull request likely means that it is perf-sensitive, so we're automatically marking it as not fit for rolling up. Please note that if the perf results are neutral, you should likely undo the rollup=never given below by specifying Importantly, though, if the results of this run are non-neutral do not roll this PR up -- it will mask other regressions or improvements in the roll up. @bors rollup=never |
|
r? @wesleywiser |
|
@bors r+ Thanks for jumping on this so quickly @Aaron1011! |
|
📌 Commit c294640 has been approved by |
|
@bors p=1 It fixes a potentially |
|
☀️ Test successful - checks-actions |
|
Thank you for this fix :) |
|
@Aaron1011 @wesleywiser this change had moderate regressions in several benchmarks. Since this was not directly addressed, I assume this was because the fix was important enough that the moderate regressions are acceptable? |
Fixes #79661
In incremental compilation mode, we update a
DefPathHash -> DefIdmapping every time we create a
DepNodefor a foreignDefId.This mapping is written out to the on-disk incremental cache, and is
read by the next compilation session to allow us to lazily decode
DefIds.When we decode a
DepNodefrom the current incremental cache, we needto ensure that any previously-recorded
DefPathHash -> DefIdmappinggets recorded in the new mapping that we write out. However, PR #74967
didn't do this in all cases, leading to us being unable to decode a
DefPathHashin certain circumstances.This PR refactors some of the code around
DepNodedeserialization toprevent this kind of mistake from happening again.