Replies: 2 comments 1 reply
-
this is actually very interesting, not just for this issue but overall |
Beta Was this translation helpful? Give feedback.
-
I just happened to see this discussion and figured I'd throw https://github.com/folder/readdir into the hat. FWIW I'm the creator and maintainer of the picomatch/micromatch libs. It's been a while since I worked on picomatch's benchmarks, so I'm not sure how it fairs against globrex, but our main goals with picomatch were to be as accurate and safe (from ReDoSS) as possible. There are likely performance penalties for that approach, but I felt it was worth the tradeoff (returning the wrong result faster doesn't help anyone). I also know the guys that work on globrex and tiny-glob, and they do a great job too. No worries if another approach makes more sense for you here. Either way, let me know if I can help. |
Beta Was this translation helpful? Give feedback.
-
Pnpm's
find-packages
walks the directory tree looking forpackage.json
files and reads them.Many commands such as
pnpm exec
andpnpm ls
run this.Many monorepo tooling depends on this. Anytime your tool needs to do something with pnpm workspace packages, you need to run this (usually via its caller
@pnpm/find-workspace-packages
).In large monorepos this can be slow. I have a large monorepo of 300+ packages and it takes about 1s on a MBP i9 8-core. Using a native Rust package with parallelism I can get this down to 200ms which is a huge improvement.
find-packages
currently usesfast-glob
(which usesmicromatch
for glob to regex compilation)Library Options
I just had a thorough discussion on the
fdir
project (which claims to be "The Fastest Directory Crawler & Globber for NodeJS") (usespicomatch
).It has comparable speeds to native Rust-based NAPI solutions.
Although, wrapping the Rust
ignore
package in a NAPI add-on which uses thread-based parallelism seems to be the fastest.fdir
withchild_process
workers could potentially compete, although the spin up of the process pool might negate benefits.There is also
tiny-glob
(usingglobrex
glob lib) which claims to be "~230% faster thanfast-glob
". I wouldn't recommendtiny-glob
right now. Has noignore
feature. terkelg/tiny-glob#79Interesting
UV_THREADPOOL_SIZE
(defaults to 4) can improve things on MBP i9 8-core (setting to 8 works well).Options
Node.js
Replacefast-glob
withtiny-glob
fast-glob
withfdir
UV_THREADPOOL_SIZE
.Native
NAPI
find-packages
as a native Rust NAPI addon usingignore
orjwalk
orglobwalk
.WASI
Daemon
Beta Was this translation helpful? Give feedback.
All reactions