Skip to content

Commit dfa7424

Browse files
authored
perf(native): raise native edge-building threshold to smallFilesThreshold (#940)
The hardcoded > 3 threshold for native import/call edge building triggered on 5-file incremental builds, but the napi-rs marshaling cost (~13ms) exceeded Rust computation savings at that scale. Raise the threshold to use ctx.config.build.smallFilesThreshold (default 5) so small incremental builds use the JS edge path, aligning with the same threshold used for insertNodes and structure. Closes #936 Impact: 1 functions changed, 5 affected
1 parent 633efba commit dfa7424

1 file changed

Lines changed: 8 additions & 6 deletions

File tree

src/domain/graph/builder/stages/build-edges.ts

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -798,10 +798,11 @@ export async function buildEdges(ctx: PipelineContext): Promise<void> {
798798
}
799799
}
800800

801-
// Skip native import-edge path for small incremental builds (≤3 files):
802-
// napi-rs marshaling overhead exceeds computation savings.
801+
// Skip native import-edge path for small incremental builds: napi-rs
802+
// marshaling overhead (~13ms) exceeds Rust computation savings at this scale.
803803
const useNativeImportEdges =
804-
native?.buildImportEdges && (ctx.isFullBuild || ctx.fileSymbols.size > 3);
804+
native?.buildImportEdges &&
805+
(ctx.isFullBuild || ctx.fileSymbols.size > ctx.config.build.smallFilesThreshold);
805806
if (useNativeImportEdges) {
806807
const beforeLen = allEdgeRows.length;
807808
buildImportEdgesNative(ctx, getNodeIdStmt, allEdgeRows, native!);
@@ -821,10 +822,11 @@ export async function buildEdges(ctx: PipelineContext): Promise<void> {
821822
buildImportEdges(ctx, getNodeIdStmt, allEdgeRows);
822823
}
823824

824-
// Skip native call-edge path for small incremental builds (≤3 files):
825-
// napi-rs marshaling overhead for allNodes exceeds computation savings.
825+
// Skip native call-edge path for small incremental builds: napi-rs
826+
// marshaling overhead for allNodes exceeds Rust computation savings.
826827
const useNativeCallEdges =
827-
native?.buildCallEdges && (ctx.isFullBuild || ctx.fileSymbols.size > 3);
828+
native?.buildCallEdges &&
829+
(ctx.isFullBuild || ctx.fileSymbols.size > ctx.config.build.smallFilesThreshold);
828830
if (useNativeCallEdges) {
829831
buildCallEdgesNative(ctx, getNodeIdStmt, allEdgeRows, allNodesBefore, native!);
830832
} else {

0 commit comments

Comments
 (0)