Avoid partial word index rebuilds#330
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: fc6dff64fc
ℹ️ 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".
| self.mu.lock(); | ||
| defer self.mu.unlock(); | ||
| self.word_index.deinit(); | ||
| self.word_index = rebuilt; |
There was a problem hiding this comment.
Rebuild word index under writer lock to avoid lost updates
rebuildWordIndex now does most of its work without holding the write lock, then swaps self.word_index at the end. In MCP/serve mode, queries can run concurrently with watcher.incrementalLoop updates (commitParsedFileOwnedOutline/removeFile), so updates applied while rebuild is in progress can be overwritten by this final assignment, leaving word_index_complete = true but missing recent file changes until another mutation happens. The previous implementation rebuilt while holding the writer lock, so this is a correctness regression under concurrent query + file-change workloads.
Useful? React with 👍 / 👎.
What changed
WordIndexIncompletewhen only a partial snapshot cache exists and no source root is available.Validation
zig build testzig buildFixes the review finding on #329 where a fresh machine with only
codedb.snapshotand no readableword.indexcould misscodedb_wordhits after the 1000-file content cache cap.