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

mason/forge:mason/12493-a-forge-on-a-migrated-empty-data-directo → main 0 commits fork 3 threads · 3 unresolved

  • Merged. mason/12493-a-forge-on-a-migrated-empty-data-directo was merged into main as 5ca0c22.

Review

Sign in to review this change.
2 files changed +25 −3
scripts/rehearse-roll.ts +13 −2
@@ -19,7 +19,7 @@
1919 * environment, never this shell's.
2020 */
2121
22 import { cpSync, mkdirSync, mkdtempSync, rmSync } from "node:fs";
22 import { cpSync, existsSync, mkdirSync, mkdtempSync, rmSync } from "node:fs";
2323 import { tmpdir } from "node:os";
2424 import { join, resolve } from "node:path";
2525 import { freePort, lostPort, PORT_RETRIES } from "../src/kernel/port.ts";
@@ -50,6 +50,17 @@ interface Forge {
5050 readonly portsLost: number;
5151 }
5252
53 /**
54 * The file a checkout boots from: its `src/main.ts`, or the `main.js` of a bundle
55 * (`bun build --target bun --outdir <checkout> src/main.ts`) when it has no source.
56 * A bundle skips parsing the source tree, which is most of a boot's first seconds (#12493).
57 */
58 function entryOf(checkout: string): string {
outdated

This new doc block splits start()'s existing doc comment (about the port race) from start(). Put entryOf and its comment above that older comment.

59 const source = join(checkout, "src", "main.ts");
60 const bundle = join(checkout, "main.js");
61 return !existsSync(source) && existsSync(bundle) ? bundle : source;
62 }
63
5364 /**
5465 * A forge on a port free a moment ago. Between the probe that found it and
5566 * the forge's bind, another process can take it — a gate shard's listener,
@@ -79,7 +90,7 @@ async function start(
7990 const v = process.env[pass];
8091 if (v !== undefined) env[pass] = v;
8192 }
82 const proc = Bun.spawn([process.execPath, join(checkout, "src", "main.ts")], {
93 const proc = Bun.spawn([process.execPath, entryOf(checkout)], {
8394 cwd: checkout,
8495 env,
8596 stdin: "ignore",
test/helpers/real-roll.ts +12 −1
@@ -11,16 +11,26 @@
1111 import { mkdtempSync, rmSync } from "node:fs";
1212 import { tmpdir } from "node:os";
1313 import { join } from "node:path";
14 import { bundleBoot } from "./bundle-boot.ts";
1415 import { createApp } from "../../src/app.ts";
1516 import { rehearse } from "../../scripts/rehearse-roll.ts";
1617 import { parseArgs } from "../../scripts/rehearsal.ts";
1718
1819 export async function realRoll(lingerS: number): Promise<Awaited<ReturnType<typeof rehearse>>> {
1920 const seeded = join(mkdtempSync(join(tmpdir(), "forge-rehearsal-seed-")), "data");
21 const built = mkdtempSync(join(tmpdir(), "forge-rehearsal-bundle-"));
2022 try {
2123 createApp({ dataDir: seeded, port: 0 }).close();
24 // Both forges boot from one bundle of src/main.ts, built once: booting the source
25 // loads about 4,000 modules each time, 3 s or more of a roll's two boots (#12493).
26 // So these rolls rehearse the bundle, not the `bun src/main.ts` boot production runs:
27 // the roll's handover, drain and probes are the same code, but the workers main.ts
outdated

This makes the rolls rehearse the bundle, not the bun src/main.ts boot that production runs. If the bound in the issue is the goal, a test of the real boot's spawn-to-ready is what is missing.

28 // starts by file (`new Worker(new URL("./x.ts", …))`: looks, scans, run logs) are not
outdated

Unexplained false argument: say what it means at the call site.

29 // in the bundle. Nothing in a roll with FORGE_APPS and FORGE_CHECKS off reaches them;
30 // the source boot itself is held by the tests that spawn src/main.ts.
31 bundleBoot(built, /* bytecode */ false); // false: a plain main.js, which `entryOf` finds in `built`
2232 return await rehearse({
23 ...parseArgs([], `${import.meta.dir}/../..`),
33 ...parseArgs([], built),
2434 from: seeded,
2535 // Room for a slow boot and a long linger on a busy machine (#2020).
2636 seconds: 30,
@@ -36,5 +46,6 @@ export async function realRoll(lingerS: number): Promise<Awaited<ReturnType<type
3646 });
3747 } finally {
3848 rmSync(join(seeded, ".."), { recursive: true, force: true });
49 rmSync(built, { recursive: true, force: true });
3950 }
4051 }

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

Keyboard shortcuts

Docs