Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions changelog.d/duplicates-scan-race-budget.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
### Fixed
- **Duplicate review timing test no longer fails under the race detector**: its 100ms budget now scales when the race detector is on. No change to how Bindery behaves.
10 changes: 8 additions & 2 deletions internal/duplicates/duplicates_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -581,8 +581,14 @@ func TestScanScale(t *testing.T) {
groups := Scan(books, nil)
elapsed := time.Since(start)

if elapsed > 100*time.Millisecond {
t.Errorf("Scan(500 books) took %s, budget 100ms", elapsed)
// The race detector slows Scan several fold, so the budget scales with it;
// a fixed 100ms failed on a shared CI runner under -race.
budget := 100 * time.Millisecond
if raceEnabled {
budget *= 10
}
if elapsed > budget {
t.Errorf("Scan(500 books) took %s, budget %s", elapsed, budget)
}
if len(groups) != 2 {
t.Fatalf("Scan = %d groups, want 2", len(groups))
Expand Down
5 changes: 5 additions & 0 deletions internal/duplicates/race_off_test.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
//go:build !race

package duplicates

const raceEnabled = false
7 changes: 7 additions & 0 deletions internal/duplicates/race_on_test.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
//go:build race

package duplicates

// raceEnabled reports whether the race detector is on. It slows Scan several
// fold, so wall clock budgets scale with it.
const raceEnabled = true
Loading