Shrink two linear-time tests under the race detector, and shuffle the race run

Merged
RO
3d ago
+16-5

Builds on Cancel superseded PR test runs, run the suite daily, and cache the race build, which has merged. This branch is rebased onto main and holds only its own commit.

Two tests made internal/markdown the slowest part of Race Detection. Both check that link scanning stays linear-time on adversarial input, and neither has any concurrency for the race detector to check.

Changes

  • linearInputScale, set by build tag next to linearBound. It is 1 in bound_test.go (!race) and 10 in bound_race_test.go (race). It divides the inputs of the two slow tests:

    • TestFindBareLinksPastRejectedPrefixesIsLinear: 50,000 repeats, or 5,000 under -race.
    • TestFindBareLinksInALongUnspacedParagraphIsLinear: 20,000 links, or 2,000 under -race.

    Both scan one string on one goroutine, and their only goroutine is a timeout wrapper, so the race detector had nothing to find and only multiplied the cost. Every build without -race still runs them at full size: the Tests job, make test and the release gate's plain run. That is where the linear-time bound is held. The other linear-time tests are unchanged.

  • -shuffle=on on the Race Detection run. A test that only passes in source order fails there and prints the seed to reproduce it.

Timings (measured locally, warm cache, 14 cores)

BeforeAfter
go test -race -count=1 ./... (after: with -shuffle=on)66.3s39.0s
internal/markdown under -race64.0s13.2s
TestFindBareLinksPastRejectedPrefixesIsLinear, -race43.95s4.39s
TestFindBareLinksInALongUnspacedParagraphIsLinear, -race12.90s1.31s
same two tests, no -race (full size)2.71s / 0.81s2.68s / 0.80s

The last row shows that the full-size path still runs: the times without -race are unchanged. The -race rows show the scaled path. internal/cmd (~37s) is now the longest package under -race. In CI, internal/markdown took 48–84s of Race Detection, so expect the job to lose roughly 35–70s there (estimated).

Checks

  • Locally:
    • make fmt-check vet tidy-check check-release-lockstep check-surface coverage pass (coverage 85.97% against the 70.8% floor).
    • go test -race -shuffle=on -count=1 ./... passed on three shuffle seeds.
    • golangci-lint v2.14.0 reports 0 issues. The pinned v2.13.1 binary can't type-check against Go 1.27.2 locally, the export-data mismatch noted in Build with Go 1.27.2 and golang.org/x/net v0.60.0.
    • actionlint is clean.