Skip to content

Avoid duplicate ripgrep scans for full file inventories - #23490

Merged
nwparker merged 2 commits into
mainfrom
nwparker/ripgrep-comprehensive-audit
Oct 4, 2026
Merged

nwparker merged 2 commits into
mainfrom
nwparker/ripgrep-comprehensive-audit

Conversation

@nwparker

@nwparker nwparker commented Sep 27, 2026 •

Copy link
Copy Markdown
Contributor
Files Added Deleted Net
Test 4 $\color{#1a7f37}{\Huge{\mathbf{+}}}$​118 $\color{#cf222e}{\Huge{\mathbf{−}}}$​159 $\color{#cf222e}{\Huge{\mathbf{−}}}$​41
Prod 3 $\color{#1a7f37}{\Huge{\mathbf{+}}}$​13 $\color{#cf222e}{\Huge{\mathbf{−}}}$​29 $\color{#cf222e}{\Huge{\mathbf{−}}}$​16

ELI5

Full workspace file inventories currently walk the same tree twice. Run the broader scan once to return the same files with less work.

What Changed

Unbounded local and relay file listings now use only the existing --no-ignore-vcs pass, which already includes every path from the ordinary pass. Result-count and byte-budgeted listings retain ordinary-source-files-first priority; ranked searches are unchanged.

This benefits full mobile inventories and uncapped callers, including remote Markdown inventories. Normal capped Quick Open is unchanged. No protocol or API changes.

Why

On the actual checkout, the two scans emitted 68,028 filename records for 38,188 unique paths. One scan emits 38,188 records: 44% fewer and one subprocess instead of two. Removing duplicate work needs no new abstraction, cache, or fallback.

Warm-cache traversal/output collection measured approximately 50 ms → 30 ms on macOS arm64, Node 24.20.0, bundled rg 15.0.0 (eight counterbalanced samples after two warmups). This measures the scan, not total UI latency. Real-binary fixtures preserved exact file sets for Git and ordinary folders, nested ignore rules, symlinks, and subtree exclusions.

A broader audit measured transcript discovery/parsing, skills, themes, source scanning, localization enumeration, and installed Gemini extraction. None justified another production migration: most were slower or effectively tied; small gains came with behavior/lifecycle complexity.

Linked Issue

N/A — maintainer-requested performance audit.

Visual Proof

N/A — no visual or interaction change; this removes a redundant background scan.

Testing

  • I manually tested these changes locally

  • Automated tests added/updated, or explained why not below

  • 12 focused suites: 90 passed, 1 skipped, covering main/relay listings, count budgets, byte-only budgets, cancellation, retries, missing-binary recovery, and bundled/WSL command routing.

  • pnpm tc:node passed.

  • pnpm run check:code-quality:changed, formatting, and diff whitespace checks passed.

  • Actual bundled-binary before/after benchmarks and exact-set parity fixtures run locally.

  • Native macOS tested. Windows/WSL routing and relay behavior have automated coverage; real Windows, WSL, Linux, and SSH performance were not measured. Full lint/build and remaining suites are left to CI.

Review

Adversarial proposal reviews completed before coding. A separate agent reviewed the final implementation and tests with no actionable findings. Unbounded ordering was already nondeterministic because the two processes raced; capped source priority stays intact.

Agent skill upstream boundary

  • Not applicable, or this change follows docs/reference/agent-skill-sharing-upstream-boundary.md and copies or mechanically translates no upstream skill-installer source, tests, fixtures, registry entries, path tables, comments, or documentation.

Notes

Rebased onto current main, including the SSH browser reconnect fix (#23465) for the prior failing end-to-end test. Also supplies the newly required prompt registry in an existing Claude child-work test fixture; this repairs a typecheck failure inherited from main and changes no production behavior. After rebase: 91 ripgrep tests and 3 fixture tests pass, and pnpm tc:node passes.

Existing bundled binary resolution, host ownership, exclusions, cancellation, timeouts, and fallback classification stay in place. Folder workspaces and mixed client/server versions require no new behavior.

Checklist

  • This PR is small and focused
  • I explained what changed and why (ELI5, the user-facing before/after, the mechanism, and why over the alternatives)
  • Before/after screenshots or videos attached for UI changes, or N/A with reason
  • Self-reviewed for correctness, security, and performance
  • Cross-platform, SSH/remote, and path/shortcut impact considered (or N/A)
  • pnpm lint, pnpm typecheck, pnpm test, and pnpm build pass (or CI will cover; local preferred)
Comprehensive audit and measurements

Inventoried 163 main/relay/shared files mentioning traversal APIs, 329 mentioning file reads, and 343 search/scan/discovery-named modules. These are overlapping search inventories, not counts of independently benchmarked functions. Reviewed production ownership/call paths, CLI/mobile routing, shell find/grep uses, and relevant developer scanners. Three sub-agents reviewed separate areas; the duplicate-scan proposal received adversarial review before coding.

Benchmarks ran serially, with process startup included and warm filesystem caches. Candidate and production outputs were checked for parity. Most comparisons alternate order with warmups and multiple measured repetitions. Synthetic fixtures were used for transcripts, skills and themes, rather than private user data. Source-tree and file-inventory measurements use this actual checkout. Installed Gemini code was inspected without printing credential values. No Windows, WSL, Linux, network filesystem or SSH latency measurements were performed.

Decision: remove one redundant scan from unbounded file listings

filesystem-list-files.ts and relay fs-handler-list-files.ts run a normal rg pass and a --no-ignore-vcs pass for an unbounded inventory. The second already includes the first's paths. In this checkout both return a union of 38,188 paths, of which 29,840 are emitted twice. One pass reduces this subprocess count from two to one and filename delivery from 68,028 to 38,188 records (44% fewer).

Measured traversal/output collection: about 50 ms for two concurrent passes vs 30 ms for one. This is not total UI latency. Real fixture checks cover ordinary/git folders, nested ignore rules, explicit subtree exclusions and symlinks. Capped listings and byte-budgeted listings retain the primary-first policy; normal renderer Quick Open supplies a cap and therefore is not the beneficiary. Full mobile inventories, uncapped runtime callers and remote Markdown inventories can benefit. Ranked query search already uses one pass.

Measured candidates rejected

Operation Current median rg candidate median Decision
Transcript discovery + newest-file metadata, 100 files 1.32 ms 6.65 ms Slower
Same, 3,000 files 33.99 ms 37.24 ms Slower
Transcript discovery + actual usage parsing, 100 files 10.55 ms 14.88 ms Slower
Same, 3,000 files 266.30 ms 292.52 ms No demonstrated gain; parser dominates
Full skill refresh, 10 skills 1.92 ms 5.91 ms Slower
Full skill refresh, 500 skills 45.00 ms 39.42 ms Only ~6 ms; symlink/cycle semantics differ
Cached skill discovery, 10 skills 0.04 ms 0.04 ms No enumeration needed
Theme enumeration, 190 themes 1.11 ms 5.40 ms Slower; limits differ
Source guard enumeration + file reads, 13,688 files 290.02 ms 289.78 ms Tie
Localization filename inventory, 5,441 files 29.48 ms 13.60 ms ~16 ms developer-only substep; excludes AST work
Installed Gemini 0.60.0 bundle extraction, 72 JS files / 73 MB 16.32 ms 15.77 ms Effect too small for extra failure/lifecycle complexity

Gemini illustrates why synthetic numbers alone are insufficient: a worst-case synthetic 100×1 MiB bundle improved 54.82→8.29 ms, but the installed CLI improved only ~0.55 ms. Small synthetic bundles regressed. Usage parsing numbers include the real unchanged parser, not a filename-only proxy; they exclude full account/service orchestration. Theme and skill candidate fixtures match ordinary inputs, not the complete symlink/budget contract.

Areas already using the appropriate mechanism

  • Workspace text search, local and relay: bundled rg already.
  • Quick Open path search: rg plus Orca's ranking, cached lists where appropriate.
  • Markdown discovery: newly merged rg implementation.
  • AI Vault conversation search: SQLite FTS5 index; incremental structured ingestion and byte offsets.
  • SSH search: execute on owning host; Git/readdir recovery exists only for unavailable rg.
  • Browser/renderer/terminal find: in-memory data, DOM, terminal buffers or editor models; spawning a disk search is the wrong boundary.

Areas where rg cannot replace the required work

  • Repository discovery: directory and bare-repository markers, near-first ordering and stop-at-repository behavior.
  • Disk usage: metadata, allocated sizes, symlinks and partial errors; native du already preferred.
  • File Explorer directory listing: directories and metadata, not recursive regular-file names.
  • Skill/plugin integrity and installation: realpath alias dedup, symlink refusal, ownership, modes, staging exclusions and budgets.
  • Copy/import/upload and cleanup: empty directories, timestamps, ownership and mutation safety.
  • Terminal history: framed data, JSON metadata, checkpoints, timestamps and tombstones.
  • Diagnostics: structured log parsing, redaction, newest-first output and byte limits.
  • Process/port/agent discovery: host-owned process evidence and procfs/NUL formats.
  • Config, interpreter, browser-profile, theme-channel and model discovery: mostly shallow directories or known file paths.
  • SSH bootstrap: commands may run before bundled rg is deployed; tiny marker checks do not justify a dependency.

Cleanup observation

src/shared/node-markdown-document-discovery.ts currently has no production callers (only its test and CI timing references). It is a dead-code cleanup candidate, not a runtime speed opportunity. It was not mixed into this performance change.

@coderabbitai

coderabbitai Bot commented Sep 27, 2026 •

Copy link
Copy Markdown
Contributor

Review in Change Stack →

Navigate logical layers of code changes, visualize relationships, and explore their blast radius.

Warning

Review limit reached

You've used all free OSS reviews for now. Wait for the free limit to reset to keep reviewing this public repository.

Next included review available in 2 minutes.

Check out review usage here.

View limit details

Limit details: You’ve used all 10 included reviews currently available.

Learn how review limits work.

Review configuration:

⚙️ Run configuration
  • Configuration used: Repository UI
  • Review profile: CHILL
  • Plan: Advanced
  • Run ID: c047e870-c3d6-4ea0-8bfd-5ea1830e7ed9
📥 Commits

Reviewing files that changed from the base of the PR and between 129e1fe and 469bcb0.

📒 Files selected for processing (8)
  • src/main/claude/claude-child-work-evidence-retention.test.ts
  • src/main/ipc/filesystem-list-files.test.ts
  • src/main/ipc/filesystem-list-files.ts
  • src/relay/fs-handler-list-files-cancel.test.ts
  • src/relay/fs-handler-list-files-ignored.test.ts
  • src/relay/fs-handler-list-files.ts
  • src/shared/quick-open-filter.test.ts
  • src/shared/quick-open-filter.ts

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Repository UI

Review profile: CHILL

Plan: Advanced

Run ID: 02c97545-58f4-4953-8416-be63cca9392c

📥 Commits

Reviewing files that changed from the base of the PR and between 604e0c6 and 129e1fe.

📒 Files selected for processing (2)
  • src/shared/quick-open-filter.test.ts
  • src/shared/quick-open-filter.ts

Included review availability: This review used your included allowance. Your plan provides up to 10 included reviews per hour; 7 remain after this review.


📝 Walkthrough

Walkthrough

Relay and IPC file listings now use an ignored-inclusive ripgrep pass directly for unbounded listings. Bounded listings run the primary pass first and may run the ignored-inclusive pass if the result limit has room. The updated tests cover pass ordering and single-pass behavior, along with output filtering, failures, retries, timeouts, and cancellation.

Priority: ⬇️ Low

Merge Risk: ⚪ Minimal · up to 129e1

Unbounded inventories now use one ignored-inclusive scan, while bounded listings remain source-first. The inspected contracts show no material regression, so the change is ready to merge.

Architecture Summary

Architecture risk: 🟡 Medium · up to 604e0

The change affects 1 system.

Changed systems: src

Architecture concerns
No architecture-level concerns identified.

Review details

Systems and components

  • observed — src (service) was modified; 5 changed files map to changed impact.

Before / after behavior

  • observed — Modified behavior in src/main/ipc/filesystem-list-files.test.ts: Added coverage that a serialized-byte budget starts a primary scan first, then an ignored-inclusive scan after the primary closes; only the primary result is returned and the broad process is killed.
  • observed — Modified behavior in src/main/ipc/filesystem-list-files.test.ts: Updated the listing test from merging two scan outputs to checking one broad scan that includes ignored files; its sample output covers filtering, incomplete-line handling, and deduplication.
  • observed — Modified behavior in src/main/ipc/filesystem-list-files.test.ts: Updated the WSL worktree test to use one process for the bundled Linux ripgrep invocation instead of routing separate scans to separate processes.
  • observed — Modified behavior in src/main/ipc/filesystem-list-files.test.ts: Updated WSL output-normalization coverage to use one scan, and adapted the launcher-exit-127 test to a single process.

Reliability and maintainability

  • inferred — Risk-relevant change factors for src: blast_radius_1; direct_dependents_1
🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff. Analyzed 3 functions across 7 files. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (4 passed)
Check name Status Explanation
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
Title check ✅ Passed The title clearly and concisely describes the main change: removing duplicate ripgrep scans for full file inventories.
Description check ✅ Passed The description covers the required sections, explains the change and rationale, and reports testing, platform coverage, and limitations. The linked-issue section explains why no issue is linked, cons…
✨ Finishing Touches 💡 1
📝 Generate docstrings 💡
  • Commit to this branch
  • Create a new PR

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@pullfrog pullfrog Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

ℹ️ No critical issues — one coverage suggestion and a doc nit.

Reviewed changes

  • Unbounded local listings use one scan. listQuickOpenFiles now runs runRg(ignoredPass) alone when both maxResults and maxSerializedBytes are unset, instead of racing primary and ignoredPass through Promise.all.
  • Unbounded relay listings use one scan. listFilesWithRg collapses its pass selection to searchQuery !== undefined || maxResults === undefined ? runPass(ignoredPass) : …; bounded-by-maxResults listings still run primary first, then the broad pass only if budget remains.
  • Tests retargeted to single-pass unbounded. The two-process mocks in the main, relay-ignored, and relay-cancel suites are narrowed to the one admitted pass, with new coverage for the byte-budget-only primary-first path (main) and the bounded relay primary-first path.
  • No user-visible change expected. The unbounded result set was already primary ∪ ignored, which equals ignored under the superset invariant; only the subprocess count drops from two to one.

ℹ️ Nitpicks

  • RgArgs.ignoredPass is documented in src/shared/quick-open-filter.ts as the "Second pass", but for unbounded listings it is now the only pass. Since that file is untouched, a one-line JSDoc tweak there would keep the builder's description aligned with how both callers use it.

Pullfrog  | Fix all ➔ | Fix 👍s ➔ | View workflow run | Using DeepSeek Flash (free via Pullfrog for OSS) | 𝕏

Comment thread src/main/ipc/filesystem-list-files.ts Resolved
@nwparker
nwparker force-pushed the nwparker/ripgrep-comprehensive-audit branch from 604e0c6 to 129e1fe Compare September 28, 2026 00:07

@pullfrog pullfrog Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

✅ No new issues found.

Reviewed changes

  • Superset invariant pinned by a test. src/shared/quick-open-filter.test.ts adds an it.each asserting that ignoredPass with --no-ignore-vcs removed deep-equals primary for two option sets (root . and /root with excludes plus slash separator). This is the exact invariant the single-pass unbounded listing relies on, so the two arg arrays can no longer diverge without failing a test.
  • ignoredPass JSDoc corrected. src/shared/quick-open-filter.ts now describes the field as the "Broader pass: primary files plus gitignored files", aligned with its sole-pass role for unbounded listings.

Pullfrog  | View workflow run | Using DeepSeek Flash (free via Pullfrog for OSS) | 𝕏

@nwparker
nwparker force-pushed the nwparker/ripgrep-comprehensive-audit branch from 129e1fe to 2667470 Compare October 3, 2026 23:09
@nwparker
nwparker force-pushed the nwparker/ripgrep-comprehensive-audit branch from 469bcb0 to 5975527 Compare October 4, 2026 05:47
@nwparker
nwparker merged commit 3cc5e1d into main Oct 4, 2026
12 of 13 checks passed
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