perf(runner): stop forking per test when publishing parallel results#813
Merged
Conversation
parse_result_parallel runs once per test in every parallel worker and forked ~4 times per test: basename for the suite dir name, mkdir -p for a dir that already existed after the first test, and an 'echo | tr | sed' pipeline that sanitized provider args even when there were none. - Derive the suite dir name with parameter expansion. - Pre-create the dir once per file before workers spawn (a [ -d ] check inside a worker races its siblings, so every worker would still pay the fork), and keep a guarded mkdir -p in the worker as fallback. - Skip arg sanitizing when there are no provider args; the pipeline still runs for real provider args. A 10-test parallel run drops from 61 to 21 forks (basename/tr/sed 30 -> 0, mkdir 12 -> 3); the remaining per-test fork is the mktemp that guarantees a unique result file. Parallel is the mode CI runs everything in. No behaviour change.
The census failed on Linux CI with a bare count; asserting on the shim log's content makes the failure identify which binary forked and how often.
The Linux CI census caught a per-test sed the macOS profile missed: on systems whose clock is fork-free (Linux date), per-test execution time is shown, and right-aligning it strips the colored line's ANSI codes through 'echo | sed' — one fork per passing test. strip_ansi_to_slot now handles short (<=1KB) backslash-free strings in pure bash: CSI sequences are removed segment-wise with the exact sed semantics (only 'm'/'K' finals swallowed, other finals keep their printable residue), then remaining control bytes are swept with a bounded pattern substitution. Long or backslash-bearing inputs keep the echo -e + sed path, so large assert payloads never hit bash's quadratic substitution.
The Bash 3.0 CI census (no bc in that image) caught math::calculate forking sed on every integer expression to strip leading zeros before $((...)). Clock durations — the common no-bc caller — never contain a leading zero, so a case precheck keeps that path fork-free and only forks sed when a 0-prefixed number is actually present.
Brace the expansion adjacent to a literal bracket in the CSI stripper and replace the write-only for-loop counter with a countdown the loop reads; CI runs shellcheck across all files while 'make sa' covers a subset.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
🤔 Background
Shim-census profiling of
--parallel(the mode CI runs everything in) showed ~4 forks per test just to publish each result file:basename, an always-runmkdir -p, and anecho | tr | sedarg-sanitizing pipeline that ran even with no provider args.💡 Changes
[ -d ]check inside a worker races its siblings); sanitizing skipped when there are no provider args.basename/tr/sed30 → 0,mkdir12 → 3); the remaining per-test fork is the uniqueness-guaranteeingmktemp.