Closespnpm/pnpm#17543.
pnpm/pnpm#17502 cached a linkable answer per store path, but still stated
every store file once before its first hardlink, although the store
verifier had read that inode's mode earlier in the same install. An
offline vitest install made 100k statx calls on 12.17.0 against 54k on
12.7.0.
The verifier now records each verified blob's mode in a process-wide map
keyed by store path, kept in pnpm_fs::file_mode next to the CAS write
locks, since the verifier and the importer sit in different crates and
install contexts. source_has_desired_mode reads the map and stats only on
a miss, recording the result. A blob that fails verification has its
entry marked stale, since the re-fetch may land a new inode with this
process's mode. A verifier read only fills an unknown path, so a read
that predates another thread's failure cannot refill it; only the
importer's own stat does. The map replaces the DashSet of linkable paths; the
linkability rule is unchanged. statx is back to 1.01x of 12.7.0.
Trade-offs: a mismatched mode is remembered too, so such a file keeps
being copied without a re-stat. A chmod of a store file by another
process during this process's life is not seen, as with the set before.
A long-lived process keeps one entry per store file it verified or
linked.
Wall time did not catch the 12.8.0 regression: each warm-cache statx
costs about a microsecond. The integrated benchmark now runs each install
twice more under strace --summary-only and fails the same-run comparison
when HEAD exceeds main's highest count of a file syscall by more than
max(2%, 50 calls). Rows whose identical runs disagree beyond that are
reported unstable and only gated past tolerance plus spread. A revert of
pnpm/pnpm#17502 fails it with 12 statx rows at +2.7% to +7.3% while the
timing table stays within tolerance.
---------
Co-authored-by: Zoltan Kochan <z@kochan.io>
Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>