New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Speed up glob implementation #304
Merged
Merged
Conversation
This file contains 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
Codecov Report
Additional details and impacted files@@ Coverage Diff @@
## master #304 +/- ##
========================================
- Coverage 94.5% 94.4% -0.1%
========================================
Files 21 21
Lines 1384 1378 -6
========================================
- Hits 1309 1302 -7
- Misses 75 76 +1
|
jayqi
approved these changes
Dec 30, 2022
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Very cool! One partially-baked thought but this looks like a big improvement and tests passing seems convincing.
Thanks! |
This was referenced Dec 30, 2022
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.
I believe that globs were slow because the internals of how pathlib calls our functions made us loop over all of the files in the directory every time it was checking children, which happened for any nested file.
Instead of passing the whole file tree to every selectable instance and letting that object filter it down on demand, this implementation builds the entire file tree as nested dicts and then lets
scandir
walk those nested dicts. Each selectable now knows only about its direct parents/children.Closes #274
Perf results
The list and glob scenarios listed below are executed against the same file trees, so this lets us more or less compare raw
_list_dir
calls to the performance of glob. (Note: N: items is different because the glob test filters out folders).Before this change
Super slow........
After this change
Very little overhead when doing actual comparisons and filtering (~10%) beyond the vanilla
_list_dir
calls!Also, CI timings are fickle, but we may have knocked a few minutes off the test suite when compared to
master
: