Skip to content

ci: Run the lint lane's self-tests in parallel (#949) - #991

Merged
zackees merged 3 commits into
masterfrom
perf/949-parallel-self-test
Oct 16, 2026
Merged

zackees merged 3 commits into
masterfrom
perf/949-parallel-self-test

Conversation

@zackees

@zackees zackees commented Oct 16, 2026

Copy link
Copy Markdown
Member

Refs #949 (part of #939). This covers the main part of #949. Two other parts are left for after the CI refactor (#930/#985), to avoid colliding with it: giving the build-and-run tests their own lane, and clang-format checking only changed files locally.

Problem

./lint spent about 164 s in self_test, a single serial unittest discover over all 64 ci/test_*.py files.

Change

self_test() now runs one unittest discover -s ci -p <file> process per file, in a thread pool:

  • Workers: process_cpu_count(), which respects cgroup and affinity limits, capped at 8.
  • Output: each file's ok/FAIL line and time print as it finishes. Failures are repeated at the end with their full output and the environment hints.
  • Timeouts and exit codes: each file times out after 600 s. Exit code 5 (no tests in the file) counts as a pass, as before.

Evidence

  • Speed: 64 s locally with 8 workers, versus 164 s serial (39 s and 41 s uncapped on 16 CPUs). A Sonnet reviewer pinned it to 4 CPUs, like the CI runner: 47.7 s, all 64 files passing.
  • Same tests: per-file discovery finds the same 374 tests, with no module-name collisions.
  • Parallel safety: a reviewer read all 64 files. Everything writes into its own tempfile directory, and the tests only read the real repo (git ls-files, ls-tree), with no index locks, fixed ports or chdir.
  • RED → GREEN: SelfTestTest now asserts one process per file, that a failing file fails the step and prints its output, and the capped worker count. Against the old self_test, self_test_workers doesn't exist.
  • This PR's Local Gate (lint) runs the new code itself.

@zackees
zackees enabled auto-merge October 16, 2026 04:30
@zackees
zackees added this pull request to the merge queue Oct 16, 2026
@github-merge-queue
github-merge-queue Bot removed this pull request from the merge queue due to a conflict with the base branch Oct 16, 2026
self_test ran every ci/test_*.py in one serial unittest process, about
164 s of ./lint on a 16-CPU host (#949). Each file now runs in its own
process, cpu_count at a time; a failing file's output (and environment
hints) is printed in full. Two local runs: 39 s and 41 s, all passing.

Refs #949
…meout

Review findings: os.cpu_count() ignores cgroup/affinity limits, so a
CPU-limited container would start every file at once; use
process_cpu_count() capped at 8. Print each file as it finishes so a
hang is visible, time each file out after 600 s, and repeat failures
with their output at the end. 64 s locally (8 workers), was 164 s.

Refs #949
@zackees
zackees force-pushed the perf/949-parallel-self-test branch from 307ccc4 to bac5944 Compare October 16, 2026 07:25
@zackees

zackees commented Oct 16, 2026

Copy link
Copy Markdown
Member Author

Rebased onto master (bac5944). #1000 landed in between, and both PRs reworked self_test() in ci/local_gate.py.

  • Merged self_test(): with OBS_GATE_SKIP_SELF_TEST=1 it runs only SOLDR_SELF_TESTS (ci: Run the ci/ self-tests on the standard pool #1000). Otherwise it runs the parallel per-file path from this PR. Both sets of constants and both docstrings are kept.
  • Semantic conflict: ci: Run the ci/ self-tests on the standard pool #1000's test_self_test_runs_by_default mocked local_gate.run. The parallel path calls subprocess.run, so nothing was mocked, and the test reran the whole ci/ suite, itself included, until the 600 s per-file timeout. That was the RED.
  • GREEN: the test now mocks subprocess.run and checks that every ci/test_*.py runs once. test_selftest_pool.py passes 5/5 in 0.1 s, and the full self_test() passes 73/73 files.

@zackees
zackees enabled auto-merge October 16, 2026 07:25
test_self_test_runs_by_default mocked local_gate.run, but after the
parallel change the default path runs each ci/test_*.py through
subprocess.run, so the mock caught nothing and the test reran the whole
suite, itself included, until the 600 s per-file timeout. Mock
subprocess.run and check every ci/test_*.py runs once.
@zackees
zackees force-pushed the perf/949-parallel-self-test branch from bac5944 to b85909a Compare October 16, 2026 07:36
@zackees
zackees added this pull request to the merge queue Oct 16, 2026
@github-merge-queue
github-merge-queue Bot removed this pull request from the merge queue due to failed status checks Oct 16, 2026
@zackees
zackees added this pull request to the merge queue Oct 16, 2026
Merged via the queue into master with commit 19581f8 Oct 16, 2026
26 checks passed
@zackees
zackees deleted the perf/949-parallel-self-test branch October 26, 2026 15:45
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

Status: Done

Development

Successfully merging this pull request may close these issues.

1 participant