diff --git a/cmd/bd/prune_bench_test.go b/cmd/bd/prune_bench_test.go index de51fd788..890d33860 100644 --- a/cmd/bd/prune_bench_test.go +++ b/cmd/bd/prune_bench_test.go @@ -97,8 +97,12 @@ func TestPruneLargeFixture(t *testing.T) { t.Fatalf("buildReferencedSet error: %v", err) } - // Performance assertion (NFR-02). - if elapsed > maxDurationSeconds*time.Second { + // Performance assertion (NFR-02). The race detector adds multi-x overhead + // that invalidates a wall-clock budget (buildReferencedSet measures ~4x + // slower under -race), so only enforce the bound in non-race builds. The + // correctness assertions below still run under -race, which is where the + // large-fixture pass earns its keep as a data-race check. + if !raceEnabled && elapsed > maxDurationSeconds*time.Second { t.Errorf("buildReferencedSet took %v; must complete in <%ds on 10K-bead fixture", elapsed, maxDurationSeconds) } diff --git a/cmd/bd/race_detector_off_test.go b/cmd/bd/race_detector_off_test.go new file mode 100644 index 000000000..497fdd3b1 --- /dev/null +++ b/cmd/bd/race_detector_off_test.go @@ -0,0 +1,6 @@ +//go:build !race + +package main + +// raceEnabled is false in non-race builds; see race_detector_on_test.go. +const raceEnabled = false diff --git a/cmd/bd/race_detector_on_test.go b/cmd/bd/race_detector_on_test.go new file mode 100644 index 000000000..a0e1930eb --- /dev/null +++ b/cmd/bd/race_detector_on_test.go @@ -0,0 +1,9 @@ +//go:build race + +package main + +// raceEnabled reports whether the test binary was built with the race +// detector (-race). Wall-clock performance budgets are unreliable under +// race instrumentation (it adds multi-x overhead), so timing-sensitive +// benches consult this flag before enforcing a duration bound. +const raceEnabled = true