-
Notifications
You must be signed in to change notification settings - Fork 31.2k
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
fs: improve globSync performance #57725
Conversation
Codecov ReportAll modified and coverable lines are covered by tests ✅
Additional details and impacted files@@ Coverage Diff @@
## main #57725 +/- ##
==========================================
- Coverage 90.22% 90.22% -0.01%
==========================================
Files 630 630
Lines 185073 185070 -3
Branches 36222 36223 +1
==========================================
- Hits 166990 166982 -8
+ Misses 11044 11041 -3
- Partials 7039 7047 +8
🚀 New features to boost your workflow:
|
// if it matches be more performant in the typical use case? #isExcluded() | ||
// is often ()=>false which is about as optimizable as a function gets. | ||
if (this.#cache.statSync(fullpath).isDirectory() && this.#isExcluded(`${fullpath}/`)) { | ||
if (this.#isExcluded(`${fullpath}/`) && this.#cache.statSync(fullpath).isDirectory()) { |
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.
I think the fastest way to would be to use this function: https://github.com/nodejs/node/blob/main/src/node_file.cc#L1053
Particularly: internalBinding('fs').internalModuleStat(path) which avoids creating unnecessary Dir/Dirent objects.
Landed in b2ab1a2 |
I'll take a look at @anonrig's suggestion for a subsequent PR (unless someone beats me to it!). |
Benchmark results: