-
Notifications
You must be signed in to change notification settings - Fork 13k
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
Improve query cycle errors for parallel queries #56434
Conversation
@@ -326,19 +326,17 @@ fn connected_to_root<'tcx>( | |||
query: Lrc<QueryJob<'tcx>>, | |||
visited: &mut FxHashSet<*const QueryJob<'tcx>> | |||
) -> bool { | |||
// This query is connected to the root (it has no query parent), return true | |||
if query.parent.is_none() { |
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.
Isn't this early return check cheaper than the contains
below?
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.
We want to return false here if query
has already been visited instead of true.
The job Click to expand the log.
I'm a bot! I can only do what humans tell me to, so if this was not helpful or you have suggestions for improvements, please ping or otherwise contact |
The job Click to expand the log.
I'm a bot! I can only do what humans tell me to, so if this was not helpful or you have suggestions for improvements, please ping or otherwise contact |
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, @Zoxc! r=me with the nits addressed.
src/librustc/ty/query/job.rs
Outdated
query.info.query.hash_stable(&mut hcx, &mut stable_hasher); | ||
let no_span = span == DUMMY_SP; | ||
// Prefer entry points which have valid spans for nicer error messages | ||
(no_span, stable_hasher.finish()) |
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 looks like things with no span would be preferred to things with span? Can you make no_span
an integer so that one can easier see what's going on?
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.
Is let no_span = (span == DUMMY_SP) as u8
any better?
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 prefer something like:
// Sort span-less queries to the back
let span_cmp = if span == DUMMY_SPAN { 1 } else { 0 };
@@ -21,6 +21,7 @@ RUN sh /scripts/sccache.sh | |||
|
|||
# using llvm-link-shared due to libffi issues -- see #34486 | |||
ENV RUST_CONFIGURE_ARGS \ | |||
--enable-experimental-parallel-queries \ |
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 shouldn't be committed, I guess.
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 wouldn't mind it too much =P
64673f1
to
57db5ad
Compare
@bors r=michaelwoerister |
📌 Commit 813b484 has been approved by |
Improve query cycle errors for parallel queries r? @michaelwoerister
Rollup of 7 pull requests Successful merges: - #56000 (Add Armv8-M Mainline targets) - #56250 (Introduce ptr::hash for references) - #56434 (Improve query cycle errors for parallel queries) - #56516 (Replace usages of `..i + 1` ranges with `..=i`.) - #56555 (Send textual profile data to stderr, not stdout) - #56561 (Fix bug in from_key_hashed_nocheck) - #56574 (Fix a stutter in the docs for slice::exact_chunks) Failed merges: r? @ghost
@@ -1942,8 +1942,12 @@ pub mod tls { | |||
/// This is a callback from libsyntax as it cannot access the implicit state | |||
/// in librustc otherwise | |||
fn span_debug(span: syntax_pos::Span, f: &mut fmt::Formatter<'_>) -> fmt::Result { |
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 am confused, isn't this only used at the same time as the TLS TyCtxt
is present?
How can with_opt
give you None
? Did that code change somehow?
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.
With parallel queries we set this on the worker threads when we create the thread pool. In that case it acts it's more like runtime linking and it will be set when no TyCtxt
is around.
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 not set it at the same time as the TyCtxt
TLS?
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.
We need to set this on all worker threads, which we can easily do when creating the thread pool.
We could put it in ImplicitCtxt
, but it would never change, so that would just make queries slower for no reason.
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.
In that case, can we make it so the debug callbacks are all set globally before entering even the global TyCtxt
even without parallel queries?
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.
Maybe we just need a scoped_thread_local
for the CodeMap
? I feel like that would probably be a cleaner design.
💥 Test timed out |
r? @michaelwoerister