#2810

A build loads the program twice per island round, each load a cold tsc-ts server

Opencramforceopened 11d ago

A build starts a fresh tsc-ts server for every frontend load and loads the program twice per island round

Measurements

scriptc build packages/coding-agent/src/cli.ts --node-islands=auto --npm-static <14 packages> (pi), SCRIPTC_TIMING=1, 8 vCPU Sandbox, cold cache, on main + #2807 (bc19267d9 + the coverage fix; builds are unaffected by it):

phaseround 1round 2round 3
frontend-load159.0 s169.4 s159.2 s
frontend-island-reload100.7 s105.2 s62.4 s
lower26.4 s20.6 s— (build failed after the reload)
  • The whole build is one frontend-process: 803.4 s, total build time=804.14s, peak RSS 2.8 GB, rc=1 (96 diagnostics).
  • Loading is 756 s of the 803 s (94%); lowering is 47 s.
  • A per-3 s process sample counted 83 distinct tsc-ts processes during the build (median life 18 s: 35 lived ≤6 s, 26 7–21 s, 9 22–60 s, 13 >60 s), at most 3 at once.

Why

Every createFrontend call builds its own FrontendServices (packages/compiler/src/index.ts:492), which owns the program hosts and their tsc-ts connections (frontend/services.ts, createProgramHost). #2650's reuse (reuseProgramHosts(PROGRAM_HOST_LOADS)) lets a host serve up to 4 loads inside one FrontendServices, so it never spans the loads that matter:

  • executable/prepare.ts:84 creates a frontend with islandScan, prepare.ts:103 disposes it and creates a second one with islandPackages — the same round loads the program twice, on two cold servers, each re-typechecking the whole program and its libraries.
  • The island retry recurses into prepareExecutableModule (prepare.ts:190, :220) with the grown set, which starts the pair over: another two cold loads, another two servers.
  • The remaining short-lived servers are helpers rooted at the entry's directory (--cwd …/packages/coding-agent/src; 7 distinct in a 167 s window against 14 rooted at the project), one fresh process each.

The same shape cost the coverage analysis a second full lowering on pi; #2807 removes that one by deciding graph-proven islands before the first lowering (node-islands/graph-islands.ts).

Directions

  • Share one FrontendServices per build (i.e. per frontend-process) instead of one per createFrontend, so the island reload and the retry rounds rebind idle hosts instead of starting cold servers.
  • Decide the graph-proven islands before the first load, as #2771 does for builds, so most rounds disappear rather than becoming cheaper.

Activity

0

No activity yet.