diff options
| author | bors <bors@rust-lang.org> | 2021-11-08 13:38:08 +0000 |
|---|---|---|
| committer | bors <bors@rust-lang.org> | 2021-11-08 13:38:08 +0000 |
| commit | 495322d776fd6f679cd8cd4ca02b8fa834da654b (patch) | |
| tree | f74962afead566a9cdafeb4da75619a3f829ae9b | |
| parent | 3e3890c9d4064253aaa8c51f5d5458d2dc6dab77 (diff) | |
| parent | 49e7c993ee4ab98f53898685394e9c2b3fa954dc (diff) | |
| download | rust-495322d776fd6f679cd8cd4ca02b8fa834da654b.tar.gz rust-495322d776fd6f679cd8cd4ca02b8fa834da654b.zip | |
Auto merge of #90361 - Mark-Simulacrum:always-verify, r=michaelwoerister
Enable verification for 1/32th of queries loaded from disk This is a limited enabling of incremental verification for query results loaded from disk, which previously did not run without -Zincremental-verify-ich. If enabled for all queries, we see a probably unacceptable hit of ~50% in the worst case, so this pairs back the verification to a more limited set based on the hash key. Per collected [perf results](https://github.com/rust-lang/rust/pull/84227#issuecomment-953350582), this is a regression of at most 7% on coercions opt incr-unchanged, and typically less than 0.5% on other benchmarks (largely limited to incr-unchanged). I believe this is acceptable performance to land, and we can either ratchet it up or down fairly easily. We have no real sense of whether this will lead to a large amount of assertions in the wild, but since those assertions may lead to miscompilations today, it seems potentially warranted. We have a good bit of lead time until the next stable release, though the holiday season will also start soon; we may wish to discuss the timing of enabling this and weigh the desire to prevent (possible) miscompilations against assertions. cc `@rust-lang/wg-incr-comp`
| -rw-r--r-- | compiler/rustc_query_system/src/query/plumbing.rs | 15 |
1 files changed, 14 insertions, 1 deletions
diff --git a/compiler/rustc_query_system/src/query/plumbing.rs b/compiler/rustc_query_system/src/query/plumbing.rs index 238b92a6134..9703f0c3d96 100644 --- a/compiler/rustc_query_system/src/query/plumbing.rs +++ b/compiler/rustc_query_system/src/query/plumbing.rs @@ -518,9 +518,22 @@ where prof_timer.finish_with_query_invocation_id(dep_node_index.into()); if let Some(result) = result { + let prev_fingerprint = tcx + .dep_context() + .dep_graph() + .prev_fingerprint_of(dep_node) + .unwrap_or(Fingerprint::ZERO); // If `-Zincremental-verify-ich` is specified, re-hash results from // the cache and make sure that they have the expected fingerprint. - if unlikely!(tcx.dep_context().sess().opts.debugging_opts.incremental_verify_ich) { + // + // If not, we still seek to verify a subset of fingerprints loaded + // from disk. Re-hashing results is fairly expensive, so we can't + // currently afford to verify every hash. This subset should still + // give us some coverage of potential bugs though. + let try_verify = prev_fingerprint.as_value().1 % 32 == 0; + if unlikely!( + try_verify || tcx.dep_context().sess().opts.debugging_opts.incremental_verify_ich + ) { incremental_verify_ich(*tcx.dep_context(), &result, dep_node, query); } |
