mirror of
https://github.com/morluto/rea.git
synced 2026-11-24 21:28:41 +00:00
perf(javascript): park the worker after preload-discovery allowance refusals
A scoped worker closed instead of parking after any failed analysis, so one member-mutation refusal during preload discovery discarded the process and every static checkpoint it retained. Discovery skips such a source and the normal pass analyzes and reports it again, and the worker reports the refusal while staying healthy. A discovery checkout whose failures are all member-mutation refusals now parks if canReuse still holds. Other failures, and any failure in a normal analysis, still close the worker. Co-Authored-By: gensokyo-dev <342580529+gensokyo-dev@users.noreply.github.com>
This commit is contained in:
1 parent
5b280e1f9f
commit
ef59a1f0a3
2 files changed
+100
-2
No files matched your search
@@ -1003,3 +1003,85 @@ it("keeps wrapped route ancestry, navigation and unknown named parents in the re
|
||||
await worker.close();
|
||||
}
|
||||
});
|
||||
|
||||
it.each([
|
||||
["preload-discovery", 1],
|
||||
["analysis", 2],
|
||||
] as const)(
|
||||
"after a %s member-mutation refusal, the next checkout uses %i launch(es)",
|
||||
async (purpose, expectedLaunches) => {
|
||||
const scope = new ArtifactResourceScope();
|
||||
const launches: number[] = [];
|
||||
const launcher: typeof spawnOwnedProviderProcess = async (request) => {
|
||||
const spawned = await spawnOwnedProviderProcess(request);
|
||||
if (spawned.process.pid !== undefined) launches.push(spawned.process.pid);
|
||||
return spawned;
|
||||
};
|
||||
const limits = {
|
||||
heapMb: 128,
|
||||
timeoutMs: 30_000,
|
||||
memberMutationAllowance: { aliasStates: 8, source: "runtime" } as const,
|
||||
};
|
||||
// Four conditional self-selections before one member write (#8294).
|
||||
const refused = source(
|
||||
"refused.js",
|
||||
[
|
||||
"function probe(input, env) { var m; if (env.first) m = env.first.info;",
|
||||
...Array.from(
|
||||
{ length: 4 },
|
||||
(_, index) =>
|
||||
`if (/case${String(index)}/.test(input)) m = m[${String(index % 2)}];`,
|
||||
),
|
||||
"m[1] = input.length; return m; } module.exports = probe;",
|
||||
].join(" "),
|
||||
);
|
||||
const accepted = source("accepted.js", "module.exports = 1;");
|
||||
try {
|
||||
const first = await createJavaScriptSourceAnalysis(limits, 2, {
|
||||
scope,
|
||||
launcher,
|
||||
});
|
||||
try {
|
||||
const capacity = { nodes: 0, unknowns: 0 };
|
||||
const refusal = await first.analyze(
|
||||
refused,
|
||||
capacity,
|
||||
undefined,
|
||||
undefined,
|
||||
"commonjs",
|
||||
purpose,
|
||||
);
|
||||
expect(refusal.ok).toBe(false);
|
||||
const success = await first.analyze(
|
||||
accepted,
|
||||
capacity,
|
||||
undefined,
|
||||
undefined,
|
||||
"commonjs",
|
||||
purpose,
|
||||
);
|
||||
if (!success.ok) throw success.error.error;
|
||||
} finally {
|
||||
await first.close();
|
||||
}
|
||||
// Discovery's refused source is analyzed again by the normal pass, so
|
||||
// only discovery parks its healthy worker; other failures still close it.
|
||||
const next = await createJavaScriptSourceAnalysis(limits, 1, {
|
||||
scope,
|
||||
launcher,
|
||||
});
|
||||
try {
|
||||
const result = await next.analyze(accepted, {
|
||||
nodes: 100,
|
||||
unknowns: 100,
|
||||
});
|
||||
if (!result.ok) throw result.error.error;
|
||||
} finally {
|
||||
await next.close();
|
||||
}
|
||||
expect(launches).toHaveLength(expectedLaunches);
|
||||
} finally {
|
||||
await scope.close();
|
||||
}
|
||||
},
|
||||
);
|
||||
Reference in new issue
Block a user