Avoid rehashing validated Graph execution metadata during Candidate loading
This commit is contained in:
@@ -130,7 +130,7 @@ export async function loadCheckedInstallationCandidate(
|
|||||||
const expectedGraph = graphExecutionRepresentation(plan, installation, kernel, queries);
|
const expectedGraph = graphExecutionRepresentation(plan, installation, kernel, queries);
|
||||||
// The stored graph embeds the same kernel/query programs. Validate it in a
|
// The stored graph embeds the same kernel/query programs. Validate it in a
|
||||||
// short-lived scope and retain the representation that shares those trees.
|
// short-lived scope and retain the representation that shares those trees.
|
||||||
await (async () => {
|
const graphDigest = await (async () => {
|
||||||
const input = await readJson(root, "graph-execution.json", scope);
|
const input = await readJson(root, "graph-execution.json", scope);
|
||||||
try {
|
try {
|
||||||
const digest = await hexDigestAsync(input.value);
|
const digest = await hexDigestAsync(input.value);
|
||||||
@@ -140,6 +140,7 @@ export async function loadCheckedInstallationCandidate(
|
|||||||
root,
|
root,
|
||||||
"Stored graph execution differs from checked inputs",
|
"Stored graph execution differs from checked inputs",
|
||||||
);
|
);
|
||||||
|
return digest;
|
||||||
} finally {
|
} finally {
|
||||||
input.releaseTree();
|
input.releaseTree();
|
||||||
}
|
}
|
||||||
@@ -168,7 +169,8 @@ export async function loadCheckedInstallationCandidate(
|
|||||||
return {
|
return {
|
||||||
reference,
|
reference,
|
||||||
workspace: plan.definition.workspace.workspaceId,
|
workspace: plan.definition.workspace.workspaceId,
|
||||||
world: await hexDigestAsync(expectedGraph),
|
// The checked representation was already compared with this digest.
|
||||||
|
world: graphDigest,
|
||||||
plan: kernel.plan as string,
|
plan: kernel.plan as string,
|
||||||
graphExecution: expectedGraph,
|
graphExecution: expectedGraph,
|
||||||
provenance,
|
provenance,
|
||||||
|
|||||||
@@ -5,6 +5,7 @@ import { join } from "node:path";
|
|||||||
import { tmpdir } from "node:os";
|
import { tmpdir } from "node:os";
|
||||||
import { CandidateMetadataBudget, readCandidateMetadata } from "../src/execution-world/metadata.js";
|
import { CandidateMetadataBudget, readCandidateMetadata } from "../src/execution-world/metadata.js";
|
||||||
import { loadCheckedInstallationCandidate } from "../src/execution-world/candidate.js";
|
import { loadCheckedInstallationCandidate } from "../src/execution-world/candidate.js";
|
||||||
|
import { hexDigestAsync } from "../src/execution-world/plan.js";
|
||||||
|
|
||||||
test(
|
test(
|
||||||
"a real checked application can stage its replacement within the default metadata budget",
|
"a real checked application can stage its replacement within the default metadata budget",
|
||||||
@@ -21,6 +22,8 @@ test(
|
|||||||
try {
|
try {
|
||||||
assert.equal(budget.snapshot().bytes, retained * 2);
|
assert.equal(budget.snapshot().bytes, retained * 2);
|
||||||
assert.deepEqual(second.reference, first.reference, "Compaction preserves exact checked identity");
|
assert.deepEqual(second.reference, first.reference, "Compaction preserves exact checked identity");
|
||||||
|
assert.equal(first.world, await hexDigestAsync(first.graphExecution));
|
||||||
|
assert.equal(second.world, first.world, "Replacement retains the checked execution identity");
|
||||||
assert.equal(second.graphExecution.kernel, second.kernel, "Graph representation shares the validated program");
|
assert.equal(second.graphExecution.kernel, second.kernel, "Graph representation shares the validated program");
|
||||||
assert.equal(second.graphExecution.queries, second.queries);
|
assert.equal(second.graphExecution.queries, second.queries);
|
||||||
// A deliberately tighter pool admits the serving installation but must
|
// A deliberately tighter pool admits the serving installation but must
|
||||||
|
|||||||
Reference in New Issue
Block a user