-
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
Make create_def a side effect instead of marking the entire query as always red #115613
base: master
Are you sure you want to change the base?
Conversation
Another tricky case:
We wouldn't want to create 2 definitions where we only ask for one. |
Huh... why does that happen? Shouldn't we already be getting weird diagnostics in that case? |
This happens if we don't have the result of |
More precisely: the first call is |
The logic is the fallback case in |
Thanks. I really need to dig into |
I did some testing and a code dive, and I don't think that's what's happening.
|
|
yay, with this hint I was able to produce an example that actually exhibits an issue
oh wait... I even have this issue without doing any other changes to rustc. So it's not even ensure related yet |
☔ The latest upstream changes (presumably #115920) made this pull request unmergeable. Please resolve the merge conflicts. |
The difficulty is to know when to skip creating the DefId and reuse the one created by side-effect replay. What about adding a new variant |
Thanks! I was thinking about doing
but didn't know how. I'll investigate the |
6f8f71c
to
a7f29ee
Compare
☔ The latest upstream changes (presumably #120486) made this pull request unmergeable. Please resolve the merge conflicts. |
6d6b1eb
to
6831868
Compare
@cjgillot I implemented replaying, and that fixes the issues I was able to coax out of incremental tests, could you have a look? I'll keep working on it and adding more tests, but I think I could benefit from a review @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.
💔 Test failed - checks-actions |
@bors try @rust-timer queue |
Awaiting bors try build completion. @rustbot label: +S-waiting-on-perf |
Make create_def a side effect instead of marking the entire query as always red Before this PR: * query A creates def id D * query A is marked as depending on the always-red node, meaning it will always get re-run * in the next run of rustc: query A is not loaded from the incremental cache, but rerun After this PR: * query A creates def id D * query system registers this a side effect (just like we collect diagnostics to re-emit them without running a query) * in the next run of rustc: query A is loaded from the incremental cache and its side effect is run (thus re-creating def id D without running query A) r? `@cjgillot` TODO: * [ ] need to make feeding queries a side effect, too. At least ones that aren't written to disk. * [ ] need to re-feed the `def_span` query * [ ] many more tests
This comment has been minimized.
This comment has been minimized.
💔 Test failed - checks-actions |
Some minor query system cleanups * Improves diagnostics on conflicting query flags * removes unnecessary impls * `track_caller` pulled out of rust-lang#115613
Some minor query system cleanups * Improves diagnostics on conflicting query flags * removes unnecessary impls * `track_caller` pulled out of rust-lang#115613
Some minor query system cleanups * Improves diagnostics on conflicting query flags * removes unnecessary impls * `track_caller` pulled out of rust-lang#115613
Rollup merge of rust-lang#126035 - oli-obk:query_macro_errors, r=fmease Some minor query system cleanups * Improves diagnostics on conflicting query flags * removes unnecessary impls * `track_caller` pulled out of rust-lang#115613
☔ The latest upstream changes (presumably #126104) made this pull request unmergeable. Please resolve the merge conflicts. |
c490a96
to
d428f0a
Compare
☔ The latest upstream changes (presumably #125918) made this pull request unmergeable. Please resolve the merge conflicts. |
…o we can reliably recreate the same `DefId` over and over again
d428f0a
to
972210d
Compare
let _ = tcx.eval_static_initializer(item_def_id); | ||
} | ||
}); | ||
|
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.
Why is this block necessary? The previous calls tcx.ensure().eval_static_initializer
.
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 test code to replicate the bug I had initially, it should not land
// | ||
// This call also writes to the value of `source_span` and `expn_that_defined` queries. | ||
// This is fine because: | ||
// - those queries are `eval_always` so we won't miss their result changing; | ||
// - this write will have happened before these queries are called. |
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.
Stale comment (pre-existing).
TaskDepsRef::Replay { prev_side_effects, created_def_ids } => { | ||
trace!(?created_def_ids, "replay side effects"); | ||
trace!("num_defs : {}", prev_side_effects.definitions.len()); | ||
let index = created_def_ids.fetch_add(1, std::sync::atomic::Ordering::Relaxed); | ||
let prev_info = &prev_side_effects.definitions[index]; | ||
let def_id = self.untracked.definitions.read().local_def_path_hash_to_def_id( | ||
prev_info.hash, | ||
&"should have already recreated def id in try_mark_green", | ||
); | ||
assert_eq!(prev_info.data, data); | ||
assert_eq!(prev_info.parent, parent); | ||
def_id | ||
} |
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 logic is subtle, we should definitely document it somewhere. Here, or on DefIdInfo
struct?
☔ The latest upstream changes (presumably #126439) made this pull request unmergeable. Please resolve the merge conflicts. |
Some minor query system cleanups * Improves diagnostics on conflicting query flags * removes unnecessary impls * `track_caller` pulled out of rust-lang/rust#115613
Before this PR:
After this PR:
r? @cjgillot
TODO:
def_span
query