Repository navigation
fix(bin): rebalance portable parallel test lanes using CI timings - #4
Merged
Merged
Conversation
…nchenguid#4151) * ci: rebalance the portable parallel lanes on measured runner durations Both portable parallel lanes are capped at 10 minutes. Lane 1 was cancelled at that cap on every request raised on 2026-09-10 while lane 2 finished in about 3.5 minutes, so no request could go green. CONTRACT CLASS: RESTORE. The workflow already promises two duration-balanced lanes and the shard documentation already claims a measured wall; this re-establishes both against what the lanes now cost, and changes no lane count, no cap, and no scope of what runs. The counter-argument, so nobody has to take that on trust: two pieces here are genuinely new rather than restored, and either could be argued to make this a NEW-behavior change. `--list-scheduled` now ranks a parallel lane on measured durations where it previously handed every parallel script the serial default weight and returned an alphabetical order; and `--check-coverage` gains three reported fields. I classify the change RESTORE because both exist only to make the already-promised property checkable, but they are named here rather than folded into the restoration. === PART 1: THE TOTAL, AND HOW IT WAS OBTAINED === This section stands on its own. It establishes what the parallel set costs. It derives no packing; Part 2 does that, from this number. THE TOTAL: 828568 ms, about 13 min 49 s of serial work across the 24 scripts. Lane 1 held 624299 ms of it and lane 2 held 204269 ms, a 3.06:1 split. HOW IT WAS OBTAINED. The difficulty was that lane 1 had never finished, so its duration did not exist as a recorded figure anywhere and no timing artifact was expected for it. It turned out to be recoverable from the real lane without estimating, by two routes, across six CI runs on 2026-09-10 (34459949083, 34460760299, 34462530836, 34462758357, 34466966385, 34470382458): - Run 34462758357's lane-1 job finished its suite 18 s BEFORE the wall and uploaded a complete fm-test-timing-portable-parallel-1 artifact carrying all 11 scripts, FM_TEST_SUMMARY total=11 failed=0 duration_ms=598225. The upload step is if: always(), so the cancellation did not suppress it. This is one full, untruncated lane-1 measurement. - The five other lane-1 jobs were cancelled mid-suite, but each logs every script that had already finished as an FM_TEST_END duration_ms= marker. Those per-script records are complete measurements of completed scripts; only the script in flight at cancellation is lost, and it differs by run. Lane 2 completed in all six runs, so its scripts come from the six uploaded fm-test-timing-portable-parallel-2 artifacts. Every one of the 24 scripts therefore carries at least one untruncated measurement: 20 of them measured in all six runs, two in three or four runs, and two (fm-brief, fm-transition-lib, the tail of lane 1) in the single complete run. Each hint is the SLOWEST value that script reached, so the total is an upper envelope rather than an average. NO FIGURE IN IT IS DERIVED FROM A TRUNCATED LANE, and no lower bound was ever extrapolated into a total. THE ENVIRONMENT, AND WHETHER IT TRANSFERS. Every hint is a serial run of the real portable parallel lane on a GitHub ubuntu-latest runner, produced by the lane's own CI job. It transfers because it is not a proxy for the lane; it is the lane. Nothing in the total came from this machine or from any harness of mine. That mattered, and here is what it would have cost. A same-day macOS cross-check of the same scripts ran 1.7x to 5.0x slower with the ratio varying per script (fm-test-run 157420 ms against 92944 ms, fm-x-mode 67217 ms against 31870 ms, fm-composer-ghost 10521 ms against 2120 ms). Local timings therefore do not scale the lane, they REORDER it, so a packing derived from them would have balanced the wrong thing while looking clean. WHAT IT REPLACES, which is the root cause. The lanes were packed from the 2026-08-20 concurrent isolation proof: 24 candidates across four LOCAL workers. That record answers whether the candidates are isolation-safe, not how long a SERIAL CI lane runs, so it was structurally incapable of representing lane wall clock even when it was fresh. It was also never refreshed while the set grew about 3.2x. Both the wrong instrument and the staleness are fixed here: the hints now come from the lane itself and carry their run ids and date. === PART 2: THE SPLIT DERIVED FROM THAT TOTAL === Longest-processing-time assignment over those hints gives 414269 ms and 414299 ms, 30 ms apart, against 624299/204269 before. tests/fm-pi-primary-types.test.sh stays in lane 1 because that is the job which installs the Pi package, so ci.yml needs no step changes. === PART 3: DOES THE MARGIN SURVIVE MACHINE VARIANCE === Stated explicitly, because 6.90 min against a 10 min cap is 69% of cap before any variance is applied, and the cap covers the whole job rather than the suite. worst lane, script time 414299 ms 6.90 min job overhead, measured on the real lane ~18 s (see below) expected healthy job ~432300 ms 7.21 min x1.29 on the script time, plus overhead ~552400 ms 9.21 min cap 600000 ms 10.00 min room left after the multiplication ~47.6 s 7.9% of cap The 1.29x is the runner variance measured today on the SIBLING SERIAL lane, as supplied; it is not this lane's own figure. This lane family does have its own, and it is tighter: the six full lane-2 sums today span 192939 ms to 203451 ms, a spread of 1.054x. At that figure the worst lane lands near 7.58 min with about 2.4 min of room. I have used the LARGER, borrowed 1.29x for the verdict rather than the tighter one this lane actually shows, and note that the hints are already per-script maxima, so 1.29x on top is conservative twice over. THE MARGIN SURVIVES THE MULTIPLICATION, so this proceeds rather than stopping. The 18 s overhead is measured, not assumed: in run 34462758357 the lane-1 job ran 10 min 16 s against a 598.2 s suite, and lane 2 ran 3 min 21 s against a 192.9 s suite, a ~10 s difference that matches lane 1's extra Pi package install. The cap is unchanged, the lane count is unchanged, and nothing in the serial lane, its shard count, its guard or its hint table is touched. === PART 4: THE RECORDED FACT === The workflow comment no longer restates the shard wall as a literal, which is how "~1 min of serial sum" survived a 10x change without announcing it. It now points at bin/fm-test-run.sh --check-coverage, which prints parallel_max_ms, parallel_imbalance_ms and parallel_unhinted derived from the hint table, so the current number is computed on demand. The shard documentation carries the dated run ids, which route it was taken by, and the local cross-check that shows why local numbers are not admissible as hints. Two regressions pin what rotted: lane membership must be stored longest-measured-first, and the lanes must be fully hinted and packed within 5% of each other. Both were run against the old composition and both fail on it (420030 ms imbalance against a 624299 ms worst lane). The ordering assertion they replace named a specific script by hand and had itself gone stale. === PART 5: NAMED AND LEFT, OUTSIDE THIS REBALANCE === tests/fm-captain-hold-lifecycle.test.sh alone is 296481 ms, 36% of the whole set, so it is the floor of any two-lane split: no repacking can put a lane below it. After this rebalance the cap is about 1.45x the healthy lane where the sibling serial lane keeps roughly 2x. Nothing refuses a stale parallel hint the way PORTABLE_SERIAL_MAX_UNHINTED_PERCENT bounds the serial lane. parallel_unhinted is reported, not enforced, which is what let this drift for three weeks unnoticed. * fix(review): Restrict parallel scheduling hints to portable parallel lanes * fix(document): Clarify parallel lane scheduling and timing evidence
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.
Intent
Cherry-pick upstream commit 869ae90 (kunchenguid/firstmate PR kunchenguid#4151), 'fix(bin): rebalance portable parallel test lanes using CI timings', onto this fork's main. This fork's first-ever CI run on PR #3 showed the 'Behavior portable parallel 1' check being cancelled at its 10-minute cap because lane 1 and lane 2 are unbalanced; the upstream commit rebalances the two portable-parallel test lanes using measured CI timings so lane 1 fits under the cap. It touches .github/workflows/ci.yml, bin/fm-test-run.sh, docs/fm-test-portable-shards.md, and tests/fm-test-run.test.sh. This is a mechanical, already upstream-reviewed CI configuration change with no new behavior beyond restoring the two-lane balance; nothing else should change. The fix unblocks every future pull request on this fork, not just one change. All 27 real GitHub checks on PR 4 already pass cleanly against this exact head (b92e741); a prior pipeline run on this same head produced a passed-with-override outcome only because it was reattached mid-flight while a stale compliance check event was still resolving - that override should not recur now that every check is genuinely green.
What Changed
bin/fm-test-run.shrebalances the membership ofportable-parallel-1andportable-parallel-2using a newportable_parallel_weight_hintstable, which holds each script's slowest completedubuntu-latestduration across six CI runs. For example,fm-pr-mergemoves to lane 1, andfm-captain-hold-lifecycle,fm-composer-lib,fm-tmux-submit-busyandfm-transition-libmove between lanes.--list-scheduled --lane portable-parallel-{1,2}now orders scripts by these hints and falls back to serial weights when a hint is missing. Every other selection still uses serial weights, with ties broken by path.--check-coveragenow also reportsparallel_max_ms,parallel_imbalance_msandparallel_unhinted, all derived from the lane memberships and hints.tests/fm-test-run.test.shadds three tests. One requires every parallel member to have a hint and the two lane sums to be within 5% of each other. One requires stored lane order to be longest-hint-first. One confirms that non-lane selections still schedule by serial weights.docs/fm-test-portable-shards.mdreplaces the old local concurrent-proof timing table with the CI-run provenance, per-script sample counts and the steps for refreshing the hints. In.github/workflows/ci.yml, only the comments on the two parallel jobs change: the stale "~1 min" estimate is corrected. Thetimeout-minutes: 10cap and the lane count stay the same.🤖 Generated with Claude Code
Risk Assessment
✅ Low: This is a mechanical cherry-pick: its added and removed lines match upstream 869ae90 exactly. The fork's copy of bin/fm-test-run.sh differs from upstream in only two family-map entries unrelated to the parallel lanes. The rebalanced lanes still partition the fork's 24-script proven-isolated set exactly. The coverage guard puts the lanes about 30 ms apart, with the larger at about 414 s. Every moved script's prerequisites (tasks-axi, jq, Pi for fm-pi-primary-types) are installed in the lane it now runs in.
Testing
I ran the realbin/fm-test-run.shCLI at head b92e741. Its--check-coverageguard passes and reports a 414 s worst lane, a 30 ms imbalance and no unhinted scripts. Applying the same measured hints to the base split puts lane 1 at 624 s (10.4 min), which matches PR #3's lane 1 being cancelled at 616 s. Both lanes ran end to end locally with CI's flags: lane 1 passed 11/11 in 557 s on WSL, sharing the CPU with my mutation runs, with the Pi test actually running. Lane 2 passed 13/13 in 502 s. Each lane's stored order matches--list-scheduled, and together the lanes still split exactly the same 24 proven-isolated scripts. The Pi test stays in the lane that installs Pi. Every non-lane--list-scheduledselection and every other lane is byte-identical to base. On mutated copies,--check-coveragenever fails (by design) but reports the drift. The branch's lane tests reject the pre-fix split, a missing hint, a >5% imbalance and parallel hints leaking into non-lane selections, and accept a small move within 5%. The workflow parses to the same model as base (only comments changed), and the patch matches upstream 869ae90. As supporting context, PR #4's CI at this head shows both parallel lanes succeeding in 351–434 s against the 600 s cap. I produced no visual artifacts because this is a CLI and CI-configuration change with no UI. The overall result is go.bin/fm-test-run.sh --check-coverageand sees the parallel lanes fully hinted and balanced--list-scheduledoutput and the other lanes are byte-identical to basenot okwith the expected message, and the M3c boundary and M0 control pass;--check-coveragereports the drift in every caseEvidence: Evidence summary table
Source: Evidence summary table
Evidence: Coverage guard output at head
Source: Coverage guard output at head
FM_TEST_COVERAGE ok total=194 parallel=24 parallel_max_ms=414299 parallel_imbalance_ms=30 parallel_unhinted=0 serial=157 serial_shards=5 serial_unhinted=11 herdr=13Evidence: Base vs head lane packing (regression repro)
Source: Base vs head lane packing (regression repro)
base 8facd7c portable-parallel-1: 11 scripts, packed_ms=624299 (10.4 min) base 8facd7c portable-parallel-2: 13 scripts, packed_ms=204269 (3.4 min) head b92e741 portable-parallel-1: 11 scripts, packed_ms=414269 (6.9 min) head b92e741 portable-parallel-2: 13 scripts, packed_ms=414299 (6.9 min)Evidence: Live lane 1 run log (CI flags, Pi gate enforced)
Source: Live lane 1 run log (CI flags, Pi gate enforced)
Evidence: Lane 1 timing artifact
Source: Lane 1 timing artifact
Evidence: Lane 2 timing artifact
Source: Lane 2 timing artifact
Evidence: Lane order, partition, and non-lane scheduling parity
Source: Lane order, partition, and non-lane scheduling parity
Evidence: Upstream 869ae90 cherry-pick parity
Source: Upstream 869ae90 cherry-pick parity
bin/fm-test-run.sh: IDENTICAL changed-line set (129 lines) ci.yml, docs/fm-test-portable-shards.md, tests/fm-test-run.test.sh: blobs identical to upstream 869ae90Evidence: CI workflow semantic parity
Source: CI workflow semantic parity
Evidence: PR #4 CI portable-parallel job walls at head
Source: PR #4 CI portable-parallel job walls at head
run 34575386704 Behavior portable parallel 2 success job_wall=351s (cap 600s) run 34575386704 Behavior portable parallel 1 success job_wall=434s (cap 600s) run 34581493312 Behavior portable parallel 2 success job_wall=414s (cap 600s) run 34581493312 Behavior portable parallel 1 success job_wall=426s (cap 600s)Evidence: PR #3 pre-fix CI portable-parallel job walls
Source: PR #3 pre-fix CI portable-parallel job walls
run 34572974900 (PR #3, pre-fix lanes) Behavior portable parallel 1 cancelled job_wall=616s (cap 600s) run 34572974900 (PR #3, pre-fix lanes) Behavior portable parallel 2 success job_wall=215s (cap 600s)Pipeline
Updates from git push no-mistakes
✅ **intent** - passed
✅ No issues found.
✅ **Rebase** - passed
✅ No issues found.
✅ **Review** - passed
✅ No issues found.
✅ **Test** - passed
✅ No issues found.
bin/fm-test-run.sh --check-coverageand sees the parallel lanes fully hinted and balanced--list-scheduledoutput and the other lanes are byte-identical to basenot okwith the expected message, and the M3c boundary and M0 control pass;--check-coveragereports the drift in every casebin/fm-test-run.sh --check-coverageat head b92e741Lane sums with head hints for base 8facd7c vs head:bin/fm-test-run.sh --list --lane portable-parallel-{1,2}from both treesPATH=<temp pi+tsc>:$PATH bin/fm-test-run.sh --lane portable-parallel-1 --fail-on-gate-skip 'Pi extension typecheck prerequisite not found' --json …(live, timed)bin/fm-test-run.sh --lane portable-parallel-2 --json …(live, timed)bin/fm-test-run.sh --list --lane Xvs--list-scheduled --lane Xfor both lanes; union vs--list --proven-isolatedBase vs head byte comparison of--list-scheduledfor --proven-isolated, --all, --family pure-contract-unit, --lane portable-serial, --lane portable-serial-1of5, --lane real-herdr-gated, an explicit script list, and--list-lanesMutation drive on temp copies of head (pre-fix split, dropped hint, >5% imbalance, <5% boundary move, parallel-hint leak) running--check-coverageplus the four lane/scheduling tests fromtests/fm-test-run.test.shParsed.github/workflows/ci.ymlat base and head with PyYAML and compared the modelsCompared the changed lines inbin/fm-test-run.shand the other files' blob SHAs against upstream kunchenguid/firstmate@869ae90 viagh apiRead PR #3 (pre-fix) and PR #4 (head) CI job walls for the portable parallel jobs viagh run view✅ **Document** - passed
✅ No issues found.
✅ **Lint** - passed
✅ No issues found.
✅ **Push** - passed
✅ No issues found.