perf(store): O(1) ensure_metadata, staleness-gated upserts, parallel batch extraction - #192
Closed
nwaughachukwuma wants to merge 2 commits into
Closed
Conversation
|
Caution The consumer version of Gemini Code Assist on GitHub has been sunset. All code review activity has officially ceased. |
nwaughachukwuma
force-pushed
the
claude/core-perf-optimization-s230yb
branch
from
August 3, 2026 12:49
efb91ce to
9ce1d7e
Compare
This was referenced Aug 3, 2026
nwaughachukwuma
commented
Aug 3, 2026
nwaughachukwuma
left a comment
Collaborator
Author
There was a problem hiding this comment.
@claude, please follow-up
…batch extraction - ensure_metadata: single-file Rust scan_one + extract_metadata_one instead of a full parent-directory scan + Arrow round-trip per file (hit twice per mm cat file). 96ms → 18ms per fresh file at 340 siblings; sibling scaling removed entirely. - upsert_files: snapshot (modified, size, content_hash) before upserting and re-extract only new/changed rows. Warm Context.save() 212ms → 8ms (26x), cold save 1220ms → 175ms (7x) on the 340-file fixture. - New Scanner.extract_metadata_batch: rayon-parallel extraction with the GIL released, one FFI crossing instead of N (3.2-17x vs the serial loop); O(1) path index replaces the per-call linear entry scan (O(n²) across a save). - Benchmarks: Criterion scan_single_vs_dir_walk group; pytest-benchmarks for warm/cold save, ensure_metadata, and batch-vs-serial / scan_one-vs-walk A/B pairs. Numbers in benchmarks/mm-bench-260803.md. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_012GnYsrLTmdJphKkm7yjWDV
nwaughachukwuma
force-pushed
the
claude/core-perf-optimization-s230yb
branch
from
August 12, 2026 10:30
9ce1d7e to
0d2f4ca
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
ensure_metadatais O(1): single-file Rustscan_one+extract_metadata_onereplaces a full parent-directoryScannerwalk + Arrow round-trip per file (it ran twice permm catfile).upsert_filesstaleness gate: snapshots(modified, size, content_hash)and re-extracts only new/changed rows.Scanner.extract_metadata_batch: rayon-parallel extraction with the GIL released, one FFI crossing instead of N; O(1) path index replaces the per-call linear entry scan (O(n²) across a save).Speed gains
End-to-end (4-core VM; 340-file fixture: 300 × 200-line .py + 40 PNGs; baseline = #181 head):
Context.save()warmContext.save()coldPer-change A/B (new vs replaced path, same build):
scan_singlevs parent-dir walk (Criterion, 50 siblings)Documented tradeoff:
extract_metadata_batchhas ~3-4 ms fixed rayon dispatch per call — a per-save constant that only shows on trees of near-empty files; end-to-end saves win regardless.Validation
1,208 Python + 106 Rust tests pass; clippy/ruff clean (2 pre-existing
TestRecordingFileenv failures fail identically on the base commit). Benchmarks: Criterionscan_single_vs_dir_walk; pytest warm/cold save,ensure_metadata, batch-vs-serial A/B. Tables inbenchmarks/mm-bench-260803.md.🤖 Generated with Claude Code
https://claude.ai/code/session_012GnYsrLTmdJphKkm7yjWDV