Skip to content

Conversation

@google-labs-jules
Copy link
Contributor

⚡ Bolt: Optimized file search performance

💡 What:
Moved the sort and slice operations in searchFiles to happen before the expensive fs.stat loop.

🎯 Why:
The previous implementation performed fs.stat on every single file matched by the glob pattern, even if the user only requested the top 100 results. In large repositories with thousands of matches, this caused significant unnecessary I/O overhead.

📊 Impact:

  • Reduces fs.stat calls from N (total matches) to limit (requested count, default 100).
  • In a benchmark with 2000 files, search time dropped from ~223ms to ~11ms (~20x improvement).

🔬 Measurement:
Run a file search in a directory with many files (e.g., src/**/*.ts) and a small limit. The response time will be significantly faster.
Internal benchmark script demonstrated 95% reduction in execution time for 2000 file matches.


PR created automatically by Jules for task 14955912441450369156 started by @GhostTypes

Reduces filesystem I/O by only retrieving metadata for the files that will actually be returned.
Previously, all matched files were stat-ed before limiting. Now, matches are sorted (by path) and limited first.
This reduces fs.stat calls from O(N) to O(limit), significantly speeding up searches in large repositories.

- Sort matched file paths immediately
- Apply limit slice before fs.stat loop
- Use matched files count as total_matches approximation
@google-labs-jules
Copy link
Contributor Author

👋 Jules, reporting for duty! I'm here to lend a hand with this pull request.

When you start a review, I'll add a 👀 emoji to each comment to let you know I've read it. I'll focus on feedback directed at me and will do my best to stay out of conversations between you and other bots or reviewers to keep the noise down.

I'll push a commit with your requested changes shortly after. Please note there might be a delay between these steps, but rest assured I'm on the job!

For more direct control, you can switch me to Reactive Mode. When this mode is on, I will only act on comments where you specifically mention me with @jules. You can find this option in the Pull Request section of your global Jules UI settings. You can always switch back!

New to Jules? Learn more at jules.google/docs.


For security, I will only act on instructions from the user who triggered this task.

@GhostTypes GhostTypes marked this pull request as ready for review January 19, 2026 14:53
@GhostTypes GhostTypes merged commit 477380f into main Jan 19, 2026
3 checks passed
@GhostTypes GhostTypes deleted the bolt-optimize-file-search-14955912441450369156 branch January 19, 2026 14:53
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.

2 participants