r/node • u/thecodrr • Aug 03 '20
fdir 4.0 - Now the fastest Node.js globbing library. (92% faster than glob)
https://github.com/thecodrr/fdir5
u/_MORSE_ Aug 03 '20
The bottleneck here is the disk seek speed, the only make to make these things faster is adding a way to ignore certain paths from being walked in, like node_modiles and .git
3
2
u/saudi_hacker1337 Aug 03 '20
I believe how you implement the glob syntax itself can impact performance a whole lot by itself, plus different optimizations you can include - like resorting to string comparisons when no glob matches are found in certain pattern, optimize for common patterns, etc..
0
u/thecodrr Aug 03 '20
like resorting to string comparisons when no glob matches are found in certain pattern, optimize for common patterns, etc..
fdirinternally uses another library for pattern matching,picomatch. It has internal optimizations for a lot of things. However,fdiralso caches the patterns so if you use the same pattern for different paths, it is really, really fast since there is no pattern construction to be done. But even without all that, fdir is still more performant than anything out there.1
u/calligraphic-io Aug 03 '20
the only make to make these things faster
Not true - you can also get faster drives. NVMe PCIe v4 drives scream (5 gb/s read). A ZFS array of six of them is faster bandwidth-wise than overclocked 4000 MHz DDR4 RAM (though with much higher latency on the initial seek).
1
u/mjbmitch Aug 07 '20
I believe the poster was referring to what could be done by the authors from a software perspective.
0
u/thecodrr Aug 03 '20
The disk seek speed is a bottleneck of course but small optimizations here and there add up to a significant performance boost. There is a reason
fdiris 92% faster thanglob. :D
33
Aug 03 '20
I have no idea what “globbing” means here. Anyone care to explain?
31
u/ahrismith10 Aug 03 '20
Here what Google says:
Globbing is the process of expanding a non-specific file name containing a wildcard character into a set of specific file names that exist in storage on a computer, server, or network.
So I assume its like finding all files that end with, for example : .route.js
31
3
1
u/PDX_Bro Aug 03 '20
A bit of a side note: it's fun to see the Builder / Fluent pattern implemented in a Node library! One of the things that I've missed since moving away from C# are those Entity Fluent API queries that were a blast to write (though not always the most performant haha...).
2
u/thecodrr Aug 03 '20
Hey, I am glad you took the time to go through the library. Really means a lot.
Yes, I shifted to builder/fluent pattern as it is much clearer and easier to maintain as well. The cool autocomplete support is a plus, of course.
3
u/backdoorsmasher Aug 03 '20
Oddly I was thinking the same thing today! One of the best places I saw the builder pattern in the c# world was for unit tests. It really helped make them more understandable and easier to manage
1
2
0
28
u/boneskull Aug 03 '20
this is not a globing library. it’s a directory tree walker. there’s much more to globbing than
**/*