Skip to content

Commit eb5cd2a

Browse files
committed
perf(native): skip backfill on incrementals when orchestrator preserved files
#1069 made `backfillNativeDroppedFiles` run on every successful orchestrator pass — including incrementals — to repair `nodes`/`file_hashes` rows the orchestrator deleted for files outside its narrower file_collector (Clojure, Julia, R, Erlang, F#, Gleam, etc.). #1070 then taught the orchestrator's `detect_removed_files` to skip those extensions, so a current-binary 1-file rebuild reports `removedCount=0` and the orchestrator never deletes the dropped-language rows in the first place. But the JS side kept calling backfill unconditionally — wasting ~45ms per incremental on this repo (fs walk + 2 DB queries + WASM re-parse of all 48 unsupported-extension fixture files) repairing a gap that no longer exists. Gate the backfill call on `result.isFullBuild || result.removedCount > 0`: - Full builds: backfill runs (orchestrator never inserted dropped-language files, gap-fill is the whole point). - Incrementals on a current binary with #1070: `removedCount=0`, backfill skipped, no work needed. - Incrementals on a legacy binary (≤3.9.6) without #1070: `removedCount>0`, backfill runs, gap-repair behavior preserved. Local measurement on this repo (incremental-benchmark.ts, native engine): before: 1-file rebuild ~108ms (post-revert main, no fix) after: 1-file rebuild ~60ms Closes #1075.
1 parent 21b0b6f commit eb5cd2a

1 file changed

Lines changed: 11 additions & 9 deletions

File tree

src/domain/graph/builder/pipeline.ts

Lines changed: 11 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -753,15 +753,17 @@ async function tryNativeOrchestrator(
753753
// stale native binaries). WASM handles those — backfill via WASM so both
754754
// engines process the same file set (#967).
755755
//
756-
// Runs on every successful orchestrator pass (not just full builds): on
757-
// incrementals the orchestrator's change detection treats files outside
758-
// Rust's narrower file_collector as `removed` and deletes their nodes +
759-
// file_hashes rows. Without re-running the backfill we'd lose the symbols
760-
// for those files and permanently break the JS-side fast-skip pre-flight
761-
// (#1054, #1068). The function is cheap (single fs scan + DB query) when
762-
// nothing is missing, and on no-op rebuilds the missing-set is re-derived
763-
// from `nodes`, so it catches whatever Rust just deleted.
764-
await backfillNativeDroppedFiles(ctx);
756+
// Runs on full builds and on incrementals when the orchestrator reports
757+
// any deletions. The orchestrator's `detect_removed_files` filter (#1070)
758+
// skips files outside its narrower file_collector, so on a current binary
759+
// an unchanged 1-file rebuild reports `removedCount=0` and the backfill
760+
// call is pure overhead (fs walk + 2 DB queries + 48-file WASM re-parse).
761+
// Legacy binaries lacking the filter still report `removedCount>0` and
762+
// get the gap-repair behavior #1068 introduced.
763+
const removedCount = result.removedCount ?? 0;
764+
if (result.isFullBuild || removedCount > 0) {
765+
await backfillNativeDroppedFiles(ctx);
766+
}
765767

766768
closeDbPair({ db: ctx.db, nativeDb: ctx.nativeDb });
767769
return formatNativeTimingResult(p, structurePatchMs, analysisTiming);

0 commit comments

Comments
 (0)