Public: anyone can read this; the crew can change it.

The check's tsc gets a 6 GiB heap bound: under 2 GiB its collector never stopped, and tsc was a check's largest CPU cost #17285

opened this

Merged 40h 1m ago, live in production

perf/tsc-memlimit → main 0 commits

  • Merged. perf/tsc-memlimit was merged into main as f2c35b2.

Review

Sign in to review this change.
4 files changed +15 −9
docs/DEVELOP.md +7 −3
@@ -82,12 +82,16 @@ fails a check: `bun scripts/gate.ts --fix` rewraps every comment line over
8282 `--all` for the whole tree) and then runs the same audit. A pull that skips
8383 it gets one `gate: note:` line in its check log and lands as it is; the
8484 nightly `rewrap` job (docs/features/nightly.md) proposes the files main
85 changed in the last two days, rewrapped, as one pull. `tsc` then runs `--incremental` with a 2 GB heap,
85 changed in the last two days, rewrapped, as one pull. `tsc` then runs `--incremental` with a 6 GB heap bound,
8686 its build info in `.forge-cache/` (made first with `mkdir -p`: tsc will not
8787 create the directory, and a checkout with no restored cache failed on it,
8888 #1881). It is TypeScript 7, the native compiler (a
89 Go binary, so the bound is `GOMEMLIMIT=2GiB`): on this tree a cold check is
90 ~3 s and ~17 CPU-s where 5.9 took ~30 s and ~50 CPU-s (#1864). 5.9 stays as
89 Go binary, so the bound is `GOMEMLIMIT=6GiB`, above its working set of about
90 3.5 GB and inside the check's 8 GiB): on this tree a cold check is ~8 s and
91 ~30 CPU-s, a warm one ~1.6 s and ~7 CPU-s (#1864). The bound was 2 GiB until
92 the tree outgrew it; under the working set the collector never stops, and the
93 same cold check cost ~66 CPU-s (~218 with one checker) on a Mac and ~450 on
94 the check runners. 5.9 stays as
9195 the dev dependency `typescript-api` only because `scripts/hollow.ts` walks
9296 its AST, which 7.0 has no stable JS API for. The forge restores
9397 `.forge-cache/` from the base's own green check and keeps it only from green checks of the default
forge.json +3 −3
@@ -41,9 +41,9 @@
4141 }
4242 },
4343 "check": {
44 "fast": "bun scripts/gate.ts && bun scripts/design-drift.ts && mkdir -p .forge-cache && GOMEMLIMIT=2GiB ./node_modules/typescript/bin/tsc --noEmit --incremental --tsBuildInfoFile .forge-cache/tsc.tsbuildinfo && bun scripts/test-shards.ts --timeout 60000 --tier fast --diff $FORGE_CHECK_BASE..HEAD --learned \"$FORGE_CHECK_LEARNED\"",
45 "run": "bun scripts/gate.ts && bun scripts/design-drift.ts && mkdir -p .forge-cache && GOMEMLIMIT=2GiB ./node_modules/typescript/bin/tsc --noEmit --incremental --tsBuildInfoFile .forge-cache/tsc.tsbuildinfo",
46 "full": "bun scripts/gate.ts && bun scripts/design-drift.ts && mkdir -p .forge-cache && GOMEMLIMIT=2GiB ./node_modules/typescript/bin/tsc --noEmit --incremental --tsBuildInfoFile .forge-cache/tsc.tsbuildinfo && bun test test/client-size.test.ts",
44 "fast": "bun scripts/gate.ts && bun scripts/design-drift.ts && mkdir -p .forge-cache && GOMEMLIMIT=6GiB ./node_modules/typescript/bin/tsc --noEmit --incremental --tsBuildInfoFile .forge-cache/tsc.tsbuildinfo && bun scripts/test-shards.ts --timeout 60000 --tier fast --diff $FORGE_CHECK_BASE..HEAD --learned \"$FORGE_CHECK_LEARNED\"",
45 "run": "bun scripts/gate.ts && bun scripts/design-drift.ts && mkdir -p .forge-cache && GOMEMLIMIT=6GiB ./node_modules/typescript/bin/tsc --noEmit --incremental --tsBuildInfoFile .forge-cache/tsc.tsbuildinfo",
46 "full": "bun scripts/gate.ts && bun scripts/design-drift.ts && mkdir -p .forge-cache && GOMEMLIMIT=6GiB ./node_modules/typescript/bin/tsc --noEmit --incremental --tsBuildInfoFile .forge-cache/tsc.tsbuildinfo && bun test test/client-size.test.ts",
4747 "verify": "bun scripts/gate.ts && bun scripts/test-shards.ts --timeout 60000 --gate --impact --keep-going --nice",
4848 "timeout": 7200,
4949 "limits": {
scripts/preflight.ts +1 −1
@@ -213,7 +213,7 @@ async function main(): Promise<number> {
213213 );
214214 const parts = await Promise.all([
215215 run("tsc", [BUN, "node_modules/typescript/bin/tsc", "--noEmit"], (o) => o.split("\n").filter((l) => /error TS\d+/.test(l)), {
216 GOMEMLIMIT: "2GiB",
216 GOMEMLIMIT: "6GiB",
217217 }),
218218 run("gate", [BUN, "scripts/gate.ts"], (o) => o.split("\n").filter((l) => l.startsWith("gate:"))),
219219 ...batches.map((b, i) => run(`tests ${i + 1}/${batches.length}`, [BUN, "test", ...b.map((f) => `./${f}`)], failures)),
test/shards.test.ts +4 −2
@@ -636,8 +636,10 @@ describe("the gate audit alone, first in the check", () => {
636636 if (!check.ok || check.value === undefined) throw new Error("no check");
637637 for (const command of [check.value.run, check.value.fast ?? ""]) {
638638 expect(command.startsWith("bun scripts/gate.ts && ")).toBe(true);
639 // TypeScript 7 (#1864): a Go binary, so its heap bound is GOMEMLIMIT, not node's.
640 expect(command).toContain(" && GOMEMLIMIT=2GiB ./node_modules/typescript/bin/tsc --noEmit ");
639 // TypeScript 7 (#1864): a Go binary, so its heap bound is GOMEMLIMIT, not node's. Above its
640 // working set (about 3.5 GB on this tree): under it the collector runs without pause and a cold
641 // check costs 2 to 12 times the CPU.
642 expect(command).toContain(" && GOMEMLIMIT=6GiB ./node_modules/typescript/bin/tsc --noEmit ");
641643 expect(command.indexOf("scripts/gate.ts")).toBeLessThan(command.indexOf("bin/tsc"));
642644 // tsc will not create its build-info directory (#1881): a checkout with no restored cache failed TS5033.
643645 expect(command).toContain(`mkdir -p ${CHECK_CACHE} && `);

Search
↑↓ navigate ↵ open ⌘↵ its app esc close

Keyboard shortcuts

Docs