perf(native): index call-binding parameter and return nodes

Build ordered per-procedure indices from admitted nodes instead of scanning every node twice for each call binding. Preserve edge order, capacity limits, omitted-parameter unknowns, and surviving return bindings.

Validation: five focused service tests and check:fast passed. Four paired Flameox blocks at 4096 call sites passed all eight full-result digest oracles. Median paired reduction was 183.02 ms (71.4%) on this synthetic fan-out workload; real-provider performance is unverified.

Flameox evidence: 5a4c98ed7d224587c10a0f4596c8680d3a0330eb112a629014448ff1ea4634e7.
This commit is contained in:
morluto
2026-10-11 09:33:36 +08:00
parent 31bfff6fdf
commit 044aa34ce6
2 changed files with 223 additions and 9 deletions
+18 -9
View File
@@ -305,10 +305,24 @@ export const traceNativeValues = async (
"No seed function could be analyzed",
),
);
const parametersByProcedure = new Map<string, typeof nodes>();
const returnsByProcedure = new Map<string, typeof nodes>();
for (const node of nodes) {
if (node.kind === "parameter") {
const parameters = parametersByProcedure.get(node.procedure) ?? [];
parameters.push(node);
parametersByProcedure.set(node.procedure, parameters);
} else if (
node.operation?.opcode === "RETURN" &&
node.operation.inputs.length > 1
) {
const returns = returnsByProcedure.get(node.procedure) ?? [];
returns.push(node);
returnsByProcedure.set(node.procedure, returns);
}
}
for (const binding of callBindings) {
const parameters = nodes.filter(
(node) => node.procedure === binding.callee && node.kind === "parameter",
);
const parameters = parametersByProcedure.get(binding.callee) ?? [];
if (parameters.length === 0)
unknowns.push({
procedure: binding.caller,
@@ -339,12 +353,7 @@ export const traceNativeValues = async (
});
}
if (binding.output)
for (const node of nodes.filter(
(node) =>
node.procedure === binding.callee &&
node.operation?.opcode === "RETURN" &&
node.operation.inputs.length > 1,
)) {
for (const node of returnsByProcedure.get(binding.callee) ?? []) {
if (edges.length >= input.max_edges) {
truncated = true;
break;