Skip to content

perf(check): cap native typecheck scheduler width - #2288

Merged
devswha merged 1 commit into
mainfrom
perf/typecheck-gomaxprocs
Oct 28, 2026
Merged

devswha merged 1 commit into
mainfrom
perf/typecheck-gomaxprocs

Conversation

@devswha

@devswha devswha commented Oct 28, 2026

Copy link
Copy Markdown
Owner

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.

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.

@coderabbitai

coderabbitai Bot commented Oct 28, 2026 •

Copy link
Copy Markdown

Review in Change Stack →

No actionable comments were generated in the recent review.

Recent review info
Run configuration
Commits

Reviewing files that changed from the base of the PR and between 4b07d0c and df34509.

Files selected for processing: 3
  • changelog.d/typecheck-gc.md
  • scripts/typecheck.test.ts
  • scripts/typecheck.ts

Included review availability: This review used your included allowance. Your plan provides up to 4 included reviews per hour; 1 remain after this review.

📝 Summary

Summary by CodeRabbit

  • Chores
    • TypeScript checks now limit Go scheduler threads by default, while respecting an explicitly configured thread limit.
    • Existing garbage-collection settings and caller-provided environment values remain supported.
  • Tests
    • Added coverage for default and explicit thread limits, combined settings, and empty values across both compiler processes.
  • Documentation
    • Updated the maintenance note to describe the scheduler limit and preserved environment settings.

The typecheck wrapper now sets GOMAXPROCS to the caller’s value when provided, or to the smaller of 32 and available parallelism otherwise. Tests verify the setting for both compiler processes, and the maintenance note documents the scheduler limit.

Changes: Typecheck scheduler configuration

Layer / File(s) Summary
Configure and verify scheduler width
scripts/typecheck.ts, scripts/typecheck.test.ts, changelog.d/typecheck-gc.md
The wrapper sets a default GOMAXPROCS of min(32, availableParallelism()) and preserves a caller-provided value. Tests cover defaults, overrides, combined settings, and empty-string values for both compiler processes. The maintenance note documents the scheduler limit and preserved caller settings.

Priority: Low

Estimated code review effort: 2 (Simple) | ~10 minutes

Change: Other

Possibly related PRs

  • devswha/ovis#2276: Introduced the typecheck wrapper and caller-overridable GOGC and GOMEMLIMIT settings that this change extends.
Merge Risk: Minimal · up to df345

No merge-blocking issue is identified; the scheduler cap and environment-variable behavior are covered by the reported tests.

Pre-merge checks: Passed 4 · Failed 1

Failed Failed checks: 1 warning

Check name Status Explanation Resolution
Docstring Coverage Warning 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. Documentat… Write docstrings for the functions missing them to satisfy the coverage threshold.
Passed Passed checks: 4 passed
Check name Status Explanation
Title check Passed The title clearly and concisely describes the main change: limiting the native typecheck scheduler width.
Description check Passed The description includes the required Change and Validation sections. It explains the behavior, caller overrides, performance measurements, concurrency impact, and test results.
Linked Issues check Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check Passed Check skipped because no linked issues were found for this pull request.
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. (1 skipped: 1 unsupported.)

Resolution

Write docstrings for the functions missing them to satisfy the coverage threshold.

Finishing Touches: 💡 1
📝 Generate docstrings: 💡
  • 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.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@devswha

devswha commented Oct 28, 2026

Copy link
Copy Markdown
Owner Author

Merging df34509, the follow-up to #2276. Codex was at capacity, so the merge pass read the diff and an omo reviewer on gpt-6.1-sol reviewed it; both pass with no findings. scripts/typecheck.ts now also sets GOMAXPROCS=min(32, cores) for the native tsc unless the caller set GOMAXPROCS (an empty value is kept); GOGC=400 and GOMEMLIMIT handling are unchanged. The lane measured it with #2276's alternating-pair method against GOGC=400 alone: about 11% less CPU, 11% less wall time and 14% less RSS. Verified: scripts/typecheck.test.ts 8/8 on this 128-core host (cap 32) and under taskset with 1 and 2 cores; bun run typecheck passes; a real compiler error in either project still fails the wrapper with exit 1 and stops it. Not verified: native Windows and macOS runs.

@devswha
devswha merged commit f906bc5 into main Oct 28, 2026
19 of 20 checks passed
@devswha
devswha deleted the perf/typecheck-gomaxprocs branch October 28, 2026 17:24
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant