Skip to content

Commit 59dbb8c

Browse files
Enable verification for 1/32th of queries loaded from disk
1 parent c7a30c8 commit 59dbb8c

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
@@ -520,7 +520,20 @@ where
520520
if let Some(result) = result {
521521
// If `-Zincremental-verify-ich` is specified, re-hash results from
522522
// the cache and make sure that they have the expected fingerprint.
523-
if unlikely!(tcx.dep_context().sess().opts.debugging_opts.incremental_verify_ich) {
523+
let prev_fingerprint = tcx
524+
.dep_context()
525+
.dep_graph()
526+
.prev_fingerprint_of(dep_node)
527+
.unwrap_or(Fingerprint::ZERO);
528+
// A fingerprint is 128 bits, and this checks if 5 of those bits are
529+
// zero. If the fingerprint is fully random (as we hope for), this
530+
// should limit us to checking every `2^5`th hash. This reduces the
531+
// number of hashes we check low enough that the overhead of
532+
// verification is acceptable to always enable.
533+
let try_verify = prev_fingerprint.as_value().1 & 0x1f == 0;
534+
if try_verify
535+
|| unlikely!(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)