mirror of
https://github.com/vercel-labs/scriptc.git
synced 2026-10-30 07:14:39 +08:00
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 <noreply@anthropic.com>
This commit is contained in:
co-authored by
Claude Opus 5.5
parent
8c8ee28413
commit
9118cbc258
+6
@@ -0,0 +1,6 @@
|
||||
{
|
||||
"order": [
|
||||
"<repo>/tests/corpus/5973-large-closure-environment.ts"
|
||||
],
|
||||
"diags": []
|
||||
}
|
||||
@@ -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<number> {
|
||||
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<number> {
|
||||
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,
|
||||
);
|
||||
|
||||
Reference in New Issue
Block a user