Cache snapshot responses by store sequence#326
Conversation
Benchmark Regression ReportThresholds: 10.00% and 50,000 ns absolute delta
|
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: d99041bb0b
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
| const seq = store.currentSeq(); | ||
| if (cache.appendIfFresh(alloc, out, seq)) return; | ||
|
|
There was a problem hiding this comment.
Avoid caching snapshot before explorer catches up
handleSnapshot reads store.currentSeq() and uses it as the cache key before building the snapshot; that assumes explorer state is already synchronized with that seq. In the watcher path, incrementalDiff calls store.recordSnapshot(...) first and only then runs indexFileContent(...) (src/watcher.zig around lines 1001-1007), so a concurrent codedb_snapshot can cache pre-update explorer data under the new seq. Once this happens, later snapshot calls with that same seq will keep returning stale output until another write advances the seq, which is a user-visible correctness regression.
Useful? React with 👍 / 👎.
Summary
codedb_snapshotresponses per default/project context usingStore.currentSeq()as the freshness keyLocal benchmark
Compared this branch against current
origin/release/0.2.579after #325:codedb_snapshot:602450 ns->68050 ns(-88.70%,-534400 ns)This stacks on top of #325's JSON-generation improvement. After this change, repeated snapshot calls mostly pay for copying the cached response into the MCP output buffer.
Validation
zig build testzig buildpython3 scripts/run-bench-json.py /tmp/codedb-cache-head.json/tmp/codedb-release-cache-baseatorigin/release/0.2.579