Repository navigation
ci: dedupe concurrent runs, parallelise pytest, and de-flake the ReDoS timing asserts (#2901) - #2919
Merged
Merged
Conversation
Measured over the last 400 workflow runs (~27h window, 2026-09-08/09): 2201 min of wall clock, of which Full Suite Gate alone was 983 min (45%). The cost was not test execution -- it was running the same tests repeatedly and then queueing for runners. Three findings drove this: 1. `full-suite-gate.yml` triggers on `pull_request: types: [labeled]` with no label filter, so EVERY label added starts a separate run. PRs here routinely carry four labels (bug, metrics, core-engine, rosetta:rebless-owed), and #2915 fired four identical 12-job matrix runs against one SHA (56624e7) within 10 seconds. rosetta-audit, which also listens for `labeled`/`unlabeled`, fired five times on the same commit. No workflow in the repo declared `concurrency`, so nothing superseded anything. ~577 min of the sampled 2201 was redundant. 2. Queue time dwarfed run time. In run 34346837647 the matrix jobs RAN for 10-18 min but QUEUED for 23-65 min, macOS worst (51-65 min) as the scarcest pool -- 16 macOS jobs were queued where 4 were needed. 3. `pytest tests/ -v` ran the whole suite single-threaded and streamed 7946 lines / 1.1 MB to the Actions log per job. Changes: - `concurrency` on 18 workflows, keyed by workflow + PR number (or ref). `cancel-in-progress` is deliberately scoped to `pull_request` via an expression: the push/schedule/tag runs are the ones that COMMIT (docs deploy, tri-comparison / tree-sitter history charts, releases), and cancelling one mid-write risks a half-written commit. Those now serialise on the group instead. `publish.yml` and `release-crucible-archive.yml` are left untouched entirely -- the release path should not be interfered with. - pytest jobs get `pytest-xdist` and run `-n auto -q -ra --durations=25`. Verified locally against this same tree: 8685 tests, serial 323.6s -> parallel 104.8s (3.1x on 6 cores), identical pass/skip/xfail counts. CI runners are 4-core, so expect ~2.5x. `-ra` keeps the xfail/skip summary and `--durations=25` keeps a slow-test report, which is the only part of `-v` that was load-bearing on a green run. - `timeout-minutes` on every job across 18 workflows. The default is 6h; a Full Suite Gate run was observed sitting at 78 min mid-flight during this investigation with nothing to stop it. - `full-suite-gate.yml` sizes its matrix per checkpoint. A `v*` tag still gets the untrimmed 12-way grid. A PR label gets 8 jobs: all four Python versions on ubuntu (the thing this gate exists to catch is a version-specific break the every-push ubuntu/3.12 full-suite cannot see), with windows and macOS covering the version floor and ceiling only. That halves the macOS jobs that dominate the queue. Co-Authored-By: Claude Opus 5 (1M context) <[email protected]>
#2901 reports two asserts going red on shared macOS runners for PRs whose diffs touched neither: `test_embedded_python_spec_exposure_redos_immunity` (macOS runs 34288012477, 34212533327 -- expected ratio > 2.5, got 2.31) and `test_var_decl_pattern_scales_linearly_not_quadratically`. Both compare wall-clock samples on a contended runner. Scope is wider than the two files the issue names, deliberately: the same shape appears at 22 timing sites, and the companion CI change in this branch runs the suite under `pytest -n auto`, which raises CPU contention and would have made every one of them flakier. `_strict_harness._best_of_timing`'s own docstring already records this class of failure recurring (#713, #800), and groovy's spec_exposure test carries a comment about it going red on macos-3.10 during #770. Triaged into three groups: - 6 sites already assert an ABSOLUTE bound on the shipped pattern (test_prism, abap, matlab, scheme, yaml, security_lens). Left alone -- these are the shape the issue recommends. - 13 sites timed the PRE-FIX pattern to prove it was quadratic before checking the shipped one. Removed. They measured a regex this repo no longer ships, so no threshold makes them both meaningful and stable, and every one is redundant with an `assert_redos_immune` already in the same test. The measured pre-fix numbers are preserved as comments, and `test_language_standards_strict.py` keeps each language's pre-fix pattern in its parametrize table as documentation (the param is renamed `_old_pattern_text` to mark it non-executable). - 3 sites (groovy x2, yacc) asserted a ratio ceiling on the SHIPPED pattern immediately after an `assert_redos_immune` call on a 100k payload. The ratio was strictly weaker than the absolute bound above it; removed. - 2 sites converted from ratio to absolute bound, since they had no `assert_redos_immune` of their own: * `var_decl`: verified the replacement still catches what it is for -- restoring the adjacent-unbounded-quantifier shape (`[^=\n]{0,80}` -> `[^=\n]*`) makes the new 160k assertion FAIL, while the shipped pattern passes it in ~1.1s including process spawn. * ada `func_start`: measured while replacing it, this site has NO reachable quadratic regression -- the aspect segment is lazy, so even fully unbounded (`[^;{}]{0,300}?` -> `[^;{}]*?`) it stays linear (0.0002s / 0.0004s / 0.0007s / 0.0014s at n=2000/4000/8000/16000). The old ratio's additive 0.05 floor was deciding the result. Kept as a plain ceiling on a long aspect run and the docstring says so rather than overclaiming. Suite is green both ways on this tree: 8685 passed / 4 skipped / 9 xfailed / 3 xpassed, identical serial and under `-n auto`. No new ruff findings (the one I001 in test_language_standards_strict.py predates this branch). Closes #2901 Co-Authored-By: Claude Opus 5 (1M context) <[email protected]>
Contributor
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.
Why
CI wall clock was measured over the last 400 workflow runs (~27h window, 2026-09-08/09): 2201 min total, of which Full Suite Gate alone was 983 min (45%).
The cost is not test execution. It is running the same tests repeatedly, then queueing for runners.
1. Every PR ran the full matrix 3-4 times on the same commit.
full-suite-gate.ymltriggers onpull_request: types: [labeled]with no label filter, so every label added starts a run. PRs here routinely carry four labels (bug,metrics,core-engine,rosetta:rebless-owed). #2915 fired four identical 12-job matrix runs against one SHA (56624e7b8) within 10 seconds; rosetta-audit fired five. No workflow declaredconcurrency, so nothing superseded anything. ~577 min of the sampled 2201 was redundant.2. Queue time dwarfed run time. In run
34346837647the jobs ran 10-18 min but queued 23-65 min:macOS is the scarcest pool, and the duplicate runs put 16 macOS jobs in a queue that needed 4.
3. The suite ran single-threaded and streamed 7946 lines / 1.1 MB to the Actions log per job via
-v.What changed
concurrencyon 18 workflows, keyed by workflow + PR number (or ref).cancel-in-progressis scoped topull_requestvia an expression on purpose: the push/schedule/tag runs are the ones that commit (docs deploy, tri-comparison / tree-sitter history charts, releases), and cancelling one mid-write risks a half-written commit — those serialise on the group instead.publish.ymlandrelease-crucible-archive.ymlare left untouched entirely.pytest-xdist,-n auto -q -ra --durations=25on both pytest jobs.-raand--durations=25keep the only parts of-vthat were load-bearing on a green run.Measured locally on 6 cores, 8685 tests, all four runs reporting identical counts (8685 passed / 4 skipped / 9 xfailed / 3 xpassed):
-n autoorigin/main(unmodified)Two things worth reading off that table. The speedup is parallelism, not this PR's test edits — it is the same either side. And the flaky: ReDoS "pre-fix pattern scales quadratically" timing ratios fail on shared macOS runners #2901 deletions are worth ~26s serial (7%) on their own, which was never the point of them; de-flaking was. CI runners are 4-core, so expect ~2.5x there rather than 3.1x.
timeout-minuteson every job across 18 workflows. The default is 6h; a Full Suite Gate run was observed sitting at 78 min mid-flight during this investigation.Per-checkpoint matrix in
full-suite-gate.yml. Av*tag still gets the untrimmed 12-way grid. A PR label gets 8 jobs: all four Python versions on ubuntu (a version-specific break the every-push ubuntu/3.12 full-suite cannot see is exactly what this gate exists for), windows and macOS at the version floor and ceiling only. Halves the macOS jobs that dominate the queue.Closes #2901
The flaky ReDoS timing asserts had to be fixed as part of this, not after:
-n autoraises CPU contention, which would have made every wall-clock ratio assert flakier.Scope is wider than the two files #2901 names — the same shape appears at 22 timing sites.
_best_of_timing's own docstring records this class recurring (#713, #800), and groovy's spec_exposure test carries a comment about it going red on macos-3.10 during #770.assert_redos_immunealready in the same test. Measured pre-fix numbers preserved as comments;test_language_standards_strict.pykeeps each language's pre-fix pattern in its parametrize table as documentation.assert_redos_immuneon a 100k payload — strictly weaker than the bound above it. Removed.var_decl— verified the replacement still catches what it is for: restoring[^=\n]{0,80}->[^=\n]*makes the new 160k assertion fail, while the shipped pattern passes in ~1.1s.func_start— measured while replacing it, this site has no reachable quadratic regression: the aspect segment is lazy, so even fully unbounded it stays linear (0.0002/0.0004/0.0007/0.0014s at n=2000..16000). The old ratio's additive0.05floor was deciding the result. Kept as a plain ceiling, and the docstring says so rather than overclaiming.Verification
-n auto.tests/tools/audit_check.py: ruff (70-finding baseline, format clean), mypy (2-error baseline), dead-key, ast-accuracy — all clear.Reviewer notes
concurrencycancels superseded PR runs only. If you want a commit-producing main-push workflow to also cancel, that is a deliberate follow-up, not an oversight here.if: github.event.label.name == 'full-matrix') so bookkeeping labels likerosetta:rebless-owedstop triggering a matrix at all.concurrencyalready collapses the duplicates without changing the documented "any label = full validation pass" intent.🤖 Generated with Claude Code