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

Save/load incremental compilation dep graph #32016

Merged
merged 19 commits into from
Apr 7, 2016

Conversation

nikomatsakis
Copy link
Contributor

Contains the code to serialize/deserialize the dep graph to disk between executions. We also hash the item contents and compare to the new hashes. Also includes a unit test harness. There are definitely some known limitations, such as #32014 and #32015, but I am leaving those for follow-up work.

Note that this PR builds on #32007, so the overlapping commits can be excluded from review.

r? @michaelwoerister

@nikomatsakis
Copy link
Contributor Author

Ah, I forgot about the impl variant thing. We may not want to merge this just yet until 61202ad is solved in some better way, since people will complain about their symbol names. :)

@alexcrichton
Copy link
Member

📫

@nikomatsakis
Copy link
Contributor Author

Doing a quick rebase now.

@nikomatsakis
Copy link
Contributor Author

@michaelwoerister argh -- I forgot when we were just talking about the "symbol names for impl" business. I should probably fix that before we land this PR. Still not sure of the best way to do so though, I'll have to think about it. Maybe I can do some quick hack so things are "no worse" than today.

@michaelwoerister
Copy link
Member

I've taken a look at the Itanium C++ ABI symbol mangling scheme (which GCC uses) and it does not seem to support something like <Type as Trait>::method. It might be easier to do Trait<SelfType, T1, T2>::method. I have not done any concrete experiments on what tools actually support yet though...

@bors
Copy link
Contributor

bors commented Mar 6, 2016

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

@nikomatsakis
Copy link
Contributor Author

Sigh. I wish they had just used something generic like URL-encoding.

@nikomatsakis
Copy link
Contributor Author

@michaelwoerister

The comments above say that revision have to start with "pass" or "fail" instead of "rpass" or "cfail", etc. Or is this something different?

Just out of date, I think.

@michaelwoerister
Copy link
Member

I've done a first pass over the PR. In general it looks good to me. The incremental test framework looks pretty neat. But I have to do another, more in-depth, reading of the code, especially the dep-graph serialization.
But it seems that there's still quite a few smaller things to do before this passes make check anyway.

One thing that I noticed was that there are some changes that show up one or two commits early, so that those commits won't compile. Do we have some policy on this? Should each commit be valid on its own?

@nikomatsakis
Copy link
Contributor Author

One thing that I noticed was that there are some changes that show up one or two commits early, so that those commits won't compile. Do we have some policy on this? Should each commit be valid on its own?

AFAIK, we don't, and they need not be. We can still easily bisect using the bors merge commits. I just tried to break it up into logical steps for your convenience -- but I don't think I'll go back and make fake history just to ensure that everything builds at each step (the real history was ... a bit convoluted).

@bors
Copy link
Contributor

bors commented Mar 9, 2016

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

@nikomatsakis
Copy link
Contributor Author

@michaelwoerister so I'm rebasing this atop your other PR and making various adjustments. Will ping you when ready.

@nikomatsakis nikomatsakis force-pushed the incr-comp-save branch 2 times, most recently from 59cff17 to 14023bb Compare March 19, 2016 00:03
@nikomatsakis nikomatsakis force-pushed the incr-comp-save branch 2 times, most recently from ed9b2ad to cf8c869 Compare March 25, 2016 21:14
@bors
Copy link
Contributor

bors commented Mar 27, 2016

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

@nikomatsakis nikomatsakis force-pushed the incr-comp-save branch 2 times, most recently from 38eae85 to 4a0e984 Compare March 28, 2016 23:19
@nikomatsakis
Copy link
Contributor Author

ping @michaelwoerister rebased and ready for re-review :) -- as before the commits are not truly standalone, but hopefully broken up enough to give you some sense of the major pieces

@michaelwoerister
Copy link
Member

Thanks for the notification. I try to do the review this week.

@bors
Copy link
Contributor

bors commented Mar 30, 2016

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

@michaelwoerister
Copy link
Member

Going to take a look at this today...


"crate_disambiguator".hash(&mut state);
crate_disambiguator.len().hash(&mut state);
crate_disambiguator.hash(&mut state);
crate_disambiguator.as_str().len().hash(&mut state);
Copy link
Member

Choose a reason for hiding this comment

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

We might get into trouble here with endianess.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@michaelwoerister I guess we should discuss the role of the SVH. I see it as being used for two purposes:

  1. to drive incr. comp.; for this role, endian-ness is no problem
  2. to check for duplicate versions of a crate; here it's a bit less clear, endianness could be an issue in the sense that compiling the same source could produce distinct hashes on different host architectures.

I am somewhat...surprised to see that write_usize for hashes does seem to convert to a [u8; 4]. Crazy.

I guess we can write a "endian-proof" wrapper, though there is also code which converts &[usize] to &[u8], which would be harder.

Copy link
Member

Choose a reason for hiding this comment

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

I'm not sure if it's a good idea to re-use the SVH for incremental compilation. It's something with a specific purpose (2) and trying to make it hit two goals at once might just make it more complicated. The other way round though, re-using a well-defined incremental compilation hash when computing the SVH makes more sense to me.

ad endianess: Yes, for incremental compilation it doesn't make a difference. For the other case: I guess you can never have two crates with differing endianess in the your crate graph. So, in the end it should not matter in either case. It's more of code smell than a bug anyway.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

On Mon, Apr 04, 2016 at 08:48:39AM -0700, Michael Woerister wrote:

     "crate_disambiguator".hash(&mut state);
  •    crate_disambiguator.len().hash(&mut state);
    
  •    crate_disambiguator.hash(&mut state);
    
  •    crate_disambiguator.as_str().len().hash(&mut state);
    

I'm not sure if it's a good idea to re-use the SVH for incremental compilation. It's something with a specific purpose (2) and trying to make it hit two goals at once might just make it more complicated. The other way round though, re-using a well-defined incremental compilation hash when computing the SVH makes more sense to me.

I agree that the SVH as originally envisioned is not what we want --
for one thing, it tries to have some (broken) notion of not hashing
things that do not affect "ABI compatibilty". I think there is no use
for the existing SVH. I am basically taking it over and repurposing
it. I should rename it to "ICH" (incr. comp. hash), probably. But the
current names seems also not inappropriate.

Do you think that it's worth retaining the "SVH as it exists today"?

ad endianess: Yes, for incremental compilation it doesn't make a
difference. For the other case: I guess you can never have two
crates with differing endianess in the your crate graph. So, in the
end it should not matter in either case. It's more of code smell
than a bug anyway.

well, what I was concerned about is that you cross-compile the library
on one machine. then copy it somewhere else. then recompile something
it depends on on that local machine. now if the endianness's differ
rustc may get whiny, even though same toolchain/version/everything was
used, because the SVH recorded in the (cross-compiled) crate is
different from the one that is found in the (locally) compiled dep.
Admittedly this scenario seems a bit far fetched and like something
that can be relegated to a FIXME.

Niko

Copy link
Member

Choose a reason for hiding this comment

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

what I was concerned about is that you cross-compile the library

That's true. I think, I would just fix it with something like: (crate_disambiguator.as_str().len() as u64).to_le().hash(...)

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Hmm, ok

On Mon, Apr 04, 2016 at 10:00:47AM -0700, Michael Woerister wrote:

     "crate_disambiguator".hash(&mut state);
  •    crate_disambiguator.len().hash(&mut state);
    
  •    crate_disambiguator.hash(&mut state);
    
  •    crate_disambiguator.as_str().len().hash(&mut state);
    

    what I was concerned about is that you cross-compile the library

That's true. I think, I would just fix it with something like: (crate_disambiguator.as_str().len() as u64).to_le().hash(...)


You are receiving this because you authored the thread.
Reply to this email directly or view it on GitHub:
https://github.com/rust-lang/rust/pull/32016/files/601f8c66256df0d4d1fe2ec3d3f617a6fae08f68..aa5eca284c2e220cac461a5626a559690f664fe6#r58409485

Copy link
Member

Choose a reason for hiding this comment

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

Although I admit that's one ugly line of code that really asks to be hidden behind some kind of utility function at some point.

@nikomatsakis
Copy link
Contributor Author

@bors r=michaelwoerister

@bors
Copy link
Contributor

bors commented Apr 6, 2016

📌 Commit 54d78a4 has been approved by michaelwoerister

@bors
Copy link
Contributor

bors commented Apr 6, 2016

⌛ Testing commit 54d78a4 with merge fd7614e...

@bors
Copy link
Contributor

bors commented Apr 7, 2016

💔 Test failed - auto-linux-64-opt-rustbuild

@nikomatsakis
Copy link
Contributor Author

@bors r=mw

@bors
Copy link
Contributor

bors commented Apr 7, 2016

📌 Commit 29ad9a2 has been approved by mw

@bors
Copy link
Contributor

bors commented Apr 7, 2016

⌛ Testing commit 29ad9a2 with merge 89fbd29...

@bors
Copy link
Contributor

bors commented Apr 7, 2016

💔 Test failed - auto-linux-64-x-freebsd

bors added a commit that referenced this pull request Apr 7, 2016
Rollup of 11 pull requests

- Successful merges: #32016, #32583, #32699, #32729, #32731, #32738, #32741, #32745, #32748, #32757, #32786
- Failed merges: #32773
@nikomatsakis
Copy link
Contributor Author

@bors r=mw

@bors
Copy link
Contributor

bors commented Apr 7, 2016

📌 Commit 9eaae92 has been approved by mw

@bors
Copy link
Contributor

bors commented Apr 7, 2016

⌛ Testing commit 9eaae92 with merge 7979dd6...

bors added a commit that referenced this pull request Apr 7, 2016
Save/load incremental compilation dep graph

Contains the code to serialize/deserialize the dep graph to disk between executions. We also hash the item contents and compare to the new hashes. Also includes a unit test harness. There are definitely some known limitations, such as #32014 and #32015, but I am leaving those for follow-up work.

Note that this PR builds on #32007, so the overlapping commits can be excluded from review.

r? @michaelwoerister
@alexcrichton
Copy link
Member

The android bot disappeared, but all other tests pass, so I'm gonna merge manually.

Praying this actually works for android :)

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