perf(db): batch node lookups, fix insertNode cache, run maintenance after writes (#108)

Batch getNodesByIds to collapse N+1 reads in graph traversal, invalidate the
insertNode LRU cache so INSERT OR REPLACE doesn't serve a stale row, and run
incremental PRAGMA optimize + passive WAL checkpoint after bulk writes.

Closes #108
This commit is contained in:
andreinknv
2026-05-22 13:16:34 -05:00
committed by GitHub
parent 4e34ba8399
commit b13f2f1ba1
5 changed files with 330 additions and 47 deletions
+11
View File
@@ -347,6 +347,12 @@ export class CodeGraph {
});
}
// Refresh planner stats + checkpoint the WAL after bulk writes.
// Cheap and non-blocking; never load-bearing for correctness.
if (result.success && result.filesIndexed > 0) {
this.db.runMaintenance();
}
return result;
} finally {
this.fileLock.release();
@@ -428,6 +434,11 @@ export class CodeGraph {
}
}
// Refresh planner stats + checkpoint the WAL after bulk writes.
if (result.filesAdded > 0 || result.filesModified > 0 || result.filesRemoved > 0) {
this.db.runMaintenance();
}
return result;
} finally {
this.fileLock.release();