Skip to content

Reduce MCP snapshot RSS#329

Merged
justrach merged 1 commit intorelease/0.2.579from
fix/mcp-snapshot-rss
Apr 26, 2026
Merged

Reduce MCP snapshot RSS#329
justrach merged 1 commit intorelease/0.2.579from
fix/mcp-snapshot-rss

Conversation

@justrach
Copy link
Copy Markdown
Owner

What changed

  • Make snapshot writing stream uncached file contents from disk so large outline-only indexes still produce loadable snapshots.
  • Cap fast snapshot restore content retention at 1000 files instead of loading every file body and freeing it afterward.
  • Compact MCP snapshot-loaded sessions once ready, releasing raw contents when a valid disk word index is available.
  • Make codedb snapshot persist a valid disk word index by streaming source files when the in-memory word index was skipped for a low-memory scan.
  • Lazily load the disk word index for simple identifier codedb_search queries so exact/prefix searches stay fast without keeping raw contents resident.

Validation

  • zig build test
  • zig build
  • Synthetic 3000-file MCP bench: contents cache drops from 3000 to 0; repeated identifier search median ~0.15ms after first lazy word-index load.
  • Synthetic 2000-file large-content MCP bench: pre-search RSS drops from ~81MB to ~49MB; repeated identifier search median ~0.10ms after first lazy word-index load.

@github-actions
Copy link
Copy Markdown

Benchmark Regression Report

Thresholds: 10.00% and 50,000 ns absolute delta

NOISE means the percentage threshold was exceeded, but the absolute delta was too small to fail CI.

Tool Base (ns) Head (ns) Delta Abs Delta (ns) Status
codedb_bundle 306889 327103 +6.59% +20214 OK
codedb_changes 31519 32285 +2.43% +766 OK
codedb_deps 5015 5035 +0.40% +20 OK
codedb_edit 4356 4312 -1.01% -44 OK
codedb_find 41304 46352 +12.22% +5048 NOISE
codedb_hot 57903 55652 -3.89% -2251 OK
codedb_outline 151594 162205 +7.00% +10611 OK
codedb_read 56121 56053 -0.12% -68 OK
codedb_search 143319 142765 -0.39% -554 OK
codedb_snapshot 184308 184792 +0.26% +484 OK
codedb_status 242661 233134 -3.93% -9527 OK
codedb_symbol 39034 43390 +11.16% +4356 NOISE
codedb_tree 54696 25676 -53.06% -29020 OK
codedb_word 40530 39299 -3.04% -1231 OK

Copy link
Copy Markdown

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 94c9e0e92a

ℹ️ 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".

Comment thread src/snapshot.zig
content_gop.key_ptr.* = path;
content_gop.value_ptr.* = content;
const content_cache_limit: u32 = 1000;
const should_cache = explorer.outlines.count() <= content_cache_limit;
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P1 Badge Preserve rebuildable content when capping snapshot cache

This cap drops raw content for files after the first 1000 during fast snapshot restore, but Explorer.searchWord rebuilds the in-memory word index from explorer.contents when disk index loading fails. In repos larger than 1000 files where word.index is missing/unreadable (for example on a fresh machine with only codedb.snapshot), the rebuild becomes partial yet is treated as complete, so codedb_word and identifier-style search paths silently miss hits in uncached files.

Useful? React with 👍 / 👎.

@justrach justrach merged commit 26ed1dd into release/0.2.579 Apr 26, 2026
1 check passed
@justrach justrach deleted the fix/mcp-snapshot-rss branch April 26, 2026 06:44
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant