Persist project-cache snapshot after CLI indexing#343
Persist project-cache snapshot after CLI indexing#343justrach merged 1 commit intorelease/0.2.579from
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: 9500977377
ℹ️ 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".
| if (!std.mem.eql(u8, cmd, "snapshot")) { | ||
| snapshot_mod.writeProjectCacheSnapshot(io, &explorer, abs_root, allocator) catch |err| { | ||
| std.log.warn("could not persist project-cache snapshot: {}", .{err}); |
There was a problem hiding this comment.
Avoid blocking CLI scans on full project-cache snapshot write
This new unconditional call runs after every non-snapshot cold scan, so commands like tree and search now synchronously generate a full snapshot before returning. On larger repos (especially once in-memory content caching is exceeded), writeSnapshot re-reads uncached files from disk while writing the CONTENT section, effectively adding a second filesystem pass and causing a significant regression on the benchmark-critical indexing path (likely above the 10% threshold). Consider persisting this cache asynchronously or gating it so normal CLI scans do not pay full snapshot-write cost.
Useful? React with 👍 / 👎.
Summary
~/.codedb/projects/<hash>/codedb.snapshotafter normal CLI scanscodedb /path treedoes not create/path/codedb.snapshotsnapshotmode and truncateproject.txtwhen refreshingProjectCacheloading a project from the central snapshot cache onlyWhy
codedb /path treeprintedindexed, but a later MCP call withproject=/pathfailed withSnapshotLoadFailedbecause only side indexes were persisted. After this change, CLI indexing and MCP project loading agree on the cache contract.Validation
zig build testzig build -Doptimize=ReleaseFastcodedb /path tree, verify no root snapshot, verify central snapshot exists, verify MCPcodedb_tree,codedb_symbol, andcodedb_statusloadproject=/path