Repository navigation
perf(analysis): wire per-file fact cache into the diff path — biggest single performance win (#1912) - #2039
Conversation
…ase audit (2026-07-19) Add 9 entries to LEARNINGS.md covering: - Gate blocking is non-functional (hardcoded seam_id None) - Static receipts are advisory (fabrication is trivial) - Every save re-runs the full pipeline (cache not wired in) - continue-on-error on every CI step makes green meaningless - Result<_, String> is the highest-leverage refactor target - Cross-language consistency needs a shared vocabulary layer - File-policy gate breaks main on new file types - Duplicate run-status logic drifts - The session's structural learnings document Each entry follows the existing LEARNINGS.md format: date, title, load-bearing lesson, and concrete evidence references.
… single performance win (#1912) The diff-scoped index build (rust.rs:655) called the UNCACHED build_index variant, re-parsing every indexed file with ra_ap_syntax on every ripr check and every LSP save. The cached variant build_index_from_loaded_files_with_cache existed and worked on the repo-seam path but was never wired into the diff path. This change loads files into (PathBuf, Vec<u8>) pairs and calls the cached variant at both diff-scoped (rust.rs:655) and repo-scoped (rust.rs:743) index sites. On a cache hit (file content unchanged), the parser is skipped entirely — the cached FileFacts are deserialized from a JSON sidecar keyed on a content hash. Impact: warm ripr check and LSP saves on unchanged files go from full ra_ap_syntax re-parse to FNV hash + JSON read. First run pays the parse cost and populates the cache; subsequent runs hit. Proof: cargo check --lib (exit 0); cargo clippy --all-targets -D warnings (exit 0); cargo run -- check --diff sample/example.diff --json produces 4 weakly_exposed findings (unchanged from uncached); goldens check (running).
|
You have reached your Codex usage limits for code reviews. You can see your limits in the Codex usage dashboard. |
Summary by CodeRabbit
WalkthroughRust diff and repository analysis now read discovered Rust files into memory and build ChangesRust fact-cache indexing
Estimated code review effort: 2 (Simple) | ~10 minutes Possibly related issues
Poem
🚥 Pre-merge checks | ✅ 4 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (4 passed)
✨ Finishing Touches📝 Generate docstrings
🧪 Generate unit tests (beta)
Comment |
There was a problem hiding this comment.
Code Review
This pull request introduces a content-addressed per-file fact cache to avoid re-parsing unchanged Rust files during analysis, loading files into memory before building the index. The code reviewer suggested extracting the duplicated file-loading and error-handling logic from both analysis paths into a shared helper function to improve maintainability and adhere to DRY principles.
Important
The consumer version of Gemini Code Assist on GitHub is being sunset. Starting June 18, 2026, new organization installations will be blocked, and all code review activity will officially cease on July 17, 2026.
For more details on the timeline and next steps, please review the Help Documentation.
There was a problem hiding this comment.
Actionable comments posted: 3
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Inline comments:
In `@crates/ripr/src/analysis/language/rust.rs`:
- Around line 659-667: The loaded-file paths in
crates/ripr/src/analysis/language/rust.rs lines 659-667 and 742-750 collect all
source bytes without an aggregate bound. Update both the diff-scope and
full-repository loading flows around loaded_files to stream files through the
cache builder or enforce a shared total-byte limit before collecting, preserving
the existing indexing behavior while preventing unbounded memory use.
- Around line 659-667: Check the cache-builder cancellation checkpoint before
each file read in both the diff-scope loading loop at
crates/ripr/src/analysis/language/rust.rs:659-667 and the repo-scope loading
loop at crates/ripr/src/analysis/language/rust.rs:742-750. Ensure cancellation
is evaluated during iteration, before std::fs::read, while preserving the
existing error propagation and loaded-file collection behavior.
- Around line 655-670: Add adapter-level tests around the loaded-files flow in
the Rust analysis module covering a missing/unreadable file and asserting the
`std::fs::read` error is propagated with the file path. Also add thin end-to-end
checks for `analyze_diff` and `analyze_repo` to verify both pass the cached
index through unchanged, reusing existing test fixtures and cache coverage from
`rust_index::build_index_from_loaded_files_with_cache`.
🪄 Autofix (Beta)
Fix all unresolved CodeRabbit comments on this PR:
- Push a commit to this branch (recommended)
- Create a new PR with the fixes
ℹ️ Review info
⚙️ Run configuration
Configuration used: Organization UI
Review profile: ASSERTIVE
Plan: Pro Plus
Run ID: 8aaa522e-a61e-4388-9e51-8a6812b1c7de
📒 Files selected for processing (1)
crates/ripr/src/analysis/language/rust.rs
🔗 Linked repositories identified
CodeRabbit considers these linked repositories for cross-repo context during reviews:
EffortlessMetrics/ripr(auto-detected)EffortlessMetrics/perl-lsp(auto-detected)EffortlessMetrics/unsafe-review(auto-detected)EffortlessMetrics/ub-review(auto-detected)
Codecov Report❌ Patch coverage is
📢 Thoughts on this report? Let us know! |
There was a problem hiding this comment.
Decision
- Needs reviewer attention before upstream: findings remain.
Confirmed findings
- Wire a test that pre-seeds the fact cache for sample/example.diff inputs, re-runs analyze_diff, and asserts cache-hit metrics (parse-call count == 0 for unchanged files) plus byte-identical findings to the uncached run. Current evidence only shows structural receipts and a prospective goldens claim; cache-hit skip-parse behavior is unproven.
- DRY the file-loading + error mapping into a single helper (load_files_for_index) used by both analyze_diff and analyze_repo; preserves behavior, kills the duplication Gemini and CodeRabbit both flagged.
- Index-builder entry points at L652-672 (diff) and L738-758 (repo) eagerly collect all source bytes into Vec<(PathBuf, Vec)> with no aggregate cap. On a large repo or wide diff scope this can OOM. PR body does not claim a size guard; existing build_index path did not materialize bytes upfront. Stream via the cache builder or enforce a per-call byte budget.
- Repo-scope load path is the uncovered codecov line; add a fixture that exercises analyze_repo with cache-miss then cache-hit to lock in parity with the diff path. CachedRustIndex round-trip is the strongest correctness guarantee here.
- Neither loop checks a cancellation/is_cancelled checkpoint before each fs::read or inside the iter. Long repo scans / LSP saves can no longer be interrupted mid-load. Add a cancel poll before each read in both diff and repo scopes; preserves error propagation already present.
Confirmed findings
- No test asserts cache-key stability across reformatting/whitespace-only edits or that a corrupted JSON sidecar falls back to re-parse rather than failing the whole index build. PR diff does not show a fallback path test.
- PR claims cargo check --lib, cargo clippy, and cargo run -- check --diff all exit 0 with identical findings, but goldens check is 'running' and cargo-test receipt is absent. Behavior parity claim is not yet machine-verified end-to-end against the cache-warmed path; treat as partial until goldens land.
- Prior reviewer thread already established that load+error logic is duplicated and that aggregate byte bound is missing; PR did not address either. Not blocking because this is a perf wire-up with same behavior on cache hit, but flagging for smallest-complete-fix boundary.
Verification questions
- Confirm both index-build sites (diff ~655, repo ~743) call build_index_from_loaded_files_with_cache and extract .index; PR body claims identical findings (4 weakly_exposed) on sample/example.diff. Diff supports wiring claim; behavior parity needs test receipt.
- Confirm pR body claims 'goldens check (running — will verify zero drift across 200 fixtures)' but no green goldens receipt is in current sensor evidence; only structural (tokmd/ripr/ast-grep) receipts are present.
- Confirm cache wiring is symmetric across analyze_diff (~L659-667) and analyze_repo (~L742-750); both now call build_index_from_loaded_files_with_cache and extract .index.
Verification questions
Refuted
Evidence gaps
[review body truncated; see review artifacts]
[review body truncated; see review artifacts]
| )); | ||
| } | ||
| let mut index = rust_index::build_index(&options.root, &index_files)?; | ||
| // Load files into memory and use the content-addressed per-file fact |
There was a problem hiding this comment.
[tests-red-green] Wire a test that pre-seeds the fact cache for sample/example.diff inputs, re-runs analyze_diff, and asserts cache-hit metrics (parse-call count == 0 for unchanged files) plus byte-identical findings to the uncached run. Current evidence only shows structural receipts and a prospective goldens claim; cache-hit skip-parse behavior is unproven.
| // cache. This avoids re-parsing unchanged files with ra_ap_syntax on | ||
| // every ripr check / LSP save (#1912). The cache is keyed on a | ||
| // content hash; unchanged files hit the cache and skip the parse. | ||
| let loaded_files = index_files |
There was a problem hiding this comment.
[opposition] DRY the file-loading + error mapping into a single helper (load_files_for_index) used by both analyze_diff and analyze_repo; preserves behavior, kills the duplication Gemini and CodeRabbit both flagged.
| .collect::<Result<Vec<_>, String>>()?; | ||
| let cached = | ||
| rust_index::build_index_from_loaded_files_with_cache(&options.root, &loaded_files)?; | ||
| let mut index = cached.index; |
There was a problem hiding this comment.
[source-route] Index-builder entry points at L652-672 (diff) and L738-758 (repo) eagerly collect all source bytes into Vec<(PathBuf, Vec)> with no aggregate cap. On a large repo or wide diff scope this can OOM. PR body does not claim a size guard; existing build_index path did not materialize bytes upfront. Stream via the cache builder or enforce a per-call byte budget.
| // stays production-only so test bodies do not generate findings. | ||
| let mut index = rust_index::build_index(&options.root, &rust_files)?; | ||
| // Use the content-addressed per-file fact cache (#1912). | ||
| let loaded_rust_files = rust_files |
There was a problem hiding this comment.
[opposition] Repo-scope load path is the uncovered codecov line; add a fixture that exercises analyze_repo with cache-miss then cache-hit to lock in parity with the diff path. CachedRustIndex round-trip is the strongest correctness guarantee here.
| rust_index::build_index_from_loaded_files_with_cache(&options.root, &loaded_files)?; | ||
| let mut index = cached.index; | ||
| rust_index::apply_oracle_policy(&mut index, oracle_policy); | ||
|
|
There was a problem hiding this comment.
[source-route] Neither loop checks a cancellation/is_cancelled checkpoint before each fs::read or inside the iter. Long repo scans / LSP saves can no longer be interrupted mid-load. Add a cancel poll before each read in both diff and repo scopes; preserves error propagation already present.
…headline entries (#3591) * docs(changelog): consolidate Unreleased headings and add the missing headline entries The Unreleased section carried duplicate Added/Fixed headings and omitted the release's headline features. Consolidate to one Added / Changed / Fixed sequence (0.10.0 convention) and add verified entries for: - ripr mcp --stdio server and startup routing (#3088, #3525, #3587) - ripr rerun changed-test targeted analysis (#1520) - the binary-first evidence/gate surface: ripr plus, pr-summary, pr-evidence, annotations, impacted-evidence (#1476/#1460/#1468/#1467/#1474) - --suppression-policy and --exception-policy policy flags (#1475/#1477) - the cache management surface: status, clear, atomic writes (#1822/#2865/#2738) - the LSP capability wave: pull diagnostics, listActionableItems, transport bounds (#1669/#3012/#2185) - analysis performance: per-file fact cache, rayon parallel parse, artifact reuse (#2039/#2322/#2250) Every cited PR verified MERGED via the GitHub API. Also corrects the stale 0.10.0 release-date line (crates.io publication 2026-06-15; GitHub release draft remains unfinalized). * docs(changelog): drop the superseded duplicate MCP entry (#3591 review) The pre-existing Added block already carried an MCP entry from the #3525 merge; keep the expanded consolidated entry (startup routing, verbose handling, review fixes) and remove the older shorter one.
Summary
Wire the existing per-file fact cache into the diff-scoped index build path. This is the single highest-leverage performance fix: the cache existed and worked on the repo-seam path, but the diff path (which runs on every ripr check and every LSP save) called the uncached variant.
Change
crates/ripr/src/analysis/language/rust.rs (+31/−2):
Both index-build sites (diff-scoped at ~655, repo-scoped at ~743) now:
On a cache hit (file content unchanged via FNV content hash), ra_ap_syntax parsing is skipped entirely — cached FileFacts are deserialized from a JSON sidecar.
Impact
Proof
Non-goals