-
Notifications
You must be signed in to change notification settings - Fork 12.8k
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
Only use the new node hashmap for anonymous nodes. #112469
base: master
Are you sure you want to change the base?
Conversation
Some changes occurred in compiler/rustc_codegen_cranelift cc @bjorn3 |
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.
Thanks for splitting this out into a more limited set of changes, @cjgillot! That should make it easier to make progress.
I've left a few comments below where I think changes are needed to preserve the semantics of the checks or to make things easier to understand. Otherwise the PR looks good to me, except for one thing:
The current version does not contain the lightweight check for duplicate dep-nodes during graph deserialization. That means that we would basically stop detecting duplicate dep-nodes altogether because the more accurate checks are now behind a flag that nobody uses. As long as (non-anonymous) dep-nodes are still defined to have a 1:1 relationship to query invocations, we want to know about DepNode collisions, right?
I'm not sure what's the best reaction to a DepNode collision being detected. Some options are:
- Ignore the incremental cache and emit a warning, encouraging re-running with
-Zverify-incremental-ich
and creating a bug report. - Same as above, but only on nightly. Silently ignore the cache on non-nightly.
- Instead of a warning, make the compiler ICE with message mentioning
-Zverify-incremental-ich
. - ICE on nightly, silently ignore cache on stable.
018664e
to
ff9f2a0
Compare
ff9f2a0
to
9227452
Compare
I think this looks great now! I'd still like us to have some form of the duplicates check during deserialization, so that the signal on hash collisions doesn't go completely silent. However, I realize that it's kind of a hard UX question that I don't want this to be blocked on. What do you think about this:
|
☔ The latest upstream changes (presumably #110050) made this pull request unmergeable. Please resolve the merge conflicts. |
@@ -1163,7 +1196,7 @@ impl<K: DepKind> CurrentDepGraph<K> { | |||
record_graph, | |||
record_stats, | |||
)), | |||
new_node_to_index: Sharded::new(|| { | |||
anon_node_to_index: Sharded::new(|| { | |||
FxHashMap::with_capacity_and_hasher( | |||
new_node_count_estimate / sharded::SHARDS, |
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.
This size estimate is probably a bit off now, but I'm not sure what we'd replace it with.
@@ -1200,20 +1243,19 @@ impl<K: DepKind> CurrentDepGraph<K> { | |||
edges: EdgesVec, | |||
current_fingerprint: Fingerprint, | |||
) -> DepNodeIndex { |
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.
This function should probably be renamed alloc_new_node
as it no longer does interning.
if let Some(ref nodes_newly_allocated_in_current_session) = | ||
self.nodes_newly_allocated_in_current_session | ||
{ | ||
if !nodes_newly_allocated_in_current_session.lock().insert(key) { |
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.
I'd put cold_path
around this.
I have a branch that builds the index on-demand, which means by the time duplicates are detected, we can no longer ignore the incremental cache. That would only be compatible with the always ICE option. |
That would also be compatible with the "drop duplicates from index" option, wouldn't it? |
Yeah. |
I noticed that dropping duplicates from the index might not catch all cases: If the hash collision occurs between a node from the previous graph and a node that is newly allocated in the current session, looking up the new node would wrongly find the previous node, right? I'm working on a proof of concept implementation of an alternative approach (inspired by @cjgillot's work in #109050), which does not have |
OK, I ran the experiment mentioned above in #118667 and I think we can safely call that a failure 🙂 Given that the quick check during deserialization also is not as complete as we thought1, I think it's time to re-evaluate. I'm proposing the following:
What do you think? Footnotes |
@cjgillot Do you mind if I pick up this PR? |
It seems this would be a good idea anyway as seems to be quite a few hash issues sneaking through CI already: https://github.com/rust-lang/rust/issues?q=is%3Aissue+is%3Aopen+forcing+query+with+already+existing |
I don't think it would catch less cases that we currently do, it just catches them later. It also does not catch all cases. We're trying to catch mismatches between |
Verify that query keys result in unique dep nodes This implements checking that query keys result into unique dep nodes as mentioned in rust-lang#112469. We could do a perf check to see how expensive this is. r? `@michaelwoerister`
Verify that query keys result in unique dep nodes This implements checking that query keys result into unique dep nodes as mentioned in rust-lang#112469. We could do a perf check to see how expensive this is. r? `@michaelwoerister`
…rister Verify that query keys result in unique dep nodes This implements checking that query keys result into unique dep nodes as mentioned in rust-lang#112469. We could do a perf check to see how expensive this is. r? `@michaelwoerister`
Verify that query keys result in unique dep nodes This implements checking that query keys result into unique dep nodes as mentioned in rust-lang/rust#112469. We could do a perf check to see how expensive this is. r? `@michaelwoerister`
Verify that query keys result in unique dep nodes This implements checking that query keys result into unique dep nodes as mentioned in rust-lang/rust#112469. We could do a perf check to see how expensive this is. r? `@michaelwoerister`
Verify that query keys result in unique dep nodes This implements checking that query keys result into unique dep nodes as mentioned in rust-lang/rust#112469. We could do a perf check to see how expensive this is. r? `@michaelwoerister`
r? @Zoxc (feel free to roll review assignment) |
Split from #109050
The duplication check is made opt-in with
-Zincremental-verify-ich
.r? @michaelwoerister