-
Notifications
You must be signed in to change notification settings - Fork 112
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
Time to find a non glob path increase with number of files in the same directory #60
Comments
Hello, @pvdlg, Good catch! Yeap, this is due to the fact that we first try to read the directory, and then try to apply patterns. So we need fix this behaviour. Thanks for reporting! |
Just a few thoughts. We can extract only constant patterns from all patterns, for example, using a |
Would a check for file existence on each glob work?
|
Yeap, good idea! I think it's possible. Now the task manager doesn't know anything about the File System and i think he shouldn't know anything about it. We can create a new I'll invest time to this issue in the near future. |
If you can point me in the right direction I can take a look as well. I looked around but I couldn't wrap my head around how all the pieces fit together. |
By checking for each string passed in the Passing a non glob path is still less common than passing a glob. |
I prefer solution with I've already started working on this issue. |
Must be fixed by Thanks for reporting ❤️! |
Environment
Actual behavior
When searching for a single file (no glob parts in the path), the time increase with as the number of files in the same directory increase. With
node-glob
this time is constant.Find 1 file in a directory with 1 file (ran 500 times):
Find 1 file in a directory with 500 file (ran 500 times):
Find 1 file in a directory with 2000 file (ran 500 times):
Expected behavior
Globbing a static path (with no wildcards) is a something that can happen sometimes in modules that get the glob patterns from user input, as users can pass a list of file path (e.g,
mymodule file1.js file2.js file3.js
).It seems that
node-glob
has a way to detect those cases and optimize them. There is potential gain of perf infast-glob
by implementing the same type of optimization.Steps to reproduce
Use the code below and change the
TOTAL_FILES
to measure the changes in the globbing time betweenfast-glob
andnode-glob
.Code sample
The text was updated successfully, but these errors were encountered: