Skip to content

Avoid creating anonymous nodes with zero or one dependency. #85337

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

Merged
merged 2 commits into from
Jun 2, 2021

Conversation

cjgillot
Copy link
Contributor

Anonymous nodes are only useful to encode dependencies, and cannot be replayed from one compilation session to another.
As such, anonymous nodes without dependency are always green.
Anonymous nodes with only one dependency are equivalent to this dependency.

cc #45408
cc @michaelwoerister

@rust-highfive
Copy link
Contributor

r? @varkor

(rust-highfive has picked a reviewer for you, use r? to override)

@rust-highfive rust-highfive added the S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. label May 15, 2021
@cjgillot
Copy link
Contributor Author

@bors try @rust-timer queue

@rust-timer
Copy link
Collaborator

Awaiting bors try build completion.

@rustbot label: +S-waiting-on-perf

@rustbot rustbot added the S-waiting-on-perf Status: Waiting on a perf run to be completed. label May 15, 2021
@bors
Copy link
Collaborator

bors commented May 15, 2021

⌛ Trying commit 95481bee74447fff3d637efc94e7ee0b12404ffe with merge 03d36a4a6ed12e8c2b5723d2bafbb9c71636f1b9...

@bors
Copy link
Collaborator

bors commented May 15, 2021

☀️ Try build successful - checks-actions
Build commit: 03d36a4a6ed12e8c2b5723d2bafbb9c71636f1b9 (03d36a4a6ed12e8c2b5723d2bafbb9c71636f1b9)

@rust-timer
Copy link
Collaborator

Queued 03d36a4a6ed12e8c2b5723d2bafbb9c71636f1b9 with parent 2a245f4, future comparison URL.

@rust-timer
Copy link
Collaborator

Finished benchmarking try commit (03d36a4a6ed12e8c2b5723d2bafbb9c71636f1b9): 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 rollup- to bors.

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
@rustbot label: +S-waiting-on-review -S-waiting-on-perf

@rustbot rustbot removed the S-waiting-on-perf Status: Waiting on a perf run to be completed. label May 15, 2021
@varkor
Copy link
Member

varkor commented May 16, 2021

r? @michaelwoerister

@michaelwoerister
Copy link
Member

That's a nice idea. But it made me realize that a single DepNodeIndex can map to multiple query invocations (if they are anonymous) even before this PR. That's a problem for query-key recording in self-profiling which relies on DepNodeIndex to uniquely identify a query invocation :/

@michaelwoerister
Copy link
Member

@cjgillot Would you be willing to open an issue about DepNodeIndex not uniquely identifying query keys of anon queries and the exact consequences this has for self-profiling? If we get that documented, I think we can move forward with this PR.

Copy link
Member

@michaelwoerister michaelwoerister left a comment

Choose a reason for hiding this comment

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

I've seen that you have opened #85688 so we can go ahead with this PR. Thanks @cjgillot! I left a few comments below.

@@ -45,6 +45,7 @@ rustc_index::newtype_index! {

impl DepNodeIndex {
pub const INVALID: DepNodeIndex = DepNodeIndex::MAX;
pub const DUMMY_ANON: DepNodeIndex = DepNodeIndex::from_u32(0);
Copy link
Member

Choose a reason for hiding this comment

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

Let's rename this to something more descriptive like SINGLETON_DEPENDENCYLESS_ANON_NODE.

let current =
CurrentDepGraph::new(prev_graph_node_count, encoder, record_graph, record_stats);

// Instantiate an *always green* node for dependency-less anonymous queries.
Copy link
Member

Choose a reason for hiding this comment

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

I would not bring the fact that dependency-less nodes are always green into play here because it actually does not matter for the optimization, right?

};
let dep_node_index = match task_deps.len() {
0 => {
// Dependency-less anonymous nodes can safely be replaced by a dummy node.
Copy link
Member

Choose a reason for hiding this comment

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

Let's provide an explanation here how this actually works. Something like:

// Because the dep-node id of anon nodes is computed from the sets of its dependencies 
// we already know what the ID of this dependency-less node is going to be (i.e. equal 
// to the precomputed `SINGLETON_DEPENDENCYLESS_ANON_NODE`). As a consequence we can 
// skip creating a `StableHasher` and sending the node through interning.

@michaelwoerister
Copy link
Member

@bors r+

@bors
Copy link
Collaborator

bors commented Jun 2, 2021

📌 Commit b51f24f has been approved by michaelwoerister

@bors bors added S-waiting-on-bors Status: Waiting on bors to run and complete tests. Bors will change the label on completion. and removed S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. labels Jun 2, 2021
@bors
Copy link
Collaborator

bors commented Jun 2, 2021

⌛ Testing commit b51f24f with merge 2f601ef...

@bors
Copy link
Collaborator

bors commented Jun 2, 2021

☀️ Test successful - checks-actions
Approved by: michaelwoerister
Pushing 2f601ef to master...

@bors bors added the merged-by-bors This PR was explicitly merged by bors. label Jun 2, 2021
@bors bors merged commit 2f601ef into rust-lang:master Jun 2, 2021
@rustbot rustbot added this to the 1.54.0 milestone Jun 2, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
merged-by-bors This PR was explicitly merged by bors. S-waiting-on-bors Status: Waiting on bors to run and complete tests. Bors will change the label on completion.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

7 participants