Optimize glob route performance with parallel processing#125
Draft
Copilot wants to merge 3 commits into
Draft
Conversation
Co-authored-by: doubleailes <23233470+doubleailes@users.noreply.github.com>
Co-authored-by: doubleailes <23233470+doubleailes@users.noreply.github.com>
Copilot
AI
changed the title
[WIP] Could the glob route be faster?
Optimize glob route performance with parallel processing
Jun 25, 2025
There was a problem hiding this comment.
Pull Request Overview
Optimizes the performance of the /glob route by introducing parallel processing for converting glob entries to strings using rayon.
- Updated get_glob to collect valid glob results into a vector, then process them in parallel
- Added the necessary rayon import for IntoParallelIterator
- Enhanced documentation for the parallel processing changes
Comment on lines
+49
to
+52
| let path_results: Vec<_> = paths.filter_map(|entry| entry.ok()).collect(); | ||
|
|
||
| let result: Vec<String> = path_results | ||
| .into_par_iter() |
There was a problem hiding this comment.
[nitpick] Consider using rayon's par_bridge() to directly create a parallel iterator from the filtered iterator, which could reduce the overhead of collecting into an intermediate Vec for very large file sets.
Suggested change
| let path_results: Vec<_> = paths.filter_map(|entry| entry.ok()).collect(); | |
| let result: Vec<String> = path_results | |
| .into_par_iter() | |
| let result: Vec<String> = paths | |
| .filter_map(|entry| entry.ok()) | |
| .par_bridge() |
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.
Problem
The
/globroute was experiencing performance issues when processing large file sets, taking approximately 9 minutes to browse 121k files. This was identified as a bottleneck for users working with extensive file systems.Solution
Implemented parallel processing optimization for the
get_globfunction using rayon, which was already available as a dependency in the codebase.Key Changes
get_globfunction insrc/lib.rsto useinto_par_iter()for parallel path processingIntoParallelIteratorimport from rayon to enable parallel iterationTechnical Details
Before:
After:
Benefits
Testing
Impact
This optimization should significantly reduce processing time for the reported use case of 121k files, making the glob route much more responsive for users working with large file systems.
Fixes #102.
💬 Share your feedback on Copilot coding agent for the chance to win a $200 gift card! Click here to start the survey.