refactor: cache prepared statements in applyEdgeTechniquesAfterNativeInsert chunk loop#1891
Open
carlos-alm wants to merge 1 commit into
Conversation
…Insert chunk loop The technique/confidence backfill loop in applyEdgeTechniquesAfterNativeInsert re-prepared its two UPDATE statements on every chunk iteration instead of caching by chunk size. Apply the shared getOrCreatePerDbChunkStmt primitive (src/shared/chunked-stmt-cache.ts) with a persistent per-db WeakMap cache, matching the batchInsertEdges/batchInsertNodes caches in builder/helpers.ts — this function can run twice within a single buildEdges() call against the same db (once from insertNativeBulkEdges, once from reconnectReverseDepEdges), so a fresh per-call cache would still miss across that second invocation. Pure performance refactor: SQL text and behavior are unchanged. Fixes #1768 Impact: 1 functions changed, 4 affected
Contributor
Contributor
Codegraph Impact Analysis1 functions changed → 4 callers affected across 2 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 join this conversation on GitHub.
Already have an account?
Sign in to comment
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
applyEdgeTechniquesAfterNativeInsertre-prepare()d two SQL statements from scratch on every chunk iteration instead of caching by chunk size, in a hot transactional edge-finalization path.getOrCreatePerDbChunkStmtprimitive from Consider adopting chunk-size statement-cache helper in features/structure.ts::batchUpdateRoles #1767, using persistent per-db caching (not per-call): this function has two call sites withinbuildEdges()that both pass the identicalctx.dband can both execute in one incremental rebuild (unlikebatchUpdateRoles's mutually-exclusive full/incremental paths), and per-db keying is required for correctness anyway since prepared statements are bound to their originating connection (e.g.branch-compare.tscallsbuildGraph()twice against different DB connections in one process).Closes #1768
Test plan
npm test— full suite green (3542 passed, 0 failed), including the Incremental rebuild leaves edges.technique NULL for native-engine call edges (full build sets 'ts-native') #1744 backfill regression test (3/3 passed)npm run lint/npx tsc --noEmit— cleangit diff(no changes to the actual UPDATE statements' logic)Stacked on #1890 (base branch
fix/issue-1767-structure-chunked-stmt-cache) — only the build-edges.ts diff is this issue's change.