Skip to content

incr.comp.: Use DefPathHash-based DepNodes in the serialized DepGraph and remove obsolete DefIdDirectory #42332

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 5 commits into from
Jun 3, 2017

Conversation

michaelwoerister
Copy link
Member

With this PR we don't store the dep-graph as a set of DepNode<IndexIntoDefIdDirectory> anymore but instead as a set of DepNode<DefPathHash>. Since a DefPathHash is a global identifier that is valid across compilation sessions, we don't need the DefIdDirectory anymore.

Since a DepNode<DefPathHash> is bigger than a DepNode<IndexIntoDefIdDirectory> and our on-disk encoding of the dep-graph is inefficient, this PR will probably increase the amount of space the dep-graph takes up on disk. I'm in the process of gathering some performance data.

The changes in here are a step towards implementing ICH-based DepNodes (#42294).

r? @nikomatsakis

@michaelwoerister
Copy link
Member Author

Some numbers for compiling ripgrep:

New implementation

  • initial runs = 24.81s 24.85s 24.72s
  • re-runs = 4.97s 4.91s 4.88s
  • rg-depgraph = 6.0 MB
  • grep-depgraph = 2.2 MB

Current implementation

  • initial run = 24.82s 24.98s 24.88s
  • re-run = 4.98s 4.87s 4.91s
  • rg-depgraph = 4.0 MB
  • grep-depgraph = 1.1 MB

I'd say the timings are pretty much equivalent. The on-disk graph gets bigger though. I'll look into a more efficient on-disk representation (which should be pretty similar to what we soon want to do anyway).

@aidanhs aidanhs added the S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. label Jun 1, 2017
@michaelwoerister
Copy link
Member Author

One more thing: This change slightly regresses the output of Zincremental-info because it will show incremental: module XYZ is dirty because DepNode::Hir(<some opaque hash value>) changed or was removed in the case of an item having been removed. For things that just have changed, you still get to see the DefPath and for removed things you at least get to see the kind of DepNode.

This could be fixed by storing some additional information with the DepGraph in case -Zincremental-info or -Zquery-dep-graph is passed. But I don't think it's an urgent problem.

@michaelwoerister
Copy link
Member Author

OK, I have a proof of concept implementation of a new dep-graph encoding:

New DepGraph Encoding

  • initial runs = 24.55s 24.75s 24.76s
  • re-runs = 4.68s 4.67s 4.71s
  • rg-depgraph = 2.4 MB
  • grep-depgraph = 1.1 MB

Looks like that slightly improves re-build times and uses less space than before the PR. I'll clean it up and push it.

@michaelwoerister
Copy link
Member Author

Ready for review.

Copy link
Contributor

@nikomatsakis nikomatsakis left a comment

Choose a reason for hiding this comment

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

I'm a bit confused how LOCAL_CRATE works, but presumably it does, and I just have to reskim the code. This looks nice.

We should discuss whether we expect DepNode<N> to remain, or be subsumed into QueryKey, etc.

@@ -676,6 +680,40 @@ impl<'a, 'gcx, 'tcx> TyCtxt<'a, 'gcx, 'tcx> {
let max_cnum = s.cstore.crates().iter().map(|c| c.as_usize()).max().unwrap_or(0);
let mut providers = IndexVec::from_elem_n(extern_providers, max_cnum + 1);
providers[LOCAL_CRATE] = local_providers;

let def_path_hash_to_def_id = if s.opts.build_dep_graph() {
Copy link
Contributor

Choose a reason for hiding this comment

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

seems like a good place for a comment kind of explaining roughly what this table is for -- but a question: does this include only foreign crates? I don't see where it adds LOCAL_CRATE to the table...

Copy link
Member Author

Choose a reason for hiding this comment

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

The local crate is added below via chain()

@nikomatsakis
Copy link
Contributor

@bors r+

@bors
Copy link
Collaborator

bors commented Jun 1, 2017

📌 Commit a3417bf has been approved by nikomatsakis

@bors
Copy link
Collaborator

bors commented Jun 3, 2017

⌛ Testing commit a3417bf with merge 2f2d741...

bors added a commit that referenced this pull request Jun 3, 2017
…akis

incr.comp.: Use DefPathHash-based DepNodes in the serialized DepGraph and remove obsolete DefIdDirectory

With this PR we don't store the dep-graph as a set of `DepNode<IndexIntoDefIdDirectory>` anymore but instead as a set of `DepNode<DefPathHash>`. Since a `DefPathHash` is a global identifier that is valid across compilation sessions, we don't need the `DefIdDirectory` anymore.

Since a `DepNode<DefPathHash>` is bigger than a `DepNode<IndexIntoDefIdDirectory>` and our on-disk encoding of the dep-graph is inefficient, this PR will probably increase the amount of space the dep-graph takes up on disk. I'm in the process of gathering some performance data.

The changes in here are a step towards implementing ICH-based `DepNodes` (#42294).

r? @nikomatsakis
@bors
Copy link
Collaborator

bors commented Jun 3, 2017

☀️ Test successful - status-appveyor, status-travis
Approved by: nikomatsakis
Pushing 2f2d741 to master...

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
S-waiting-on-review Status: Awaiting review from the assignee but also interested parties.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants