-
Notifications
You must be signed in to change notification settings - Fork 12.9k
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
Introduce HashStable trait and base ICH implementations on it. #40878
Conversation
Those travis errors seem to indicate that something went wrong when rebasing ontop of the |
So, I can reliably reproduce these errors but I can't see how the changes in this PR would have an effect like that |
OK, the problem was that those tests where exercising code paths that would try to hash the DefPath of NodeIds that don't have a corresponding DefId. |
☔ The latest upstream changes (presumably #40597) made this pull request unmergeable. Please resolve the merge conflicts. |
This latest error is legitimate (the SVH is more sensitive than it needs to be) and I figured out that impl specialization offers a way of solving this in a nice and general way, that also allows for reverting the splitting-out of dep_graph_assert attrs. Please hold off on reviewing until I've done that. |
4589028
to
7684437
Compare
Alright, this passes |
@bors r+ |
📌 Commit 7684437 has been approved by |
⌛ Testing commit 7684437 with merge 730547d... |
💔 Test failed - status-travis |
… On Mon, Apr 3, 2017 at 1:58 PM, bors ***@***.***> wrote:
💔 Test failed - status-travis
<https://travis-ci.org/rust-lang/rust/builds/218207848>
—
You are receiving this because you are subscribed to this thread.
Reply to this email directly, view it on GitHub
<#40878 (comment)>, or mute
the thread
<https://github.com/notifications/unsubscribe-auth/AAD95Hw_765vUX8-pAsyVO_JYkh0wlPFks5rsU9WgaJpZM4MrxhQ>
.
|
Introduce HashStable trait and base ICH implementations on it. This PR introduces the `HashStable` trait which marks that a type can be hashed in a way that is stable across multiple compilation sessions. The PR also moves HIR incr. comp. hashing over to implementations of this trait instead of doing this via a HIR visitor. It also provides many `HashStable` implementations that are not used yet (e.g. for MIR types) but soon will be used when we directly hash crate metadata for incr. comp. I've only done superficial performance measurements but it looks like the new implementation is a bit faster than the current one (due, I suppose, to some bugs I fixed and some unnecessary inefficiencies I removed). Here is the time in seconds for the `compute_incremental_hashes_map` pass for various crates: | | OLD | NEW | |:---------------:|:-----:|:-----:| | libcore | 0.507 | 0.409 | | libsyntax | 0.320 | 0.260 | | librustc | 0.730 | 0.611 | | librustc_driver | 0.024 | 0.015 | Some notes regarding the implementation: * Most `HashStable` implementations are provided via the `impl_hash_stable_for!` macro (as suggested by @nikomatsakis). This works out quite well. A custom_derive would have been better but Macros 1.1 are not available in the compiler. * The trait implementation take care to exhaustively destructure everything they hash so that fields added in the future don't fall through the cracks. This is a bit verbose but I think it's well worth the trouble since we've had quite a few issues with missing fields or visitor callbacks in this area in the past. Most of it is behind the macro anyway. cc @rust-lang/compiler r? @nikomatsakis
Ran into an issue with this PR in the rollup https://travis-ci.org/rust-lang/rust/jobs/219131927 @bors r- |
Looks like a minor merge thing-y:
|
In particular I renamed |
This initial commit provides implementations for HIR, MIR, and everything that also needs to be supported for those two.
@bors r=nikomatsakis Rebased. |
📌 Commit c47cdc0 has been approved by |
Introduce HashStable trait and base ICH implementations on it. This PR introduces the `HashStable` trait which marks that a type can be hashed in a way that is stable across multiple compilation sessions. The PR also moves HIR incr. comp. hashing over to implementations of this trait instead of doing this via a HIR visitor. It also provides many `HashStable` implementations that are not used yet (e.g. for MIR types) but soon will be used when we directly hash crate metadata for incr. comp. I've only done superficial performance measurements but it looks like the new implementation is a bit faster than the current one (due, I suppose, to some bugs I fixed and some unnecessary inefficiencies I removed). Here is the time in seconds for the `compute_incremental_hashes_map` pass for various crates: | | OLD | NEW | |:---------------:|:-----:|:-----:| | libcore | 0.507 | 0.409 | | libsyntax | 0.320 | 0.260 | | librustc | 0.730 | 0.611 | | librustc_driver | 0.024 | 0.015 | Some notes regarding the implementation: * Most `HashStable` implementations are provided via the `impl_hash_stable_for!` macro (as suggested by @nikomatsakis). This works out quite well. A custom_derive would have been better but Macros 1.1 are not available in the compiler. * The trait implementation take care to exhaustively destructure everything they hash so that fields added in the future don't fall through the cracks. This is a bit verbose but I think it's well worth the trouble since we've had quite a few issues with missing fields or visitor callbacks in this area in the past. Most of it is behind the macro anyway. cc @rust-lang/compiler r? @nikomatsakis
Introduce HashStable trait and base ICH implementations on it. This PR introduces the `HashStable` trait which marks that a type can be hashed in a way that is stable across multiple compilation sessions. The PR also moves HIR incr. comp. hashing over to implementations of this trait instead of doing this via a HIR visitor. It also provides many `HashStable` implementations that are not used yet (e.g. for MIR types) but soon will be used when we directly hash crate metadata for incr. comp. I've only done superficial performance measurements but it looks like the new implementation is a bit faster than the current one (due, I suppose, to some bugs I fixed and some unnecessary inefficiencies I removed). Here is the time in seconds for the `compute_incremental_hashes_map` pass for various crates: | | OLD | NEW | |:---------------:|:-----:|:-----:| | libcore | 0.507 | 0.409 | | libsyntax | 0.320 | 0.260 | | librustc | 0.730 | 0.611 | | librustc_driver | 0.024 | 0.015 | Some notes regarding the implementation: * Most `HashStable` implementations are provided via the `impl_hash_stable_for!` macro (as suggested by @nikomatsakis). This works out quite well. A custom_derive would have been better but Macros 1.1 are not available in the compiler. * The trait implementation take care to exhaustively destructure everything they hash so that fields added in the future don't fall through the cracks. This is a bit verbose but I think it's well worth the trouble since we've had quite a few issues with missing fields or visitor callbacks in this area in the past. Most of it is behind the macro anyway. cc @rust-lang/compiler r? @nikomatsakis
⌛ Testing commit c47cdc0 with merge 14d938b... |
💔 Test failed - status-appveyor |
…shes, r=nikomatsakis Handle DefPath hashing centrally as part of DefPathTable (+ save work during SVH calculation) In almost all cases where we construct a `DefPath`, we just hash it and throw it away again immediately. With this PR, the compiler will immediately compute and store the hash for each `DefPath` as it is allocated. This way we + can get rid of any subsequent `DefPath` hash caching (e.g. the `DefPathHashes`), + don't need to allocate a transient `Vec` for holding the `DefPath` (although I'm always surprised how little these small, dynamic allocations seem to hurt performance), and + we don't hash `DefPath` prefixes over and over again. That last part is because we construct the hash for `prefix::foo` by hashing `(hash(prefix), foo)` instead of hashing every component of prefix. The last commit of this PR is pretty neat, I think: ``` The SVH (Strict Version Hash) of a crate is currently computed by hashing the ICHes (Incremental Computation Hashes) of the crate's HIR. This is fine, expect that for incr. comp. we compute two ICH values for each HIR item, one for the complete item and one that just includes the item's interface. The two hashes are are needed for dependency tracking but if we are compiling non-incrementally and just need the ICH values for the SVH, one of them is enough, giving us the opportunity to save some work in this case. ``` r? @nikomatsakis This PR depends on rust-lang#40878 to be merged first (you can ignore the first commit for reviewing, that's just rust-lang#40878).
This PR introduces the
HashStable
trait which marks that a type can be hashed in a way that is stable across multiple compilation sessions. The PR also moves HIR incr. comp. hashing over to implementations of this trait instead of doing this via a HIR visitor. It also provides manyHashStable
implementations that are not used yet (e.g. for MIR types) but soon will be used when we directly hash crate metadata for incr. comp.I've only done superficial performance measurements but it looks like the new implementation is a bit faster than the current one (due, I suppose, to some bugs I fixed and some unnecessary inefficiencies I removed). Here is the time in seconds for the
compute_incremental_hashes_map
pass for various crates:Some notes regarding the implementation:
HashStable
implementations are provided via theimpl_hash_stable_for!
macro (as suggested by @nikomatsakis). This works out quite well. A custom_derive would have been better but Macros 1.1 are not available in the compiler.cc @rust-lang/compiler
r? @nikomatsakis