Repository navigation
fix(bin): run one ShellCheck per CI lint partition and split lint into four partitions - #15
Merged
Merged
Conversation
…rocess The lint partitions ran at the edge of the GitHub runner's memory and a partition was killed outright when a two-file PR reshuffled the byte-weight packing. In source-following mode a worker handed its whole shard to one ShellCheck process, and that process keeps the heap its heaviest root needed for as long as it runs, so each of the two concurrent workers held a worst-root high-water mark for the length of the job. Peak memory tracks the sourced-library fan-out rather than file size, so the byte-weight packing that balances the shards cannot bound it, and any file added or removed can regroup the roots and tip a partition over. Analyze every root in its own process instead, which is what the no-source-following path already did. A worker's peak is then one root's analysis, measured across the canonical set at 4.07 GiB at most, and that bound no longer depends on how roots are grouped. Coverage, rules, source following and extended analysis are unchanged: ShellCheck reports findings only for the root it was given, so the per-root and batched diagnostics are identical.
A lint partition was killed by the runner's OOM killer (exit 143, no findings printed) whenever the byte-weight packing gave it two expensive shards. ShellCheck sizes its heap to the memory it can see rather than to a fixed per-root cost. The same root on Linux x86_64 is OOM-killed under a 3 GiB cap, completes at exactly 5.00 GiB under a 5 GiB cap, uses 5.72 GiB under 7 GiB, and reaches about 11.6 GiB on a 16 GB runner. Two workers sharing a runner both expand toward the whole machine, which is the collision; one worker expands into that same runner safely. Because the heap follows available memory, no regrouping of roots can bound it: giving every root its own process moved the runner's reported peak by 0.009%. A per-process GHC heap cap would bound it without touching concurrency, but the pinned binary rejects both GHCRTS=-M and +RTS with "Most RTS options are disabled", so that lever is unavailable until ShellCheck ships -rtsopts. Run a single ShellCheck per partition, and generalize --partition from the hardcoded 1of2/2of2 to <n>of<total> so partition count is the dial that bounds wall time. The CI matrix moves to four partitions to absorb the lost intra-job concurrency. Coverage, rules, source following and extended analysis are unchanged; --jobs and FM_LINT_JOBS can no longer raise a partition above one worker.
max-metaplanet
added a commit
that referenced
this pull request
Oct 6, 2026
…o four partitions Carried from fork commit 8105600 (#15). The plan's step 9 said to prefer upstream here if upstream's work covers this partitioning. It does not: upstream fixed the same memory problem from the other side, by bounding each root's deadline and address space and retrying a root that hits the ceiling without source following, but its `--partition` remains fixed at `1of2|2of2` and its CI matrix remains two partitions. This commit generalizes the partition count to `<n>of<total>` and runs one ShellCheck per partition, which upstream does not do, so both land: upstream's per-root envelope keeps a single root from running uncapped, and this commit's one-worker-per-partition rule keeps two workers on one runner from each sizing a heap to the whole machine and colliding with its OOM killer. The script header states both: upstream's bounded workers and one-root-per-process default, then this commit's generalized partition count and the reason a partition runs one ShellCheck at a time. docs/fm-test-portable-shards.md keeps upstream's per-root bounds sentence, its per-root lifecycle sidecar, and its newer statement that the watch-triage floor alone already exceeds the fifteen-minute objective, with this commit's partition-count wiring, its pointer to the new memory verification record, and the corrected sixteen-job layout. `bin/fm-doc-audience-check.sh` passes, and the new verification record is classified in the inventory.
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
The CI lint job runs at the edge of the GitHub runner's memory and gets killed. On the last green run of main (c48332b), lint partition 1 took 574s with 8.3GB peak memory in one ShellCheck worker and 13.7GB summed across workers; partition 2 took 531s with 12GB peak in one worker and 21GB summed, on a 16GB ubuntu-latest runner. On PR #12, the "Lint 2" job was killed twice with exit 143 at about 7m25s, with no findings printed, no GitHub cancellation, and a 30-minute job limit, while every other check passed; that PR only added two small files, which reshuffled the byte-weight partitioning (19 files moved out of partition 2, 18 in) and made partition 2 about 13% heavier. Any future PR that adds or removes files can tip a partition over the same way. That PR was merged with an explicit one-time waiver of that check. Fix the lint job so it stays well within runner memory, with the same lint rigor.
Scope note for the test step: verify behaviour with the lint unit tests (tests/fm-lint*.test.sh, including the test added by this change) plus at most one sanity run of the fixed code on a single partition. Do not rerun full base-versus-fix partition memory comparisons locally. The before/after memory and wall-time telemetry comes from this pull request's real CI run and belongs in the pull request description.
What Changed
bin/fm-lint.sh --partitionnow accepts any<n>of<total>value, not just1of2/2of2. It rejects malformed or out-of-range values, and a missing value, with exit 2. The byte-weight packing now spreads roots acrosstotalpartitions instead of a fixed two. In partition mode the script forces a single ShellCheck worker (JOBS=1), and neither--jobs 2norFM_LINT_JOBS=2can override that. Lint runs outside partition mode still use two workers.Lint 1throughLint 4). The workflow comment names the matrix as the setting to raise when partitions get slow.CONTRIBUTING.md(required checks list) anddocs/fm-test-portable-shards.mdare updated to match.docs/verification/lint-runner-memory.md, registered indocs/documentation-audiences.json. It holds the measurements behind the change: ShellCheck grows its memory to fill whatever the machine has, so two workers on one runner collide, and splitting roots per process does not lower the peak.tests/fm-lint.test.shnow checks that the four partitions together cover every canonical root with no overlaps, checks the new refusal cases, and adds a test that every partition run recordsjobs 1in telemetry even when--jobs 2orFM_LINT_JOBS=2is set.CI memory and wall time
Measured on this PR's own GitHub Actions run at
e939f22a, againstmainat the merge base65fc15d9.Both used the pinned ShellCheck 0.11.0 on
ubuntu-latest(16 GB).Before, each partition ran two ShellCheck workers concurrently, so its summed figure is memory that could be live at the same moment:
After, each partition runs a single ShellCheck, so its two shards are sequential and the max worker is the real instantaneous ceiling:
The summed column is no longer a safety number: with one worker the two shards never coexist, so it adds peaks reached at different times.
The number that matters is the instantaneous ceiling, which falls from about 16.8 GiB of concurrent demand on a 16 GB runner to 12.55 GiB in a single process that has no sibling to collide with.
Longest partition wall time falls from 765s to 649s, against a 30 minute job limit.
All four partitions passed, including the job that was previously killed with exit 143.
One caveat worth stating plainly: 12.55 GiB is 78% of the runner, which is consumption rather than requirement.
ShellCheck expands into whatever memory is free, and the same heaviest root completes cleanly at exactly 5.00 GiB when capped at 5 GiB.
With one process per runner there is no second process sizing itself to the whole machine, which is what produced the kills.
Why not a heap cap instead
A per-process GHC heap cap would bound memory without changing concurrency, and would have been the smaller change.
The pinned ShellCheck refuses it.
GHCRTSdoes reach the binary, sinceGHCRTS=--infoprints the RTS table (GHC 9.8.2, vanilla non-threaded RTS), but bothGHCRTS=-M6gandshellcheck --norc +RTS -M6g -RTSfail with:That is why partition count carries the wall-time cost instead.
docs/verification/lint-runner-memory.mdrecords the measurement and says to re-test after a ShellCheck upgrade, since a build linked with-rtsoptswould make the cap the better fix.Coverage
Coverage and rules are unchanged.
The same 432 canonical roots are linted, now 108 per partition across four partitions instead of 216 across two.
Severity, extended analysis,
--external-sourcesand the ShellCheck version pin are all untouched, and no check is disabled or excluded.Risk Assessment
✅ Low: The change is small and well-tested: each CI partition now runs one ShellCheck, partition parsing is generalized with correct validation and greedy balancing, and the CI matrix uses the existing job-total contract with the same roots and analysis settings; the only defect found is a stale error message.
Testing
I ran both lint unit test files, including the new single-worker partition test, and both passed. From the command line I checked that the four partitions cover the 432 canonical roots exactly once (108 roots each), and that malformed or weakened partition options are refused with exit 2. I then ran partition 2of4 once with real ShellCheck 0.11.0 while explicitly asking for 2 workers through both
--jobs 2andFM_LINT_JOBS=2. Telemetry showed jobs=1, full analysis, and exit 0. The run took 268s wall time, and the single worker peaked at about 3.9GB RSS on this macOS host. That number is only a local sanity figure because ShellCheck sizes its heap to the memory it can see. The before/after memory and wall-time comparison against the 16GB runner has to come from this PR's real CI run, as the intent specifies, so I did not repeat it locally. No transient files were left in the worktree.CI=true FM_LINT_JOBS=2 bin/fm-lint.sh --partition 2of4 --jobs 2; new unit test test_partition_runs_one_shellcheck_at_a_time passesCI=true bin/fm-lint.sh). It recorded no live run.…Evidence: Partition CLI transcript (coverage, disjointness, refusals)
Source: Partition CLI transcript (coverage, disjointness, refusals)
Evidence: Real partition 2of4 lint run with /usr/bin/time -l
Source: Real partition 2of4 lint run with /usr/bin/time -l
Evidence: Partition 2of4 telemetry (jobs 1 despite --jobs 2 / FM_LINT_JOBS=2)
Source: Partition 2of4 telemetry (jobs 1 despite --jobs 2 / FM_LINT_JOBS=2)
partition 2of4 jobs 1 analysis_mode full root_count 108 wall_seconds 268 max_worker_rss_kib 3928976 result_exit 0Evidence: fm-lint unit test log
Source: fm-lint unit test log
Evidence: fm-lint-workflows unit test log
Source: fm-lint-workflows unit test log
Pipeline
Updates from git push no-mistakes
✅ **intent** - passed
✅ No issues found.
✅ **Rebase** - passed
✅ No issues found.
bin/fm-lint.sh:435- Running--partitionwith no value still prints the old 'requires 1of2 or 2of2' message. The CI matrix now uses 1of4..4of4, so that message points users at a two-way split. It should match the new wording at line 475: 'requires <n>of<total>, such as 1of4'.docs/verification/lint-runner-memory.md:20- Evidence for the fix: one ShellCheck on the 16 GB runner peaked at about 11.6 GiB (12,128,056 KiB), which leaves roughly 4 GiB of headroom. The fix makes sure only one ShellCheck runs per runner, and it keeps full rigor: same roots, rules, source following, and extended analysis. How much headroom there really is gets confirmed by this PR's CI telemetry, which the intent assigns to the PR description. No code change needed.✅ **Test** - passed
✅ No issues found.
CI=true FM_LINT_JOBS=2 bin/fm-lint.sh --partition 2of4 --jobs 2; new unit test test_partition_runs_one_shellcheck_at_a_time passesCI=true bin/fm-lint.sh). It recorded no live run.…bash tests/fm-lint.test.sh(includes the new test_partition_runs_one_shellcheck_at_a_time and the updated test_canonical_partitions_preserve_full_lint) - exit 0bash tests/fm-lint-workflows.test.sh- exit 0bin/fm-lint.sh --partition {1..4}of4 --list-filescompared againstCI=true bin/fm-lint.sh --list-filesfor completeness and no duplicatesbin/fm-lint.sh --partition <0of4|5of4|of4|1of|xof4|1of4x> --list-filesand--partition 1of4 --fastchecked for refusal with exit 2CI=true FM_LINT_JOBS=2 /usr/bin/time -l bin/fm-lint.sh --partition 2of4 --jobs 2 --telemetry ...- one real sanity run on a single partition with pinned ShellCheck 0.11.0🔧 **Document** - 2 issues found → auto-fixed ✅
CONTRIBUTING.md:43- The CI matrix now emits Lint 1 through Lint 4, and CONTRIBUTING.md now lists those as required contexts, but the GitHub main ruleset itself is repository configuration, not a committed file. A maintainer has to addLint 3andLint 4as required checks once this lands green, following the CONTRIBUTING.md procedure. Until then, those two partitions can fail without blocking a merge.bin/fm-lint.sh:435- When--partitionis given with no value, the error still says 'requires 1of2 or 2of2', which no longer matches the<n>of<total>format (line 475 uses 'such as 1of4'). This is an executable message, so the document phase left it alone. It needs a one-line code fix.🔧 Fix applied.
✅ Re-checked - no issues remain.
✅ **Lint** - passed
✅ No issues found.
✅ **Push** - passed
✅ No issues found.