-
Notifications
You must be signed in to change notification settings - Fork 12.7k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Properly re-use def path hash in incremental mode #79721
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) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Just one small nit.
@@ -53,6 +53,19 @@ use std::hash::Hash; | |||
#[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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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 -> DefId
mapping every time we create a
DepNode
for 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
DefId
s.When we decode a
DepNode
from the current incremental cache, we needto ensure that any previously-recorded
DefPathHash -> DefId
mappinggets 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
DefPathHash
in certain circumstances.This PR refactors some of the code around
DepNode
deserialization toprevent this kind of mistake from happening again.