Repository navigation
Shrink two linear-time tests under the race detector, and shuffle the race run - #565
Conversation
Sensitive Change Detection (shadow mode)This PR modifies control-plane files:
|
There was a problem hiding this comment.
No issues found across 4 files
You’re at about 92% of the monthly reviewed-line limit. You may want to disable incremental reviews to conserve quota. Reviews will continue until that limit is exceeded. If you need help avoiding interruptions, please contact contact@cubic.dev.
There was a problem hiding this comment.
🟢 Approved
The scaling remains race-specific, preserves full-size checks elsewhere, and the workflow change is valid.
0 open findings
What changed in this PR
Reduces race-detector runtime while preserving full-size linearity checks in normal test runs.
Changes:
- Scales two adversarial inputs down under
-race. - Randomizes race-test execution order.
[!TIP]
If you aren't ready for review, convert to a draft PR.
Click "Convert to draft" or rungh pr ready --undo.
Click "Ready for review" or rungh pr readyto reengage.
| File | Description |
|---|---|
internal/markdown/bound_test.go |
Defines full-size input scaling. |
internal/markdown/bound_race_test.go |
Defines reduced race-build scaling. |
internal/markdown/bare_links_test.go |
Applies scaling to two linearity tests. |
.github/workflows/test.yml |
Enables shuffled race tests. |
🧠 Review effort: Balanced
💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.
… race run TestFindBareLinksPastRejectedPrefixesIsLinear and TestFindBareLinksInALongUnspacedParagraphIsLinear scan one large string on one goroutine. Under -race they took 44s and 13s, against 2.7s and 0.8s without it, and made internal/markdown the floor of Race Detection while giving the detector nothing to find. A race-tagged linearInputScale now divides their inputs by ten under -race; every build without -race runs them at full size, where the linear-time bound is held. Race Detection also runs with -shuffle=on, so a test that only passes in source order fails there with the seed to reproduce it.
c84e6d3 to
7a0698d
Compare
Builds on Cancel superseded PR test runs, run the suite daily, and cache the race build, which has merged. This branch is rebased onto
mainand holds only its own commit.Two tests made
internal/markdownthe 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 tolinearBound. It is1inbound_test.go(!race) and10inbound_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
-racestill runs them at full size: the Tests job,make testand the release gate's plain run. That is where the linear-time bound is held. The other linear-time tests are unchanged.-shuffle=onon 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)
go test -race -count=1 ./...(after: with-shuffle=on)internal/markdownunder-raceTestFindBareLinksPastRejectedPrefixesIsLinear,-raceTestFindBareLinksInALongUnspacedParagraphIsLinear,-race-race(full size)The last row shows that the full-size path still runs: the times without
-raceare unchanged. The-racerows show the scaled path.internal/cmd(~37s) is now the longest package under-race. In CI,internal/markdowntook 48–84s of Race Detection, so expect the job to lose roughly 35–70s there (estimated).Checks
make fmt-check vet tidy-check check-release-lockstep check-surface coveragepass (coverage 85.97% against the 70.8% floor).go test -race -shuffle=on -count=1 ./...passed on three shuffle seeds.actionlintis clean.