Skip to content

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

Merged
robzolkos merged 1 commit into
mainfrom
test/race-small-linear-inputs
Oct 12, 2026
Merged

robzolkos merged 1 commit into
mainfrom
test/race-small-linear-inputs

Conversation

@robzolkos

@robzolkos robzolkos commented Oct 12, 2026 •

Copy link
Copy Markdown
Contributor

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)

Before After
go test -race -count=1 ./... (after: with -shuffle=on) 66.3s 39.0s
internal/markdown under -race 64.0s 13.2s
TestFindBareLinksPastRejectedPrefixesIsLinear, -race 43.95s 4.39s
TestFindBareLinksInALongUnspacedParagraphIsLinear, -race 12.90s 1.31s
same two tests, no -race (full size) 2.71s / 0.81s 2.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.

@robzolkos
robzolkos requested a review from a team as a code owner October 12, 2026 17:27
Copilot AI balanced review requested due to automatic review settings October 12, 2026 17:27
@github-actions

Copy link
Copy Markdown

Sensitive Change Detection (shadow mode)

This PR modifies control-plane files:

  • .github/workflows/test.yml

Shadow mode — this check is informational only. When activated, changes to these paths will require approval from a maintainer.

@cubic-dev-ai cubic-dev-ai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

View guided diff | Turn on auto-fix | Re-trigger cubic

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟢 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 run gh pr ready --undo.
Click "Ready for review" or run gh pr ready to 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.

Base automatically changed from ci/faster-feedback to main October 12, 2026 17:48
… 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.
@robzolkos
robzolkos force-pushed the test/race-small-linear-inputs branch from c84e6d3 to 7a0698d Compare October 12, 2026 18:04
@robzolkos
robzolkos merged commit e386157 into main Oct 12, 2026
25 checks passed
@robzolkos
robzolkos deleted the test/race-small-linear-inputs branch October 12, 2026 18:07
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants