From 9118cbc2587d2cc568bb1ee27ab65a4ff8d2f338 Mon Sep 17 00:00:00 2001 From: Malte Ubl Date: Sat, 17 Oct 2026 20:34:49 -0700 Subject: [PATCH] Record corpus 5973's preflight baseline and skip the scaling test under ASan The order-parity baseline for the new corpus program records its module order and empty preflight diagnostics. Uncached sanitized builds rebuild the runtime for every compile, which takes longer than either measured size, so the compile-time growth test runs in the plain lane only. Co-Authored-By: Claude Opus 5.5 --- .../5973-large-closure-environment.ts.json | 6 +++ .../closure-environment-scaling.test.ts | 41 +++++++++---------- 2 files changed, 26 insertions(+), 21 deletions(-) create mode 100644 packages/compiler/test/ts7/baselines/order-parity/tests/corpus/5973-large-closure-environment.ts.json diff --git a/packages/compiler/test/ts7/baselines/order-parity/tests/corpus/5973-large-closure-environment.ts.json b/packages/compiler/test/ts7/baselines/order-parity/tests/corpus/5973-large-closure-environment.ts.json new file mode 100644 index 000000000..545536285 --- /dev/null +++ b/packages/compiler/test/ts7/baselines/order-parity/tests/corpus/5973-large-closure-environment.ts.json @@ -0,0 +1,6 @@ +{ + "order": [ + "/tests/corpus/5973-large-closure-environment.ts" + ], + "diags": [] +} diff --git a/tests/harness/closure-environment-scaling.test.ts b/tests/harness/closure-environment-scaling.test.ts index c6f3a09fe..785f07349 100644 --- a/tests/harness/closure-environment-scaling.test.ts +++ b/tests/harness/closure-environment-scaling.test.ts @@ -14,6 +14,8 @@ import { expect, test } from "vitest"; const execFileAsync = promisify(execFile); const repoRoot = join(import.meta.dirname, "../.."); +// Sanitized builds compile the runtime with each uncached build, which +// dwarfs both sizes; the growth this test bounds is the same in every lane. const sanitize = process.env["SCRIPTC_SAN"] === "1"; /** `n` number bindings plus n/20 objects and strings, all captured by a @@ -83,14 +85,7 @@ async function compileTime(dir: string, n: number): Promise { writeFileSync(entry, source); const { stderr } = await execFileAsync( process.execPath, - [ - join(repoRoot, "packages/cli/dist/main.js"), - "build", - entry, - "-o", - binary, - ...(sanitize ? ["--sanitize"] : []), - ], + [join(repoRoot, "packages/cli/dist/main.js"), "build", entry, "-o", binary], { env: { ...process.env, SCRIPTC_TIMING: "1", SCRIPTC_NO_CACHE: "1" }, maxBuffer: 16 * 1024 * 1024, @@ -113,16 +108,20 @@ async function compileTime(dir: string, n: number): Promise { return complete - loaded; } -test("compile time grows linearly with a shared closure environment", async () => { - const dir = mkdtempSync(join(tmpdir(), "scriptc-closure-scaling-")); - try { - const small = await compileTime(dir, 500); - const large = await compileTime(dir, 4000); - // Eight times the bindings. Linear growth stays at or below 8x (fixed - // costs keep it near 5x); the quadratic analyses and code generation - // measured 24x at these sizes, and every doubling beyond adds 4x. - expect(large / small, `${small.toFixed(0)} ms -> ${large.toFixed(0)} ms`).toBeLessThan(16); - } finally { - rmSync(dir, { recursive: true, force: true }); - } -}, 300_000); +test.skipIf(sanitize)( + "compile time grows linearly with a shared closure environment", + async () => { + const dir = mkdtempSync(join(tmpdir(), "scriptc-closure-scaling-")); + try { + const small = await compileTime(dir, 500); + const large = await compileTime(dir, 4000); + // Eight times the bindings. Linear growth stays at or below 8x (fixed + // costs keep it near 5x); the quadratic analyses and code generation + // measured 24x at these sizes, and every doubling beyond adds 4x. + expect(large / small, `${small.toFixed(0)} ms -> ${large.toFixed(0)} ms`).toBeLessThan(16); + } finally { + rmSync(dir, { recursive: true, force: true }); + } + }, + 300_000, +);