-
Notifications
You must be signed in to change notification settings - Fork 113
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
Slower than node-glob
when ignoring a directory with dir/**
#45
Comments
Hello, @pvdlg, Thanks for good catch. Yeap, I know about this problem. The current behavior is described in «How to exclude directory from reading?» section. Unfortunately, I don't remember why I decided to only describe the current behavior. It seems that were borderline cases when the directory still need to read the case even if you specify a pattern that excludes this directory. I will try to find |
const globby = require('globby');
const entries = globby.sync(['**/*', '!a/**', 'a/*.{js,css}'], { cwd: 'test' });
console.dir(entries, { colors: true }); In this case,
So in this case we need to read the But the
In this case, we can safely ignore the reading of directories that end with the globstar. I file PR #49 for this case. |
Landed by |
See benchmark file: https://gist.github.com/pvdlg/8f72824d81263efc71b30fd443aa8b0e
patterns:
'a/*'
, ignore:['a']
231 op/s » fast-glob sync
136 op/s » glob sync
patterns:
'a/*'
, ignore:['a/**']
302 op/s » fast-glob sync
31,096 op/s » glob sync
It's quite an edge case as it seems the performance difference happens only when the the
ignore
pattern make so that no pattern will match. It seems thatnode-glob
is able to figure out that nothing will ever with pattern'a/*'
and ignore['a/**']
, whilefast-glob
still goes through the directory.With pattern
'a/*'
and ignore['a']
it seems neitherfast-glob
nornode-glob
figure out that nothing would match and both attempt to go through the directory.I thought the directory would be ignored completely in such case.
I'm not sure it's a big issue as it concerns a pattern/ignore config that doesn't make much sense, but I though it worth mentioning in case the perf improvement is really simple to do. Maybe ignoring patterns that are included within ignore pattern can bring other more useful performance improvements.
The text was updated successfully, but these errors were encountered: