0234. Parallel test executables
- Status: Accepted (maintainer, 2026-11-22)
- Date: 2026-11-14
- Plan: optimization round 1 (Optimization Researcher findings)
Context
The gate ran cargo test --workspace --quiet, which
starts the ~84 test executables one after another. Research
measured the gcc run averaging 2.8 of 8 cores (586 s wall, 1528 s
user CPU): most executables are short or mostly serial, and the
tui suite serialized its four runner cases (about 370
s) behind one global lock.
Decision
scripts/run-tests.py runs the executables that
bench/test_suite.py discovers
(cargo test --workspace --no-run) on a pool of
HARNESS_TEST_JOBS workers, default half the CPUs in
the affinity mask. Executables start longest first from a static
estimate table, then by name. Each gets
RUST_TEST_THREADS or CPUs / jobs test threads, so the
product stays near the core count. Output is captured per
executable and printed whole in scheduling order, never
interleaved and never timing-dependent; any failure makes the run
fail. scaling (wall-time ratios) runs alone, one test
at a time, after the pool drains.
HARNESS_UNVERIFIED_LOG stays shared: each marker is
one O_APPEND write, atomic across processes.
In tests/tui.rs only the property and plugin-check
modes share a lock (the property mode rewrites files under
plugins/tui/tests/); the wire and example modes build
in private temporary directories and overlap. tui
gets four test threads. scripts/test-tui.py checks
its hand-run examples on a pool of HARNESS_TEST_JOBS
workers (default the process CPU count) and prints results in
fixed order.
The workspace has only a binary target, so
cargo test --workspace runs no doctests; the runner
still runs cargo test --doc for any future workspace
library. Profiling (HARNESS_PROFILE_TESTS=1) goes
through the same runner.
Alternatives considered
- Keep serial executables: simplest, leaves most cores idle.
- cargo-nextest: per-test processes and
scheduling, but a new tool to pin and install, and the custom
goldenharness and output parsing would change. - Run golden and heap_programs alone because their workpools use every core: adds a serial tail of about 75 s, while the kernel shares briefly oversubscribed cores and those suites have no timing assertions.
- Print output as executables finish: earlier feedback, but log order would depend on the scheduler.
Consequences
Wall time falls toward the longest remaining chain (the paired
tui cases): 352-379 s against 1441 s serial on the
same build and a loaded 8-core host (load about 20). Contention
exposed two hang deadlines set near normal run time, widened as
hang detectors only: test-tui per-command 90 s to 300 s and the
app-test acceptance child 40 s to 120 s. Tests that compare wall
times must be listed as serial in
bench/test_suite.py. Stale estimates only cost
efficiency. HARNESS_TEST_JOBS=1 runs one executable
at a time for debugging.