Skip to content

perf(search): bound the workspace file scan and cache (#74)#78

Merged
dawsbot merged 1 commit into
masterfrom
perf/74-bound-file-cache
Jul 7, 2026
Merged

perf(search): bound the workspace file scan and cache (#74)#78
dawsbot merged 1 commit into
masterfrom
perf/74-bound-file-cache

Conversation

@dawsbot

@dawsbot dawsbot commented Jul 7, 2026

Copy link
Copy Markdown
Owner

Summary

updateFiles() passed undefined as findFiles' maxResults, so the extension scanned and cached every matching path in the workspace for the lifetime of the session. On very large workspaces that meant unbounded disk I/O before the picker could open and hundreds of MB held in _fileNames.

This bounds the scan and makes the bound visible:

  • New setting relativePath.maxFilesCached (default 100000, 0 = no limit, matching the old behavior). It's passed straight through as findFiles' maxResults, so the cap bounds both the scan time and the cache size.
  • Truncation is surfaced, not silent. When the scan stops at the cap, the quick pick / input box placeholders say "Found the first 100000 files (capped by 'relativePath.maxFilesCached')" instead of implying full coverage.
  • The cache is refreshed when the setting changes, same as relativePath.ignore already was.

The sanitization and truncation-detection logic lives in a new pure module src/search-limit.ts with unit tests (test/search-limit.test.ts), following the pattern set by globs.ts / closest-match.ts.

Testing

  • npm test: 15/15 pass (4 new tests covering default fallback, the 0 opt-out, flooring, and the cap-reached boundary).
  • tsc compiles cleanly, so the findFiles(include, exclude, maxResults, token) wiring type-checks against the VS Code API. Not exercised in a live Extension Development Host.

Closes #74

🤖 Generated with Claude Code

The findFiles scan passed maxResults=undefined and cached every matching
path for the session, so huge workspaces paid unbounded disk I/O up front
and held the whole list in memory.

- Add relativePath.maxFilesCached (default 100000, 0 = no limit) and pass
  it as findFiles' maxResults
- Track when the scan hit the cap and say so in the picker/input
  placeholders instead of presenting a silently partial list
- Re-scan when the setting changes, like relativePath.ignore

Closes #74

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
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.

Unbounded findFiles + full-array cache doesn't scale to very large workspaces

1 participant