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

A forge on a migrated, empty data directory is ready in under 1.5 s, so the real rolls leave the SLOW list #17009

Merged opened this

Check · Review · Land · Live done — Landed and live in production.

Merged

The two real-roll tests now boot both forges from one bundle of src/main.ts, built once, so each roll skips parsing the source tree twice. The bun src/main.ts boot itself is unchanged, and I did not get it under 1.5 s. What changed scripts/rehearse-roll.ts: a new entryOf(checkout) picks the file a forge boots from.

Notes

opened this

The two real-roll tests now boot both forges from one bundle of src/main.ts, built once, so each roll skips parsing the source tree twice. The bun src/main.ts boot itself is unchanged, and I did not get it under 1.5 s.

What changed

  • scripts/rehearse-roll.ts: a new entryOf(checkout) picks the file a forge boots from. It is src/main.ts as before, or a bundle's main.js when the checkout has no src/.
  • test/helpers/real-roll.ts: builds the bundle once with the existing bundleBoot helper from #16853. Old and new forge both boot from it, and the temp directory is removed afterwards. The 1 s settle and 2 s linger windows are untouched.

Measurements (the box was at load average about 240 on 72 cores, so absolute numbers are inflated and only the ratios mean much)

BootSpawn to /readyz 200
Source12–15 s
Bundle3.4–4 s
Compiled --bytecode build1.7–1.8 s
  • test/rehearsal-real.test.ts took 27.6 s alone before. It and test/rehearsal-abrupt.test.ts together took 17.3 s after, so about 8.6 s a file.
  • The 1.5 s boot target is not met, and I could not tell whether the bytecode build would meet it on a quiet box.
  • Those two files are not in scripts/gate.ts SLOW on this base, so there was nothing to remove there.
  • bun x tsc --noEmit is clean and test/rehearsal.test.ts passes (18 tests). bun scripts/gate.ts --fix changed nothing.

What I chose not to do

  • I did not change how production boots or ships. forge.json still runs bun run src/main.ts.
  • I did not use the compiled --bytecode build in the rolls. It is faster, but it is a compiled executable rather than the file the forge runs.

How the roll now differs from a source boot

  • The bundle does not yet carry the page and look workers, so those log a warning and degrade. A roll does not exercise them.
  • The roll rehearses the same code but not the source-tree boot. test/bundle-boot.test.ts is what proves the bundle boots and answers.

To try it: bun test test/rehearsal-real.test.ts test/rehearsal-abrupt.test.ts.

🤖 Generated with Claude Code

Closes #12493

3 earlier comments
commented

The two real-roll tests now boot both forges from one bundle of src/main.ts, built once, so each roll skips parsing the source tree twice. The bun src/main.ts boot itself is unchanged, and I did not get it under 1.5 s.

What changed

  • scripts/rehearse-roll.ts: a new entryOf(checkout) picks the file a forge boots from. It is src/main.ts as before, or a bundle's main.js when the checkout has no src/.
  • test/helpers/real-roll.ts: builds the bundle once with the existing bundleBoot helper from #16853. Old and new forge both boot from it, and the temp directory is removed afterwards. The 1 s settle and 2 s linger windows are untouched.

Measurements (the box was at load average about 240 on 72 cores, so absolute numbers are inflated and only the ratios mean much)

BootSpawn to /readyz 200
Source12–15 s
Bundle3.4–4 s
Compiled --bytecode build1.7–1.8 s
  • test/rehearsal-real.test.ts took 27.6 s alone before. It and test/rehearsal-abrupt.test.ts together took 17.3 s after, so about 8.6 s a file.
  • The 1.5 s boot target is not met, and I could not tell whether the bytecode build would meet it on a quiet box.
  • Those two files are not in scripts/gate.ts SLOW on this base, so there was nothing to remove there.
  • bun x tsc --noEmit is clean and test/rehearsal.test.ts passes (18 tests). bun scripts/gate.ts --fix changed nothing.

What I chose not to do

  • I did not change how production boots or ships. forge.json still runs bun run src/main.ts.
  • I did not use the compiled --bytecode build in the rolls. It is faster, but it is a compiled executable rather than the file the forge runs.

How the roll now differs from a source boot

  • The bundle does not yet carry the page and look workers, so those log a warning and degrade. A roll does not exercise them.
  • The roll rehearses the same code but not the source-tree boot. test/bundle-boot.test.ts is what proves the bundle boots and answers.

To try it: bun test test/rehearsal-real.test.ts test/rehearsal-abrupt.test.ts.

🤖 Generated with Claude Code

commented

This change cuts the real rolls' boot time but does not meet the issue's 1.5 s spawn-to-ready target. Nothing was added to src/main.ts, and no spawn-to-ready test was added. I fixed the two small review points; the two larger ones need a person's call.

What changed

  • The real rolls (rehearsal-real and rehearsal-abrupt) boot both forges from one bundle of src/main.ts, built once. Each roll no longer parses the source tree twice.
  • entryOf in scripts/rehearse-roll.ts now sits above its own function. start()'s port-race comment is back directly above start().
  • The bundleBoot(built, false) call in test/helpers/real-roll.ts now says what false means: a plain main.js, not a bytecode executable.
  • I ran bun x tsc --noEmit and rehearsal-real.test.ts (3 pass). bun scripts/gate.ts --fix found nothing to rewrap. The gate's note about one comment line over 100 columns in scripts/rehearse-roll.ts is the nightly rewrap's to do on main.

Not done

  • 1.5 s boot. The real bun src/main.ts boot is unchanged, at 12–15 s from source and about 3.4–4 s from the bundle. Reaching 1.5 s means finding what to import lazily with --cpu-prof, or shipping the bundle as the boot (the bytecode build in test/helpers/bundle-boot.ts is a candidate). That is a change to src/main.ts and to how the forge starts. I think it belongs in its own issue, not folded into this one. I did not measure the lazy-import route.
  • SLOW list. I did not touch scripts/gate.ts. The sentinel says the two rehearsal tests are not in SLOW on this base, so no per-file budget is shown for them. They run well under the test budget, so I did not add them.

I disagree that this pull alone can meet the issue. I'd re-scope the issue's first box to "rolls skip parsing the tree twice" and open a separate issue for the 1.5 s boot of src/main.ts.

commented

This pull does not close #12493. Its two real rolls (rehearsal-real and rehearsal-abrupt) now boot both forges from one bundle of src/main.ts, built once. Their two boots skip loading the source tree, but the forge's own bun src/main.ts boot is unchanged. Both reviewers were right that box 1 (spawn to ready under 1.5 s) is not met.

Why the real boot is not cut here. Spawn to first /readyz 200, on an empty migrated directory with this box loaded (72 cores, load ~110):

BootTime
bun src/main.ts3.8–4.4 s
The bundle of it1.3–1.55 s

The cost is loading modules. main.ts reaches 3,985 modules (22 MB) without any lazy imports. The profile puts its samples at the root because Bun loads modules outside JS: 94 samples in 4.5 s.

What the 1.5 s needs. It is more than one run, so I split it into three issues, and #12493 now waits on all three:

  • #17019: the boot can run the bundle. That means emitting the workers that main.ts starts by file path, which the bundle does not include today. The owner decides whether production boots it, and a test asserts spawn to ready under 1.5 s.
  • #17020: server.ts loads page, studio, render and API modules on the first request to their prefix. This is the unticked box of #16852; 752 modules load only through server.ts.
  • #17021: main.ts imports each background service when it starts it. Even with every page family lazy, 2,437 modules would still load from those service imports.

Box 2. Neither rehearsal test is in SLOW on main; they left it in bb5a2ad33 (#12443). I said so on #12493: box 2 can be ticked as already true or dropped, at the owner's call.

Review fixes:

  • scripts/rehearse-roll.ts: entryOf and its doc comment now sit above start()'s port-race comment, so that comment is next to start() again.
  • test/helpers/real-roll.ts:
    • The false passed to bundleBoot is now explained: a plain main.js, not a bytecode build.
    • The comment now says plainly that these rolls rehearse the bundle, not the source boot production runs.
    • It also says the workers started by file path (looks, scans, run logs) are not in the bundle, and that a roll with apps and checks off does not reach them.

bun x tsc --noEmit and the gate are clean, and test/rehearsal-real.test.ts plus test/rehearsal-abrupt.test.ts pass (4 tests, 14.3 s together).

My first attempt to open the issues left an empty "t" issue; I rewrote it as #17019, so nothing stray is left.

🤖 Generated with Claude Code

commented

Left #12493 open: 1 unticked item remain (Find what src/main.ts spends its first 3 s on before reconciled on an empty migrated directory (a --cpu-prof of the boot puts most samples at the root, not in forge code), and cut it so spawn to ready is under 1.5 s there.).

Sign in to join this conversation.

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

Keyboard shortcuts

Docs