Skip to content

ci: run the race gate in 3 parts on 3 runners - #276

Merged
bketelsen merged 1 commit into
mainfrom
ci/faster-race-detector
Nov 24, 2026
Merged

bketelsen merged 1 commit into
mainfrom
ci/faster-race-detector

Conversation

@bketelsen

Copy link
Copy Markdown
Contributor

Summary

Shortens the "Race detector" check, by far the slowest gate that every pull request waits on (17m46s on #275, 13m37s and 13m44s on the two runs before it), by running the race gate in 3 parts on 3 runners.

One decision to review first (ADR-0048, Proposed). The largest saving comes from leaving checkptr out of modernc.org/... in the simulation's race run, and running checkptr in every package in a second pass with no race detector. Race instrumentation is unchanged, and every check of the old single run still runs on every pull request. What changes: checkptr's checks inside modernc's translated SQLite no longer run in the same process as the race detector during the simulation. If that is not acceptable, the fallback below keeps the old flags and still saves 2.5 to 3.5 minutes.

Where the time went (3 CI runs on 2026-11-24): internal/synctest took 604 to 817 s under race and ran alone to the end of the job; every other package had reported 3.5 to 5.6 minutes in. A CPU profile of 2 scenario tests under race had 43% of its samples in runtime.checkptr*, almost all from modernc.org/sqlite: -race implies checkptr. Verify runs the same package without race in 47 s.

What changes

  • make race is 3 targets, and make ci depends on it:
    • race-rest: go test -race on every package but internal/synctest, with the old flags.
    • race-sim: go test -race on internal/synctest, with checkptr off in modernc.org/... only.
    • race-sim-checkptr: internal/synctest with checkptr in every package and no race detector.
  • CI runs the 3 as a matrix, race-shards. Job race keeps the name "Race detector", needs the shards, runs with if: always() and passes only when their result is success. Branch protection needs no change.
  • A guard, internal/workflowcheck/racegate_test.go: the Makefile's parts and the matrix must agree, each part keeps its flags, and the aggregate keeps its name, needs, always() and its test. 20 mutations are each caught.
  • Docs: ADR-0048, AGENTS.md, README.md, docs/development.md, docs/design/sync.md.

No test, seed or step changes.

Risk tier

Risk tier: 3 — the change matches L2 paths.

  • .github/workflows/** (ci.yml): the race job becomes the matrix job and the aggregate job. The shards keep contents: read, the pinned checkout with persist-credentials: false, setup-go and the module-download retry; the apt step runs only where desktop tests run. The aggregate job has permissions: {} and no checkout. No new action; no other job changes.
  • Makefile: ci depends on the new race target in place of its own go test -race line; verify, check and bump are untouched.
  • internal/workflowcheck/**: the new guard, and the module-download check now reads the race-shards job.

Coverage: race-rest tests 59 of the 60 packages of go list ./..., every one but internal/synctest, which the other 2 parts test.

Docs housekeeping

  • New docs started from their category's TEMPLATE.md
  • Every new doc indexed in docs/README.md
  • Cross-links added in both directions (ADR ↔ design ↔ spec ↔ plan)
  • New significant decision recorded as an ADR first, in this PR
  • Conformance aliases and canonical symlinks are unchanged; canonical targets are edited instead

ADR-0048 is Proposed: merging accepts it, or say what to change.

Verification

  • make check green (host, exit 0)
  • make race-rest (52 ok, 7 with no test files), make race-sim and make race-sim-checkptr: each passes on the host
  • Workflows changed: every action is SHA-pinned with # vX.Y.Z, permissions: {}, and persist-credentials: false
  • Not run: make ci as a whole (ui-check needs the nsl machine), and anything on GitHub's runners.

Measured, on one busy host (4 cores): internal/synctest under race took 380 and 387 s with today's flags and 175 and 189 s with checkptr off in modernc; the checkptr pass with no race detector took 232 s.

Not measured: the job's time on GitHub's runners. This pull request's run is the first. If CI keeps the host's ratios, the slowest shard takes about 7.5 to 9.5 minutes against 13.6 to 17.8 today; that is a projection.

To know

  • Fallback, the 3 shards with the old flags: drop the -gcflags from race-sim, delete race-sim-checkptr, and update the guard's parts and the matrix. It saves about 2.5 to 3.5 minutes.
  • With if: always(), a cancelled run posts a failed "Race detector" on the commit it was superseded on.
  • make ci on a host now runs the simulation twice; its time there is not measured.
  • Not taken: t.Parallel in the simulation (19% in 1 sample, but the worlds would share the CPUs their timeouts count on); -short or fewer seeds under race (less coverage); a race build cache (about 30 s a shard on the host, and it needs actions/cache, which this repository does not use).

Measured before, on 2026-11-24. The Race detector job ran
go test -race -timeout 25m ./... on one runner and took 17m46s on PR #275
(run 45427862610), 13m37s on main (run 45324538062) and 13m44s on PR #274
(run 45322892023). internal/synctest alone took 817 s, 604 s and 617 s of
those runs. The other packages took 649 s, 422 s and 435 s of test time
summed, and those listed before internal/synctest had all reported 3.5 to
5.6 minutes into the step. Verify ran internal/synctest with no race
detector in 47 s.

-race also turns on checkptr. On a developer machine, pinned to 4 cores
while the machine ran other work, internal/synctest took 380 s and 387 s
as the job ran it, 175 s and 189 s with -race and no checkptr in
modernc.org's packages (SQLite as C translated to Go), and 232 s with
checkptr in every package and no race detector.

What changed:

- Makefile: make race is the race gate, and make ci runs it in place of
  its own go test line. Its parts are race-rest (-race on every package
  but internal/synctest, with the old flags), race-sim (-race on
  internal/synctest with -gcflags=modernc.org/...=-d=checkptr=0) and
  race-sim-checkptr (internal/synctest with -gcflags=all=-d=checkptr and
  no -race).
- ci.yml: the race-shards job runs the 3 parts as a matrix, each with
  make race-<shard>. The job named "Race detector" needs it, runs always
  and passes only when every shard passed, so the rulesets that require
  that name need no change. No new action; the shards keep contents: read
  and the new job has no permission.
- internal/workflowcheck: a test fails when make race's parts and the
  matrix differ, when a part loses the race detector, a package or
  checkptr, and when the required check could pass without every shard.
- ADR-0048 (Proposed) records the decision; AGENTS.md, the README and the
  development and sync design docs describe the gate.

Every package and every test still runs under -race, with no fewer seeds
or steps. The checkptr checks in modernc.org's packages during the
simulation still run, but in a process with no race detector.

Checked here: make check, and make race-rest, race-sim (177 s) and
race-sim-checkptr (206 s), all passing.

Not measured: the job's time on CI after this change, since no pull
request has run it. If CI keeps the ratios above, the slowest shard runs
its tests in 6 to 8 minutes where the old step took 12 to 17. make ci's
time on a developer machine is not measured either.
@github-actions github-actions Bot added level:L2 Read the diff risk:high Touches a path in .github/risk-paths.json labels Nov 24, 2026
@bketelsen
bketelsen merged commit d963a22 into main Nov 24, 2026
15 checks passed
@bketelsen
bketelsen deleted the ci/faster-race-detector branch November 24, 2026 17:21
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

level:L2 Read the diff risk:high Touches a path in .github/risk-paths.json

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant