Skip to content

Profile the core test suite and build the installer fixture once per file - #239

Merged
jimhoyd merged 1 commit into
mainfrom
claude/issue-234-test-profile
Sep 20, 2026
Merged

jimhoyd merged 1 commit into
mainfrom
claude/issue-234-test-profile

Conversation

@jimhoyd

@jimhoyd jimhoyd commented Sep 20, 2026

Copy link
Copy Markdown
Collaborator

Investigation for #234. Measurement first; the change is one targeted consolidation.

What was measured, and where

macOS 15 (darwin 25.6.0), Node 26.8.2, 12 cores, warm npm cache, local checkout after npm ci. These are not Windows numbers and do not establish Windows behavior. #234's 4m56s came from one Windows CI run, not a controlled benchmark, and nothing here reproduces that environment.

Method: every child_process entry point was intercepted with a module.registerHooks resolve hook redirecting node:child_process to a timing shim, then the suite was run (a) whole and in parallel, and (b) one file at a time, recording per-test durations and every child process with its duration.

Where the time actually goes

582 tests across 83 files. Summed over per-file solo runs: 188.6s. Parallel npm test runner duration: 36-41s.

value
child processes spawned by tests 326
cumulative child-process time 46.0s (24% of the 188.6s sequential total)
files that spawn no child process at all 56 of 83, 76.7s (41%) of sequential time
src/cli.ts spawns 110

Measured CLI startup floor (median of 7):

bare node -e '' 26 ms
import() of the src/cli.ts module graph, no command run 186 ms
src/cli.ts --help 186 ms
built dist/cli.js --help 129 ms
src/cli.ts routes --project starters/default 309 ms

Negative result: repeated CLI startup is not dominant

The suspected cause is real but small. 110 spawns x the 186 ms floor is ~20.5s, about 11% of the 188.6s sequential total. Of that floor, TypeScript stripping is only ~57 ms (186 vs. 129 for the built CLI); the remaining ~160 ms is the module graph itself. Uncontended CLI invocations cost ~200-380 ms each, so most of a spawn is startup — but there are not enough of them for it to be the story.

Three of the four slowest files barely spawn anything:

file solo wall of which child processes
extensions.test.ts 13.8s 1.6s (6 spawns)
compliance.test.ts 12.0s 3.6s (10)
install.test.ts 11.4s 11.2s (33)
prerender.test.ts 11.0s 0.5s (1)
explain.test.ts 10.5s 1.8s (6)
site.test.ts 7.3s 0s (0)

extensions.test.ts is 29 tests at a ~200 ms in-process floor each — project loading and compilation inside the test process, not spawning. That is where a future optimization would have to look.

The packed-package smoke (scripts/package-smoke.ts) runs one pack and one install; locally it is 9.2s. There is no redundant setup in it to remove — its CI cost is npm install and tsc on the runner's filesystem.

The one change

install.test.ts was the outlier: 11.2s of its 11.4s was child processes, and six release() calls each re-ran scripts/build.ts + npm pack for byte-identical output (~8.7s of the file). Build and pack once per file, reuse the bytes.

Coverage retained. Every test still serves the freshly packed tarball over its own HTTP server and installs it into its own prefix via the real install.sh. No test was converted from a spawned process to an in-process call. No CLI or OS/Node matrix coverage was touched. The corrupt variant only ever altered the SHA256SUMS digest, never the tarball, so sharing bytes is sound.

Before / after (three runs each, same machine, same session)

before after
test/install.test.ts alone 11.19 / 11.24 / 12.21s 3.51 / 3.51 / 3.58s
full npm test runner duration 36.03 / 40.23 / 40.61s 34.06 / 35.27 / 35.48s

The per-file number is the reliable one. The parallel wall figure is noisy on 12 cores and the ranges overlap at the edges; read it as a few seconds, not as a headline. An earlier cold-cache first run measured 61.5s — that was a cold dist/, and it is excluded above rather than used to claim a 26s win.

Sharding

Assessed, not attempted. The suite is throughput-bound, not tail-bound: the longest single file is 13.8s against a 188.6s total, so splitting across runners would help, but that is a CI-topology change and should follow its own measurement on Windows rather than ride on this.

#202

Not folded in. The Windows auth-store worker startup timeout is a separate open question about packages/auth, not about this suite, and nothing measured here establishes it as a performance-only issue.

Verified

npm run lint, npm run typecheck, npm run check, full npm test (581 pass, 1 skipped, 0 fail) on macOS. Windows was not run.

🤖 Generated with Claude Code

Profiling the core suite on macOS (Node 26.8.2, 12 cores) showed
test/install.test.ts was the single most expensive file that spent its
time on redundant setup rather than on the behavior under test: each of
its six release() calls re-ran scripts/build.ts and npm pack, producing
byte-identical inputs. Those six build+pack pairs were about 8.7s of the
file's 11.2s.

Build and pack once per file and reuse the tarball bytes. Every test
still serves the freshly packed tarball over its own HTTP server and
installs it into its own prefix, so the fresh-installed-package and
separate-process coverage is unchanged; only the repeated identical
build and pack are removed. The corrupt variant only ever altered the
SHA256SUMS digest, not the tarball, so it shares the same bytes.

Measured on macOS 15 (darwin 25.6.0), Node 26.8.2, 12 cores, warm npm
cache, three runs each:

  test/install.test.ts alone: 11.19-12.21s -> 3.51-3.58s
  full `npm test` wall:       36.03-40.65s -> 34.09-35.52s

Not verified: Windows. These are local macOS numbers and do not
establish what the change does to the Windows core job in CI, which is
where #234's 4m56s was observed. The wall-clock figures above are a
12-core parallel run and are noisy; the per-file figure is the reliable
one.

Not changed: no test was converted from a spawned process to an
in-process call, no CLI coverage was dropped, and no OS or Node matrix
entry was touched. Sharding was not attempted.

Refs #234.

Co-Authored-By: Claude Opus 5 <[email protected]>
@jimhoyd
jimhoyd force-pushed the claude/issue-234-test-profile branch from 97d118b to 356d523 Compare September 20, 2026 05:29
@jimhoyd
jimhoyd merged commit 67a6996 into main Sep 20, 2026
20 checks passed
@jimhoyd
jimhoyd deleted the claude/issue-234-test-profile branch September 20, 2026 05:35
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