Repository navigation
perf(check): reduce native typecheck GC CPU with caller-overridable defaults - #2276
Conversation
…efaults Co-authored-by: sisyphus-dev-ai <[email protected]>
|
No actionable comments were generated in the recent review.
|
| Layer / File(s) | Summary |
|---|---|
Typecheck orchestration and validation package.json, scripts/typecheck.ts, tsconfig.tools.json, scripts/typecheck.test.ts, changelog.d/typecheck-gc.md |
The typecheck command uses a script that runs both projects in sequence and stops on the first nonzero exit status. Tests cover default and caller-provided GC settings, inherited environment values, and compiler failures. The tools project includes the runner and its tests. The changelog records the GOGC=400 default and CPU/RAM tradeoff. |
Priority:
Estimated code review effort: 2 (Simple) | ~10 minutes
Change: Other
Merge Risk: 
Minimal · up to 00df2
-
Typechecks default to higher memory use in exchange for lower CPU use. No merge-blocking issue was identified.
Pre-merge checks: 
4 · 
1
-
Failed checks: 1 warning Passed checks: 4 passed-
Full details: Description check
-
Explanation
The description includes the required Change and Validation sections. It explains the problem, resulting behavior, implementation scope, performance evidence, limitations, and validation results in sufficient detail.
-
Full details: Docstring Coverage
-
Explanation
Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff with cyclomatic complexity of at least 2. Documentation-only edits and deletions within surviving functions are included; unchanged diff context and fully deleted functions are excluded. Analyzed 1 functions across 2 files. (3 skipped: 3 unsupported.)
Resolution
Write docstrings for the functions missing them to satisfy the coverage threshold.
-
Finishing Touches: 💡 2
-
📝 Generate docstrings: 💡
-
- Commit to this branch
- Create a new PR
🛠️ Fix failing CI checks: 💡
-
- Commit to this branch
- Create a new PR
🧪 Generate unit tests (beta)
-
- Commit to this branch
- Create a new PR
-
- Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.
Comment @coderabbitai help to get the list of available commands.
184d37e to
00df225
Compare
Deploying ovis with
|
| Latest commit: |
00df225
|
| Status: | ✅ Deploy successful! |
| Preview URL: | https://8bcaebcd.ovis.pages.dev |
| Branch Preview URL: | https://chore-ram-offload.ovis.pages.dev |
|
Merging 00df225. Codex was at capacity, so the merge pass read the diff and an omo reviewer on gpt-6.1-sol reviewed it; both pass. |
## Change Follow-up to #2276. Native TypeScript 7 is a Go binary; cap its default scheduler width at `min(32, availableParallelism())` alongside #2276's `GOGC=400` default. - The wrapper sets `GOMAXPROCS` only when the caller did not set it. - Caller values still win, including an explicitly empty `GOMAXPROCS`. - Caller `GOGC` still wins under the same rule, and `GOMEMLIMIT` remains untouched. - The two native compiler invocations remain sequential and keep their existing arguments, inherited stdio, and failure exit codes. ## Final-tree measurement Measured on #2276 head `00df2254735dbebb2185e38ee323c6a55eeb6835`, before this follow-up. Five rotated rounds ran B/P/N, P/N/B, N/B/P, B/P/N, P/N/B inside one `dori heavy ram-gogc-pr` admission. - B: TypeScript directly, with `GOGC`, `GOMAXPROCS`, and `GOMEMLIMIT` unset. - P: #2276 wrapper, default `GOGC=400`, `GOMAXPROCS` unset. - N: #2276 wrapper, default `GOGC=400`, `GOMAXPROCS=32`. - CPU is GNU time user + system. RSS is MiB. | Variant | Median CPU s | Median wall s | Full RSS | Main tsc RSS | Tools tsc RSS | | :--- | ---: | ---: | ---: | ---: | ---: | | B | 87.87 | 11.85 | 1155.18 | 1193.28 | 602.23 | | P | 67.21 | 12.90 | 1378.33 | 1377.27 | 679.29 | | **N** | **59.73** | **11.48** | **1181.23** | **1190.29** | **652.23** | N versus B: CPU **-32.02%**, wall **-3.12%**, full RSS **+2.26%**, main RSS **-0.25%**, tools RSS **+8.30%**. N versus P: CPU **-11.13%**, wall **-11.01%**, full RSS **-14.30%**, main RSS **-13.58%**, tools RSS **-3.98%**. Every N CPU run was below P's 67.21-second median: **66.90, 50.26, 57.61, 59.73, 67.18**. N also beat P on median CPU and median wall, satisfying all predeclared gates. The closest N run was **67.18 seconds versus P's 67.21-second median**, a 0.03-second margin. No run was discarded. This was a noisy shared host: the recorded one-minute load average ranged from **95.66 to 141.61** at the start of the measured commands (approximately **95-140**). Rotation and the per-run table retain that noise rather than hiding it. ### Every run | Round | Variant | CPU s | Wall s | Full RSS | Main tsc RSS | Tools tsc RSS | Load averages at start | | ---: | :---: | ---: | ---: | ---: | ---: | ---: | :--- | | 1 | B | 85.56 | 11.85 | 1188.33 | 1193.28 | 598.18 | 95.66 / 93.82 / 85.28 | | 1 | P | 74.32 | 12.90 | 1378.33 | 1377.27 | 681.27 | 102.13 / 95.39 / 86.02 | | 1 | N | 66.90 | 17.21 | 1166.33 | 1238.34 | 662.28 | 123.21 / 101.22 / 88.26 | | 2 | P | 54.75 | 9.53 | 1383.27 | 1374.27 | 691.28 | 117.51 / 102.13 / 88.99 | | 2 | N | 50.26 | 9.56 | 1185.28 | 1190.29 | 664.23 | 110.91 / 101.60 / 89.09 | | 2 | B | 93.28 | 12.44 | 1141.23 | 1196.34 | 600.17 | 112.24 / 102.57 / 89.68 | | 3 | N | 57.61 | 10.74 | 1181.23 | 1196.29 | 650.29 | 109.19 / 102.50 / 89.94 | | 3 | B | 92.47 | 12.33 | 1155.18 | 1197.17 | 602.24 | 107.79 / 102.59 / 90.29 | | 3 | P | 64.74 | 19.31 | 1381.27 | 1197.29 | 654.29 | 106.67 / 102.84 / 90.71 | | 4 | B | 82.99 | 11.82 | 1187.24 | 1187.23 | 602.23 | 140.35 / 111.96 / 94.29 | | 4 | P | 68.66 | 12.73 | 1187.29 | 1380.29 | 679.29 | 141.61 / 114.83 / 95.72 | | 4 | N | 59.73 | 11.48 | 1230.17 | 1160.29 | 652.23 | 130.71 / 114.34 / 96.07 | | 5 | P | 67.21 | 13.17 | 1198.34 | 1377.29 | 654.29 | 124.02 / 113.86 / 96.29 | | 5 | N | 67.18 | 15.52 | 1154.29 | 1166.24 | 650.29 | 122.54 / 114.34 / 96.93 | | 5 | B | 87.87 | 10.78 | 1143.18 | 1192.23 | 602.23 | 126.01 / 116.25 / 98.13 | ## Concurrency sizing Median direct main-compiler RSS is 1190.29 MiB with N versus 1193.28 MiB with B. At 24 simultaneous main compilers: - B: **27.97 GiB / 30.03 decimal GB**. - N: **27.90 GiB / 29.95 decimal GB**. The median main-compiler RSS is effectively unchanged (-0.25%), while CPU falls 32.02% versus B and 11.13% versus P. `GOMAXPROCS` limits scheduler parallelism, not memory, and caller `GOGC`, `GOMAXPROCS`, and `GOMEMLIMIT` remain available. ## Validation On this head (`df345097`, rebased onto main after #2276 merged as `4b07d0cc`): - `bun test ./scripts/typecheck.test.ts` (inside check fast): **8 pass, 0 fail**. - `bun run check fast` through `dori heavy ram-gogc-pr`: **exit 0**; workflow syntax, generated types and themes, typecheck, build, and unit tests all ok; **8326 pass, 0 fail, 34 skip in 533 files**. Co-authored-by: sisyphus-dev-ai <[email protected]>
Change
Default native TypeScript 7 checks to
GOGC=400, retaining garbage collectionwhile spending modestly more RAM to reduce CPU. Typecheck's Go 1.26.4
tscwas the #2 CPU consumer on the shared P620 CI host.
The original proposal was
GOGC=off GOMEMLIMIT=6GiB. The maintainer's concurrencysteer requires sizing for 24 simultaneous typechecks with approximately 40 GB free;
the measurements below rule out a GC-off limit with the requested 1.5x headroom,
so this PR uses the explicitly requested
GOGC=400fallback instead.package.jsonroutestypecheckthrough a small Bun wrapper. Both CI'scheck fast/check concurrentand the remote-bundle jobs already invokebun run typecheck; neitherscripts/check.tsnor any workflow needs editing.invocations, sequential execution, inherited stdio, and failure exit codes.
GOGCwins, including an explicitly empty value.GOMEMLIMITisnever assigned or removed by the wrapper, so caller limits remain in force.
environment-assignment syntax or hard-coded Linux compiler path. This preserves
TypeScript's platform package selection on Linux, macOS, and Windows.
and independent/combined/empty overrides, argument forwarding, inherited
unrelated environment, and stopping on either compiler's failure.
typecheck validates both new files.
changes.
Concurrency sizing
Direct GNU
/usr/bin/time -vmeasurements ofnode_modules/@typescript/typescript-linux-x64/lib/tsc, not Bun's RSS.Three runs per project and setting, each through
dori heavy ram-gogc-pr -- ...;the table reports the maximum of those three runs. Both projects run sequentially.
Baseline and unlimited-off measurements explicitly remove
GOMEMLIMIT.GOGC=100, no limitGOGC=off, no limitGOGC=off GOMEMLIMIT=6GiBGOGC=400, no limitSeparate baseline
GODEBUG=gctrace=1traces show largest post-GC live heaps(
X->Y->Z MB, theZ) of 752 MiB main / 394 MiB tools. These are observedlive heaps, not a universal upper bound.
The no-GC main peak times 1.5 is 2100.50 MiB, rounded up to 2112MiB.
That limit alone times 24 is 49.5 GiB, before RSS overhead, exceeding both
the approximately 30 GB target and approximately 40 GB free. Even observed
unlimited-off RSS times 24 is 32.82 GiB / 35.24 decimal GB without growth headroom.
There is no qualifying GC-off limit under the requested sizing rule.
Baseline direct RSS times 24 is 28.25 GiB / 30.33 decimal GB. The chosen
direct peak times 24 is 32.38 GiB / 34.76 decimal GB. The larger observed
full-command high-water RSS gives 32.49 GiB / 34.89 decimal GB.
The decision-relevant increment for these direct peaks is 176.05 MiB per
compiler, or 4.13 GiB / 4.43 decimal GB at 24: the existing baseline memory
is already consumed without this change. In the prior seven-round CI-image
experiment below, the median increment is 157.00 MiB per compiler, or
3.68 GiB / 3.95 decimal GB at 24.
The fallback is below approximately 40 GB in this measurement but does not
meet the preferred approximately 30 GB envelope; it leaves about 5 GB for other
memory.
GOGC=400retains collection, not an RSS cap or a guarantee that 24runners plus their overhead fit.
GOMEMLIMITremains available to the caller.Twenty-four simultaneous typechecks are a conservative planning case, not the
usual workload:
CHECK_HOST_MAX_RUNS=4bounds the herdr-backed lanes, whereastypecheck runs in Fast checks on up to 20 runners plus any applicable lanes.
That lane bound is not a global semaphore for every Fast-check compiler.
Performance evidence
Prior CI-image experiment: seven rotating rounds
Source:
/home/devswha/.cache/ram-offload-tmp/gogc/results.md, snapshotadfdef6e49767ec09323b9b2e1f0f151c6b84394, Bun 1.4.2, TypeScript 7.0.2 /Go 1.26.4,
herdr-ci-runner:localon the 128-CPU P620. Medians:GOGC=400GOGC=off GOMEMLIMIT=6GiBEvery one of the seven GOGC=400 runs used less CPU than the baseline median;
its worst was 47.16 CPU-s versus 52.31 CPU-s.
This worktree: five alternating baseline/chosen comparisons
Rebased onto
792dbb98be8a2cd88b1123930a6aae8b131ebe23; Bun 1.4.3, nativeTypeScript 7.0.2 / Go 1.26.4. GNU time wraps the real
bun run typecheck.Baseline supplies
GOGC=100; chosen leaves it unset and exercises the wrapperdefault. Both remove
GOMEMLIMIT. Odd rounds run baseline then chosen, evenrounds reverse that order. All runs use
dori heavy ram-gogc-pr -- ....Every chosen run beats its paired baseline on CPU; four of five also beat the
baseline median. Round 5's 61.80 CPU-s exceeds the 59.58 CPU-s baseline median
and is retained. Wall-time improvement is negligible on this busy shared host.
Full-command RSS is GNU time's process-tree high-water statistic, not a sum of
simultaneously resident processes.
For the originally requested chronological three-run before/after comparison:
the unchanged script was measured before tracked edits, so no stash was needed.
Before CPU was 35.10 / 36.17 / 28.64 s, wall 4.32 / 4.95 / 5.94 s, and
RSS 1202.23 / 1206.29 / 1207.29 MiB. The first three after runs are rounds 1-3
above. Their medians are 35.10 -> 42.98 CPU-s, 4.95 -> 7.37 wall-s,
1206.29 -> 1382.29 MiB. That chronology-only comparison is slower; shared-host
conditions differed between blocks. The alternating comparison above is the
contemporaneous evidence for the win. No result was discarded.
Full-command
GODEBUG=gctrace=1counts: 24 before, 6 after (3 per compiler).The 0-2 expectation was for GC off; the selected fallback deliberately retains GC.
Raw logs, scripts, and the complete local report are retained at
/home/devswha/.cache/ram-offload-tmp/pr-tmp/(sizing-results.md,baseline-*.time,size-*.time,compare-*.time, and*.trace).The table above uses
final/compare-*.timeandfinal/size-chosen-*.time.An earlier five-round comparison before adding the module marker and tools
typechecking coverage is retained too: medians 55.60 -> 39.74 CPU-s (-28.53%),
7.03 -> 6.74 wall-s, 1193.21 -> 1250.16 MiB. The final tree was remeasured rather
than substituting those earlier results.
Validation
dori heavy ram-gogc-pr -- bun test ./scripts/typecheck.test.ts: 7 pass, 0 fail.tsconfig.tools.json.dori heavy ram-gogc-pr -- bun run check fast: exit 0;8202 pass, 0 fail, 33 skip in 530 files. Workflow syntax, both generated-file
freshness checks, both TypeScript projects, build, and unit tests all passed.
Report
e39ee9c2-d32d-4758-89a6-7432c7db8945hasstatus=success,verification.status=verified,source.unchanged=true, and no errors;log:
check-fast-final.log.because this task is already at the harness's maximum subagent depth.
the existing launcher and Bun child-environment API, without shell assignments.
operations. Temporary evidence uses the requested
TMPDIR; no shared cleanup.