Skip to content

[incremental] Add support for eval always queries - #45353

Merged
bors merged 4 commits into
rust-lang:masterfrom
wesleywiser:untracked_queries
Oct 27, 2017
Merged

[incremental] Add support for eval always queries#45353
bors merged 4 commits into
rust-lang:masterfrom
wesleywiser:untracked_queries

Conversation

@wesleywiser

Copy link
Copy Markdown
Member

Part of #45238

@rust-highfive

Copy link
Copy Markdown
Contributor

r? @eddyb

(rust_highfive has picked a reviewer for you, use r? to override)

@wesleywiser

Copy link
Copy Markdown
MemberAuthor

r? @michaelwoerister

@kennytmkennytm added the S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. label Oct 18, 2017

@michaelwoeristermichaelwoerister left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looking good, except for the result fingerprinting being missing. Since we essentially disable dependency tracking for this tasks its even more important for them to be fingerprinted.

If you add the fingerprint, however, I guess there'll be a lot of code duplication between with_untracked_task and with_task. Maybe one can be implemented in the terms of the other.

I'm also a bit skeptical about the term untracked since it rather suggests the functionality that we already have with ignore.

Comment threadsrc/librustc/dep_graph/graph.rs Outdated

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You should be able to make the push and the pop methods here private.

Comment threadsrc/librustc/dep_graph/graph.rs Outdated

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Since this line is getting a little long, it would be more readable to have each arm on its own line.

@kennytmkennytm added S-waiting-on-author Status: This is awaiting some action (such as code changes or more information) from the author. and removed S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. labels Oct 18, 2017
@michaelwoerister

michaelwoerister commented Oct 18, 2017

Copy link
Copy Markdown
Member

Hm, it looks like implementing with_untracked_task in terms with_task gets rather contrived. I had hoped that we would be able to do something like:

pubfnwith_xxx_task<C,A,R,HCX>(&self,key:DepNode,cx:C,arg:A,task:fn(C,A) -> R)
-> (R,DepNodeIndex){self.with_task(key, cx, arg, |cx, arg| {// Explicitly add the read to the Krate nodeself.read(DepNode::Krate);// Execute the task without recording any other readsself.with_ignore(|| {task(cx, arg)})})}

But with_task takes a function, not a closure, so we cannot capture the task parameter. If you can come up with a way to make this work nonetheless, that'd be nice. Then you wouldn't even need to modify CurrentDepGraph and OpenTask. Otherwise I suggest to make a generalized, private version of with_task -- which allows to specify somehow which push and pop methods it will invoke -- and call that with different parameters from with_task and with_untracked_task.

@wesleywiser

Copy link
Copy Markdown
MemberAuthor

Thanks for the review! What about something like "crate-wide query"? I'm also fine just changing it to "eval-always".

@michaelwoerister

Copy link
Copy Markdown
Member

Yeah, let's stick to "eval-always". It's not a pretty name but it conveys the underlying concept well enough.

@wesleywiser

Copy link
Copy Markdown
MemberAuthor

@michaelwoerister I fixed up the commit per your feedback.

@kennytmkennytm added S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. and removed S-waiting-on-author Status: This is awaiting some action (such as code changes or more information) from the author. labels Oct 21, 2017
@michaelwoerister

Copy link
Copy Markdown
Member

@wesleywiser Yes, that looks very good now! If you want to continue working on this, I suggest just appending to this PR.

@michaelwoeristermichaelwoerister added S-waiting-on-author Status: This is awaiting some action (such as code changes or more information) from the author. and removed S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. labels Oct 23, 2017
@wesleywiser

Copy link
Copy Markdown
MemberAuthor

@michaelwoerister Thanks! Pushed three new commits.

@michaelwoerister

Copy link
Copy Markdown
Member

Looks very good!

I'm seeing this error on travis:

thread 'rustc' panicked at 'assertion failed: !data.colors.borrow().contains_key(&key)', /checkout/src/librustc/dep_graph/graph.rs:220:12

This suggests that we are re-running queries although they've already been marked as green. This is because we are not doing the whole try_mark_green_and_read() spiel for eval-always.

Thinking about it some more, there should really be no reason to treat an eval-always query different from a regular one, except for the changes you already implemented in graph.rs. So instead of modifying try_get(), could you just do if dep_node.is_eval_always() {...} in force()?:

profq_msg!(tcx,ProfileQueriesMsg::ProviderBegin);
let res = tcx.cycle_check(span,Query::$name(key), || {
tcx.sess.diagnostic().track_diagnostics(|| {
tcx.dep_graph.with_task(dep_node,
tcx,
key,
Self::compute_result)
})
})?;
profq_msg!(tcx,ProfileQueriesMsg::ProviderEnd);

That should also not introduce any code duplication.

Let me know if you have any questions about this change of strategy.

@wesleywiser

Copy link
Copy Markdown
MemberAuthor

Hmmm... I can't seem to repro that. ./x.py test succeeds on my machine.

Regardless, I can certainly revert the changes to try_get_with() but I'm not entirely clear what you're proposing in regards to force(). Can you elaborate on that?

@michaelwoerister

Copy link
Copy Markdown
Member

Hmmm... I can't seem to repro that. ./x.py test succeeds on my machine.

You are probably building with debug assertions disabled. I generally recommend setting debug-assertions = true in your config.toml. (and debuginfo-lines = true for better backtraces).

I imagine the updated force() method to look like this:

profq_msg!(tcx,ProfileQueriesMsg::ProviderBegin);let res = tcx.cycle_check(span,Query::$name(key), || { tcx.sess.diagnostic().track_diagnostics(|| {if dep_node.is_eval_always(){
tcx.dep_graph.with_eval_always_task(dep_node, tcx, key,Self::compute_result)}else{
tcx.dep_graph.with_task(dep_node, tcx, key,Self::compute_result)}})})?;profq_msg!(tcx,ProfileQueriesMsg::ProviderEnd);

This way eval-always tasks are treated the same as regular with the only exception of what reads are recorded from them.

@wesleywiser

Copy link
Copy Markdown
MemberAuthor

Oh got it. That makes sense.

I generally recommend setting debug-assertions = true in your config.toml. (and debuginfo-lines = true for better backtraces).

Thanks! I'll do that.

@wesleywiser

Copy link
Copy Markdown
MemberAuthor

@michaelwoerister Done

@wesleywiserwesleywiser changed the title [incremental] Add support for untracked queries[incremental] Add support for eval always queriesOct 27, 2017
@michaelwoerister

Copy link
Copy Markdown
Member

Awesome, thank you so much @wesleywiser!

@bors r+

@bors

bors commented Oct 27, 2017

Copy link
Copy Markdown
Collaborator

📌 Commit 8281e88 has been approved by michaelwoerister

@bors

bors commented Oct 27, 2017

Copy link
Copy Markdown
Collaborator

⌛ Testing commit 8281e88 with merge 51456a6...

bors added a commit that referenced this pull request Oct 27, 2017
[incremental] Add support for eval always queries
Part of #45238
@bors

bors commented Oct 27, 2017

Copy link
Copy Markdown
Collaborator

☀️ Test successful - status-appveyor, status-travis
Approved by: michaelwoerister
Pushing 51456a6 to master...

@bors
bors merged commit 8281e88 into rust-lang:masterOct 27, 2017
@wesleywiser

Copy link
Copy Markdown
MemberAuthor

Thanks for all the help @michaelwoerister!!

@michaelwoerister

Copy link
Copy Markdown
Member

You're welcome!

@wesleywiser
wesleywiser deleted the untracked_queries branch October 28, 2017 23:16
@mark-i-mmark-i-m mentioned this pull request Jan 2, 2019
emilyalbini added a commit to emilyalbini/rust that referenced this pull request Jan 7, 2019
…=michaelwoerister
remove outdated comment
rust-lang#44234 was closed, apparently solved by rust-lang#45353
r? @michaelwoerister
@ChrisDentonChrisDenton mentioned this pull request Oct 20, 2024
matthiaskrgr added a commit to matthiaskrgr/rust that referenced this pull request Oct 20, 2024
rust-timer added a commit to rust-lang-ci/rust that referenced this pull request Oct 20, 2024
Rollup merge of rust-lang#131965 - ChrisDenton:outdated-comment, r=jieyouxu
remove outdated comment
rust-lang#44234 was closed, apparently solved by rust-lang#45353
Sign up for freeto join this conversation on GitHub. Already have an account? Sign in to comment

Labels

S-waiting-on-authorStatus: This is awaiting some action (such as code changes or more information) from the author.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

6 participants

@wesleywiser@rust-highfive@michaelwoerister@bors@eddyb@kennytm