04da6816 perf: cut filesystem calls in the dependency walk
Per dependency edge the walk did an existsSync through the candidate
symlink (~150us on Windows), then lstat and realpath to collapse it, and
the walker lstat'ed the result again for its identity. Measured at this
repo's root: 2482 existsSync, 1244 lstat, and 779 realpath calls for
420 packages.
- Probe candidates with readlink first (~37us): a symlink yields its
target directly, a real directory fails with EINVAL and is checked
once, a missing entry fails with ENOENT.
- Memoize per scan: node_modules directory existence, candidate paths,
and symlink targets. Fifty packages depending on semver now resolve
its virtual-store target once.
- Prime the identity cache with resolved directories so the walker
skips their lstat.
- Sort workspace patterns and package dirs by code unit instead of
localeCompare, which initialized the ICU collator (~7ms) on every
CLI run and depends on the process locale.
Same repo root afterwards: 1382 existsSync, 465 lstat, 0 realpath;
intent list ~500ms -> ~320ms, and ~180ms -> ~135ms in an npm project.
Discovered packages and paths are unchanged.