test(prune): don't enforce wall-clock budget under -race (#4624)
TestPruneLargeFixture's <5s budget is invalid under the race detector (~20s vs ~1.2s). The Main integration cmd/bd shard runs with -race; gate the timing assertion on a build-tag raceEnabled flag so only non-race builds enforce it. Correctness assertions still run under -race.
This commit is contained in:
parent
7a00780777
commit
d84fb1e5ea
3 changed files with 21 additions and 2 deletions
|
|
@ -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)
|
||||
}
|
||||
|
||||
|
|
|
|||
6
cmd/bd/race_detector_off_test.go
Normal file
6
cmd/bd/race_detector_off_test.go
Normal file
|
|
@ -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
|
||||
9
cmd/bd/race_detector_on_test.go
Normal file
9
cmd/bd/race_detector_on_test.go
Normal file
|
|
@ -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
|
||||
Loading…
Add table
Add a link
Reference in a new issue