Skip to content

Commit 495322d

Browse files
committed
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](#84227 (comment)), 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`
2 parents 3e3890c + 49e7c99 commit 495322d

File tree

1 file changed

+14
-1
lines changed

1 file changed

+14
-1
lines changed

Diff for: compiler/rustc_query_system/src/query/plumbing.rs

+14-1
Original file line numberDiff line numberDiff line change
@@ -518,9 +518,22 @@ where
518518
prof_timer.finish_with_query_invocation_id(dep_node_index.into());
519519

520520
if let Some(result) = result {
521+
let prev_fingerprint = tcx
522+
.dep_context()
523+
.dep_graph()
524+
.prev_fingerprint_of(dep_node)
525+
.unwrap_or(Fingerprint::ZERO);
521526
// If `-Zincremental-verify-ich` is specified, re-hash results from
522527
// the cache and make sure that they have the expected fingerprint.
523-
if unlikely!(tcx.dep_context().sess().opts.debugging_opts.incremental_verify_ich) {
528+
//
529+
// If not, we still seek to verify a subset of fingerprints loaded
530+
// from disk. Re-hashing results is fairly expensive, so we can't
531+
// currently afford to verify every hash. This subset should still
532+
// give us some coverage of potential bugs though.
533+
let try_verify = prev_fingerprint.as_value().1 % 32 == 0;
534+
if unlikely!(
535+
try_verify || tcx.dep_context().sess().opts.debugging_opts.incremental_verify_ich
536+
) {
524537
incremental_verify_ich(*tcx.dep_context(), &result, dep_node, query);
525538
}
526539

0 commit comments

Comments
 (0)