Repository navigation
perf(builder): cache prepared statements in technique-backfill chunk loops (#1952) - #2204
Merged
Merged
Conversation
…loops backfillIncrementalEdgeTechniques (incremental.ts) and backfillEdgeTechniquesAfterNativeOrchestrator + findOneHopReverseDepFiles (native-orchestrator.ts) each re-prepared their chunk-loop statements on every iteration, mirroring the anti-pattern already fixed in applyEdgeTechniquesAfterNativeInsert (#1768). Reuses the same getOrCreatePerDbChunkStmt chunk-size-keyed cache helper for all three, scoped per db via a dedicated WeakMap cache per statement. No behavior change — verified the technique/confidence-floor backfill still lands correctly on a real incremental rebuild (zero NULL-technique and zero below-floor ts-native calls edges after rebuild). No README.md/CLAUDE.md/ROADMAP.md changes needed, docs check acknowledged. Closes #1952 Impact: 3 functions changed, 7 affected
Contributor
Greptile SummaryThis PR caches chunk-size-specific SQLite statements used by incremental and native-orchestrator technique backfills, avoiding repeated preparation while preserving existing SQL behavior.
Confidence Score: 5/5The PR appears safe to merge, with the cached statements preserving the prior queries, parameter ordering, and per-database lifecycle. Cache entries are isolated by database object and exact chunk size, while generated placeholders and runtime bindings remain aligned for both complete and partial chunks. Important Files Changed
Reviews (1): Last reviewed commit: "perf(builder): cache prepared statements..." | Re-trigger Greptile |
Contributor
Codegraph Impact Analysis3 functions changed → 7 callers affected across 4 files
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to subscribe to this conversation on GitHub.
Already have an account?
Sign in.
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Issue #1768/#1767 fixed the re-prepare-per-chunk anti-pattern in
applyEdgeTechniquesAfterNativeInsert(stages/build-edges.ts) using a chunk-size-keyedWeakMapstatement cache (getOrCreatePerDbChunkStmtinsrc/shared/chunked-stmt-cache.ts). That PR explicitly named two sibling functions with the identical pattern as out of scope, filed here per the one-PR-per-concern rule:backfillIncrementalEdgeTechniques(incremental.ts) — same two-statement chunk-of-500 loopbackfillEdgeTechniquesAfterNativeOrchestrator(stages/native-orchestrator.ts) — same two-statement chunk loopfindOneHopReverseDepFiles(stages/native-orchestrator.ts) — a third chunked loop in the same file, a single re-prepared SELECT per chunkThis PR applies the same fix to all three, reusing the existing
getOrCreatePerDbChunkStmthelper (not reinventing it) with a dedicated per-functionWeakMapcache, mirroring the naming and structure of the already-mergedtechniqueBackfillStmtCache/confidenceFloorStmtCachepair inbuild-edges.ts.Verification
npx tsc --noEmit: cleannpm run lint: cleannpm test: 260 files, 4197 passed, 30 skipped, 2 todo, 0 failedsrc/, confirmed zerocallsedges withtechnique IS NULLand zerots-nativeedges below the confidence floor after rebuild — same correctness as before, just fewer redundantdb.prepare()calls per chunkNo behavior change — this is purely a caching refactor of internal chunk loops, not urgent per the issue but small and low-risk to land.
Closes #1952