Skip to content
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

track incr. comp. dependencies across crates #33476

Merged
merged 21 commits into from
May 18, 2016

Conversation

nikomatsakis
Copy link
Contributor

This PR refactors the compiler's incremental compilation hashing so that it can track dependencies across crates. The main bits are:

  • computing a hash representing the metadata for an item we are emitting
    • we do this by making MetaData(X) be the current task while computing metadata for an item
    • this naturally registers reads from any tables and things that we read for that purpose
    • we can then hash all the inputs to those tables
  • tracking when we access metadata
    • we do this by registering a read of MetaData(X) for each foreign item X whose metadata we read
  • hashing metadata from foreign items
    • we do this by loading up metadata from a file in the incr. comp. directory
    • if there is no file, we use the SVH for the entire crate

There is one very simple test only at this point. The next PR will be focused on expanding out the tests.

Note that this is based on top of #33228

r? @michaelwoerister

// we walk the predecessors of `MetaData(X)` from the
// dep-graph. This corresponds to all the inputs that were read to
// construct the metadata. To create the hash for the metadata, we
// hash (the hash of) all of those inputs.
Copy link
Member

Choose a reason for hiding this comment

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

This is nice indeed, I like it.

@bors
Copy link
Contributor

bors commented May 8, 2016

☔ The latest upstream changes (presumably #33091) made this pull request unmergeable. Please resolve the merge conflicts.

@michaelwoerister
Copy link
Member

Note that this is based on top of #33228

Since that has landed already, could you remove those commits from this PR? That would also make it easier to review since Github won't show a merged diff because there are too many changed files.

@nikomatsakis
Copy link
Contributor Author

@michaelwoerister will do so once this flight lands :)

@nikomatsakis nikomatsakis force-pushed the incr-comp-xcrate branch 2 times, most recently from 7aa973e to 1853f26 Compare May 9, 2016 22:35
@nikomatsakis
Copy link
Contributor Author

@michaelwoerister rebased :)

@bors
Copy link
Contributor

bors commented May 10, 2016

☔ The latest upstream changes (presumably #33443) made this pull request unmergeable. Please resolve the merge conflicts.

// node each time we pull the information for an item out of the
// crate store.
MetaData(D),

// Represents different phases in the compiler.
CrateReader,
CollectLanguageItems,
Copy link
Member

Choose a reason for hiding this comment

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

This commit looks good.

@bors
Copy link
Contributor

bors commented May 11, 2016

☔ The latest upstream changes (presumably #33425) made this pull request unmergeable. Please resolve the merge conflicts.

@nikomatsakis
Copy link
Contributor Author

OK, so I was able to capture a stack trace in VMWare (this was...not easy). It had nothing to do w/ a stack overflow. Rather, I think that the error code I was seeing was being produced by the span_bug code, or perhaps cargo or rust-build's response to the message. The actual problem is that link_binary needed a dep-graph task now. Will rebase.

This got removed at some point, it seems.
Conflicts:
	src/librustc_metadata/csearch.rs
This lets us determine what was used to construct the metadata.

Conflicts:
	src/librustc_metadata/encoder.rs
This way, multiple compilations can share the same work directory.
Generate a second hash file that contains the metadata for an X node.
we need them to be able to retrace.
This is needed for incremental compilation harness to support
cross-crate testing. Also support cfg for typechecking prettyprint
We used to store a u64 converted to a String for some reason. Now we
don't.
Create some re-usable filtering subroutines.
For external crates, we must build up a map that goes from
the DefKey to the DefIndex. We do this by iterating over each
index that is found in the metadata and loading the associated
DefKey.
This commit reorganizes how the persist code treats hashing. The idea is
that each crate saves a file containing hashes representing the metadata
for each item X. When we see a read from `MetaData(X)`, we can load this
hash up (if we don't find a file for that crate, we just use the SVH for
the entire crate).

To compute the hash for `MetaData(Y)`, where Y is some local item, we
examine all the predecessors of the `MetaData(Y)` node and hash their
hashes together.
In MSVC (at least), linking requires accessing metadata, which generates
reads.
@nikomatsakis
Copy link
Contributor Author

@bors r=mw

@bors
Copy link
Contributor

bors commented May 18, 2016

📌 Commit f860f8b has been approved by mw

@michaelwoerister
Copy link
Member

Wow, that sounds super annoying! 😬

@bors
Copy link
Contributor

bors commented May 18, 2016

⌛ Testing commit f860f8b with merge 9a14045...

bors added a commit that referenced this pull request May 18, 2016
track incr. comp. dependencies across crates

This PR refactors the compiler's incremental compilation hashing so that it can track dependencies across crates. The main bits are:

- computing a hash representing the metadata for an item we are emitting
  - we do this by making `MetaData(X)` be the current task while computing metadata for an item
  - this naturally registers reads from any tables and things that we read for that purpose
  - we can then hash all the inputs to those tables
- tracking when we access metadata
  - we do this by registering a read of `MetaData(X)` for each foreign item `X` whose metadata we read
- hashing metadata from foreign items
  - we do this by loading up metadata from a file in the incr. comp. directory
  - if there is no file, we use the SVH for the entire crate

There is one very simple test only at this point. The next PR will be focused on expanding out the tests.

Note that this is based on top of #33228

r? @michaelwoerister
@bors bors merged commit f860f8b into rust-lang:master May 18, 2016
@nikomatsakis nikomatsakis deleted the incr-comp-xcrate branch October 3, 2016 14:55
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants