Skip to content

perf(deps-restorer): key dir-clone cache slots by package content - #18294

Merged
zkochan merged 4 commits into
pnpm:mainfrom
jamenh:jhuang7/dir-clone-content-slots
Nov 21, 2026
Merged

zkochan merged 4 commits into
pnpm:mainfrom
jamenh:jhuang7/dir-clone-content-slots

Conversation

@jamenh

@jamenh jamenh commented Nov 21, 2026 •

Copy link
Copy Markdown
Member

Summary

On macOS, pnpm install imports a package by cloning a cached copy of its files (the dir-clone cache) into the project's virtual store with one clonefile. The cached copy, or canonical slot, used the global virtual store's slot path, which hashes the package's dependency graph, peers included. A package installed with several sets of peer dependencies therefore got one canonical slot per peer variant, even though every variant holds the same files. Each new variant paid the full per-file import into its own slot before it could be cloned.

This PR keys the canonical slot by the package's files instead: a SHA-256 over the sorted (file name, CAS path) pairs. All peer variants of one package version now share one slot. The first variant materializes it, and the others cost one directory clone each.

Changes:

  • Slot path. content_slot_dir maps the package's files to <dir-clone-cache>/content/xx/<rest>.
  • Cache eligibility. has_hashed_slot checks whether the snapshot has a precomputed global virtual store suffix. dir_clone_cacheable excludes packages that need builds, mutable sources, file: and git-hosted tarballs.
  • Why the content is the whole key. A canonical slot only holds node_modules/<name>, materialized from the package's CAS files, and builds never reach the cache. The CAS path already encodes the file's hash and executable bit, so two slots with equal keys hold byte-identical trees.
  • Tests. peer_variants_share_one_canonical_slot checks that a second peer variant is served by a clone of the first variant's slot. The key test covers file names, CAS paths, executable files, and map insertion order. The CLI dir_clone_cache suite looks up slots by package manifest.

Slots written under the old layout are no longer read. pnpm store prune already discards the dir-clone cache without reachability information, so they go away on the next prune.

Benchmarks

Measured on an M4 Pro with macOS 15.8 and endpoint security agents that slow file I/O, comparing v12.22.0 with this PR. Every run kept a warm CAS store and started with no node_modules. "Cold slots" also had no dir-clone cache. Before each timed warm-slot run, the binary rebuilt its own dir-clone cache with an untimed cold-slot install, because cloning from slots that are hours old is measurably slower than from fresh ones. Without that step, the comparison mostly measures slot age.

synthesized-giant-monorepo, a public repro with our monorepo's shape: a filtered install of about 2.3k of 13.7k workspace projects and 8.4k packages. 2 alternating runs each, mean.

Scenario v12.22.0 this PR
Warm store, cold slots 118.9 s 96.7 s (−19%)
Warm store, warm slots 81.2 s 69.7 s (−14%)

Our private monorepo, 1 run each:

Scenario v12.22.0 this PR
Warm store, cold slots 179.4 s 124.9 s (−30%)
Warm store, warm slots 96.7 s 81.5 s (−16%)

The dir-clone cache shrinks by about a third, because peer variants no longer get their own copies: from 8.3 GB to 5.7 GB on the private monorepo, measured earlier against main at f937394e67.

pnpm v11

The dir-clone cache exists only in v12, so v11 needs no change.


Get evidence
Open in [code]smith · Need help on this PR? Tag @codesmith-bot with what you need.

Summary by CodeRabbit

  • Performance
    • Improved pnpm install speed on macOS for packages used with multiple peer-dependency configurations. These installs can reuse one cached package copy across variants, reducing repeated work while preserving package contents. Cache reuse also remains available when a cached content blob has been removed, provided the package can be restored from another available copy.

Updated by an agent (Codex, GPT-6).

@coderabbitai

coderabbitai Bot commented Nov 21, 2026 •

Copy link
Copy Markdown
Contributor

Explain Change →

No actionable comments were generated in the recent review.

Walkthrough

Directory-clone imports now derive canonical content slots from CAS entries and use them instead of package-specific hashed slot paths. Tests cover peer variants sharing a canonical slot and identify cached package directories by manifest version.

Changes: Content slot imports

Layer / File(s) Summary
Canonical slot derivation and import
pnpm/crates/deps-restorer/src/dir_clone_cache.rs, pnpm/crates/deps-restorer/src/virtual_store_layout.rs
The cache sorts CAS entries and hashes their names and encoded paths to derive a canonical content-slot path. Imports use this path after checking whether the layout has a hashed slot.
Shared-slot validation and lookup
pnpm/crates/deps-restorer/src/dir_clone_cache/tests.rs, pnpm/crates/cli/tests/suite/dir_clone_cache.rs, .changeset/dir-clone-content-slots.md
Tests verify that peer variants can use one canonical slot and that CLI test lookup finds a package by manifest version. The changeset documents a patch release.

Estimated code review effort: 3 (Moderate) | ~20 minutes

Change: Refactor

Possibly related PRs

  • pnpm/pnpm#17909: Both changes modify the macOS directory-clone cache layout and its interaction with store pruning.

Suggested labels: product: pacquet

Suggested reviewers: qodo-code-review

Merge Risk: Minimal · up to 41f01

This change lets peer variants of the same package share one cached directory clone, which should speed up installs on macOS and shrink the cache. No concrete merge-blocking risk was found. Old cache slots are no longer read and will be removed on the next prune.

Finishing Touches

Generate unit tests (beta)

  • Create a new PR
  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

Share

Recent review info

Run configuration

  • Source mode: Auto
  • Repository: pnpm/pnpm
  • Branch: main
  • File: .coderabbit.yaml
  • Commit: 4941335
  • Layers: Repository YAML
  • Review profile: CHILL
  • Plan: Advanced
  • Run ID: dd4736fd-3a0b-4655-8323-41be11f74a68
Commits

Reviewing files that changed from the base of the PR and between 8d218be and 41f01fc.

Files selected for processing: 3

  • pnpm/crates/deps-restorer/src/dir_clone_cache.rs
  • pnpm/crates/deps-restorer/src/dir_clone_cache/tests.rs
  • pnpm/crates/deps-restorer/src/virtual_store_layout.rs

Included review availability: This review used your included allowance. Your plan provides up to 10 included reviews per hour; 8 remain after this review.

@github-actions

github-actions Bot commented Nov 21, 2026 •

Copy link
Copy Markdown
Contributor

Same-run regression check

HEAD and main are measured on the same runner. The tolerance is 5% of the main median or 2 ms, whichever is larger. A regression requires both the median slowdown and the gap between the fastest retained HEAD sample and slowest retained main sample to exceed this tolerance, after trimming up to 10% from each tail. Suspected regressions are rerun once with target order reversed and only fail if reproduced. This conservative noise guard is not a statistical confidence interval.

Inconclusive rows do not fail the check. They remain visible for performance review. Bencher retains absolute minimum timings for historical tracking; historical alerts do not gate this PR. Sequential measurements can still be affected by runner drift.

Scenario Engine main median HEAD median Change Tolerance Result
isolated-fresh-restore-cold-cache-cold-store pacquet 2290.35 ms 2295.62 ms 0.2% 114.52 ms Within tolerance
isolated-fresh-restore-cold-cache-cold-store pnpr 1367.49 ms 1467.52 ms 7.3% 68.37 ms Inconclusive (overlapping samples)
isolated-fresh-restore-hot-cache-hot-store pacquet 207.50 ms 209.07 ms 0.8% 10.38 ms Within tolerance
isolated-fresh-restore-hot-cache-hot-store pnpr 228.03 ms 225.26 ms -1.2% 11.40 ms Within tolerance
isolated-repeat-install-hot-cache-hot-store pacquet 9.00 ms 9.34 ms 3.8% 2.00 ms Within tolerance
isolated-repeat-install-hot-cache-hot-store pnpr 9.39 ms 9.23 ms -1.7% 2.00 ms Within tolerance
isolated-repeat-install-cold-cache-hot-store pacquet 9.68 ms 9.72 ms 0.4% 2.00 ms Within tolerance
isolated-repeat-install-cold-cache-hot-store pnpr 9.68 ms 9.70 ms 0.2% 2.00 ms Within tolerance
isolated-fresh-install-cold-cache-cold-store pacquet 2375.21 ms 2385.15 ms 0.4% 118.76 ms Within tolerance
isolated-fresh-install-cold-cache-cold-store pnpr 1546.16 ms 1561.14 ms 1.0% 77.31 ms Within tolerance
isolated-fresh-install-hot-cache-hot-store pacquet 466.50 ms 464.06 ms -0.5% 23.33 ms Within tolerance
isolated-fresh-install-hot-cache-hot-store pnpr 273.10 ms 283.91 ms 4.0% 13.66 ms Within tolerance
isolated-fresh-install-cold-cache-hot-store pacquet 1516.27 ms 1521.12 ms 0.3% 75.81 ms Within tolerance
isolated-fresh-install-cold-cache-hot-store pnpr 306.11 ms 307.68 ms 0.5% 15.31 ms Within tolerance
isolated-fresh-install-cold-cache-hot-store-cold-pnpr-resolve pacquet 1538.35 ms 1548.84 ms 0.7% 76.92 ms Within tolerance
isolated-fresh-install-cold-cache-hot-store-cold-pnpr-resolve pnpr 730.88 ms 744.63 ms 1.9% 36.54 ms Within tolerance
isolated-fresh-resolve-hot-cache-offline pacquet 266.95 ms 254.67 ms -4.6% 13.35 ms Within tolerance
isolated-fresh-resolve-hot-cache-offline pnpr 92.90 ms 93.45 ms 0.6% 4.65 ms Within tolerance
isolated-peer-heavy-resolve-hot-cache-offline pacquet 193.28 ms 177.05 ms -8.4% 9.66 ms Within tolerance
isolated-linked-workspace-resolve-hot-cache-offline pacquet 75.42 ms 76.61 ms 1.6% 3.77 ms Within tolerance
isolated-injected-workspace-repeat-install-hot-cache-hot-store pacquet 73.16 ms 73.49 ms 0.5% 3.66 ms Within tolerance
isolated-fresh-restore-cold-cache-cold-store-cold-pnpr pacquet 4453.04 ms 4398.87 ms -1.2% 222.65 ms Within tolerance
isolated-fresh-restore-cold-cache-cold-store-cold-pnpr pnpr 3491.33 ms 3438.06 ms -1.5% 174.57 ms Within tolerance
gvs-fresh-restore-hot-cache-hot-store pacquet 115.44 ms 120.64 ms 4.5% 5.77 ms Within tolerance
gvs-fresh-restore-hot-cache-hot-store pnpr 125.86 ms 126.18 ms 0.3% 6.29 ms Within tolerance
store-only-unlocked-direct-deps-cold-cache-hot-store pacquet 1112.66 ms 1134.87 ms 2.0% 55.63 ms Within tolerance
cargo-repeat-install-hot-cache-hot-store pacquet 31.76 ms 30.94 ms -2.6% 2.00 ms Within tolerance

Same-run syscall check

Each install runs 2 more times per revision, untimed, under strace --follow-forks --summary-only. A file syscall regresses when HEAD's fewest calls exceed main's most by more than 2% of main or 50 calls, whichever is larger. mkdir and mkdirat count only the calls that created a directory, since concurrent installs fail a varying number with EEXIST. A syscall whose identical runs differ by more than that tolerance is reported unstable and not gated, unless HEAD's fewest calls also exceed main's most by more than the tolerance plus that difference. Each scenario lists its largest change relative to its tolerance and every row that is not within tolerance.

Scenario Engine Syscall main calls (max) HEAD calls (min) Change Tolerance Identical-run spread Result
isolated-fresh-restore-cold-cache-cold-store pacquet ioctl 11 25 +127.3% 50 1 Within tolerance
isolated-fresh-restore-cold-cache-cold-store pnpr access 11 11 +0.0% 50 0 Within tolerance
isolated-fresh-restore-hot-cache-hot-store pacquet access 11 11 +0.0% 50 0 Within tolerance
isolated-fresh-restore-hot-cache-hot-store pnpr access 11 11 +0.0% 50 0 Within tolerance
isolated-repeat-install-hot-cache-hot-store pacquet access 8 8 +0.0% 50 0 Within tolerance
isolated-repeat-install-hot-cache-hot-store pnpr access 8 8 +0.0% 50 0 Within tolerance
isolated-repeat-install-cold-cache-hot-store pacquet access 8 8 +0.0% 50 0 Within tolerance
isolated-repeat-install-cold-cache-hot-store pnpr access 8 8 +0.0% 50 0 Within tolerance
isolated-fresh-install-cold-cache-cold-store pacquet access 11 11 +0.0% 50 0 Within tolerance
isolated-fresh-install-cold-cache-cold-store pnpr access 11 11 +0.0% 50 0 Within tolerance
isolated-fresh-install-hot-cache-hot-store pacquet access 11 11 +0.0% 50 0 Within tolerance
isolated-fresh-install-hot-cache-hot-store pnpr access 11 11 +0.0% 50 0 Within tolerance
isolated-fresh-install-cold-cache-hot-store pacquet access 11 11 +0.0% 50 0 Within tolerance
isolated-fresh-install-cold-cache-hot-store pacquet readlink 15450 15353 -0.6% 309 541 Unstable (identical runs differ by 541, not gated)
isolated-fresh-install-cold-cache-hot-store pnpr access 11 11 +0.0% 50 0 Within tolerance
isolated-fresh-install-cold-cache-hot-store-cold-pnpr-resolve pacquet access 11 11 +0.0% 50 0 Within tolerance
isolated-fresh-install-cold-cache-hot-store-cold-pnpr-resolve pnpr statx 81422 81429 +0.0% 1628 16 Within tolerance
isolated-fresh-resolve-hot-cache-offline pacquet openat 2927 2930 +0.1% 58 9 Within tolerance
isolated-fresh-resolve-hot-cache-offline pnpr access 8 8 +0.0% 50 0 Within tolerance
isolated-peer-heavy-resolve-hot-cache-offline pacquet access 8 8 +0.0% 50 0 Within tolerance
isolated-linked-workspace-resolve-hot-cache-offline pacquet access 8 8 +0.0% 50 0 Within tolerance
isolated-injected-workspace-repeat-install-hot-cache-hot-store pacquet access 11 11 +0.0% 50 0 Within tolerance
isolated-fresh-restore-cold-cache-cold-store-cold-pnpr pacquet ioctl 12 13 +8.3% 50 10 Within tolerance
isolated-fresh-restore-cold-cache-cold-store-cold-pnpr pnpr ioctl 11 12 +9.1% 50 10 Within tolerance
gvs-fresh-restore-hot-cache-hot-store pacquet access 11 11 +0.0% 50 0 Within tolerance
gvs-fresh-restore-hot-cache-hot-store pnpr access 11 11 +0.0% 50 0 Within tolerance
store-only-unlocked-direct-deps-cold-cache-hot-store pacquet access 8 8 +0.0% 50 0 Within tolerance
cargo-repeat-install-hot-cache-hot-store pacquet access 10 10 +0.0% 50 0 Within tolerance

Integrated-Benchmark Report (Linux)

Commit: 41f01fc54b17

Compared against main at: 4941335d39d0

Regular scenarios report direct and pnpr installs. The peer-heavy resolver scenario compares current Rust, main Rust, and TypeScript pnpm; the linked, injected, and Cargo workspace scenarios compare current Rust against main Rust. Bencher consumes pacquet@HEAD and pnpr@HEAD.

The tables below show mean ± σ. Bencher tracks absolute minimum latency; PR regression checks compare HEAD and main samples from the same runner. Historical timing alerts do not gate PRs.

Scenario: Isolated linker: fresh restore, cold cache + cold store

Command Mean [s] Min [s] Max [s] Relative
pacquet@HEAD 2.348 ± 0.128 2.226 2.561 1.71 ± 0.12
pacquet@main 2.298 ± 0.065 2.223 2.417 1.68 ± 0.09
pnpr@HEAD 1.449 ± 0.125 1.280 1.690 1.06 ± 0.10
pnpr@main 1.371 ± 0.060 1.272 1.446 1.00
BENCHMARK_REPORT.json
{
  "results": [
    {
      "command": "pacquet@HEAD",
      "mean": 2.3481400976,
      "stddev": 0.12844263203005427,
      "median": 2.2956159584,
      "user": 1.9257812600000002,
      "system": 1.47483524,
      "min": 2.2259864159,
      "max": 2.5607131359
    },
    {
      "command": "pacquet@main",
      "mean": 2.2976826547,
      "stddev": 0.06487246118002299,
      "median": 2.2903465344000002,
      "user": 1.9130698599999998,
      "system": 1.44450504,
      "min": 2.2230586349,
      "max": 2.4169224619
    },
    {
      "command": "pnpr@HEAD",
      "mean": 1.4491241892,
      "stddev": 0.12483812328820104,
      "median": 1.4675212924,
      "user": 1.7585849599999999,
      "system": 1.3900818400000001,
      "min": 1.2803883869000001,
      "max": 1.6903335509000001
    },
    {
      "command": "pnpr@main",
      "mean": 1.3707749650999999,
      "stddev": 0.06016928410462908,
      "median": 1.3674921404,
      "user": 1.80405236,
      "system": 1.39682604,
      "min": 1.2720328599,
      "max": 1.4455514109
    }
  ]
}

Scenario: Isolated linker: fresh restore, hot cache + hot store

Command Mean [ms] Min [ms] Max [ms] Relative
pacquet@HEAD 209.4 ± 7.3 198.0 223.3 1.00
pacquet@main 211.4 ± 11.4 198.4 232.6 1.01 ± 0.06
pnpr@HEAD 224.7 ± 6.0 216.3 233.2 1.07 ± 0.05
pnpr@main 229.5 ± 6.9 222.0 242.7 1.10 ± 0.05
BENCHMARK_REPORT.json
{
  "results": [
    {
      "command": "pacquet@HEAD",
      "mean": 0.20941616004000002,
      "stddev": 0.007300806613733956,
      "median": 0.20907146434,
      "user": 0.26144382,
      "system": 0.5320326999999999,
      "min": 0.19803782834000003,
      "max": 0.22334008834000002
    },
    {
      "command": "pacquet@main",
      "mean": 0.21143200624,
      "stddev": 0.011382766046138717,
      "median": 0.20750409934000003,
      "user": 0.25546182,
      "system": 0.5495876,
      "min": 0.19842815334000002,
      "max": 0.23258169234
    },
    {
      "command": "pnpr@HEAD",
      "mean": 0.22468822724,
      "stddev": 0.005956411563351629,
      "median": 0.22525875984000002,
      "user": 0.27028891999999993,
      "system": 0.5324456,
      "min": 0.21628036234,
      "max": 0.23319917334
    },
    {
      "command": "pnpr@main",
      "mean": 0.22952560254,
      "stddev": 0.006919760706026714,
      "median": 0.22803367734000002,
      "user": 0.27299182,
      "system": 0.5284513999999999,
      "min": 0.22203868934,
      "max": 0.24269888434
    }
  ]
}

Scenario: Isolated linker: repeat install, hot cache + hot store

Command Mean [ms] Min [ms] Max [ms] Relative
pacquet@HEAD 9.4 ± 0.4 8.7 11.9 1.04 ± 0.07
pacquet@main 9.0 ± 0.4 8.5 12.0 1.00
pnpr@HEAD 9.3 ± 0.3 8.5 11.5 1.02 ± 0.06
pnpr@main 9.4 ± 0.4 8.7 12.5 1.04 ± 0.07
BENCHMARK_REPORT.json
{
  "results": [
    {
      "command": "pacquet@HEAD",
      "mean": 0.009396377208421063,
      "stddev": 0.0004392725234547072,
      "median": 0.00933828984,
      "user": 0.005651714979757083,
      "system": 0.004721885829959513,
      "min": 0.008667238839999999,
      "max": 0.01189131784
    },
    {
      "command": "pacquet@main",
      "mean": 0.009048654046521738,
      "stddev": 0.00038303876491125417,
      "median": 0.00899501434,
      "user": 0.0057965398550724615,
      "system": 0.004151792391304349,
      "min": 0.00849324884,
      "max": 0.01201805684
    },
    {
      "command": "pnpr@HEAD",
      "mean": 0.009255632242027027,
      "stddev": 0.00031953386315393623,
      "median": 0.00922982984,
      "user": 0.005564502027027032,
      "system": 0.004711679054054053,
      "min": 0.00847564784,
      "max": 0.01150298684
    },
    {
      "command": "pnpr@main",
      "mean": 0.009435158293846151,
      "stddev": 0.00043350845265914745,
      "median": 0.00938855484,
      "user": 0.005642207692307694,
      "system": 0.004826596769230768,
      "min": 0.00874219884,
      "max": 0.01250177984
    }
  ]
}

Scenario: Isolated linker: repeat install, cold cache + hot store

Command Mean [ms] Min [ms] Max [ms] Relative
pacquet@HEAD 9.8 ± 0.4 8.9 11.2 1.01 ± 0.05
pacquet@main 9.7 ± 0.4 8.8 12.3 1.00 ± 0.05
pnpr@HEAD 9.7 ± 0.3 8.6 11.1 1.00
pnpr@main 9.7 ± 0.4 8.9 11.2 1.00 ± 0.05
BENCHMARK_REPORT.json
{
  "results": [
    {
      "command": "pacquet@HEAD",
      "mean": 0.009755696565535711,
      "stddev": 0.00036352504622408946,
      "median": 0.009715713820000001,
      "user": 0.005690330892857142,
      "system": 0.005046245535714284,
      "min": 0.008940367820000001,
      "max": 0.01124487182
    },
    {
      "command": "pacquet@main",
      "mean": 0.00971623103739131,
      "stddev": 0.0003877145617911289,
      "median": 0.00967967882,
      "user": 0.005908640869565215,
      "system": 0.004790499130434783,
      "min": 0.008805177820000001,
      "max": 0.01225237382
    },
    {
      "command": "pnpr@HEAD",
      "mean": 0.009703591294358972,
      "stddev": 0.0003330793281713578,
      "median": 0.00969999432,
      "user": 0.005797999658119659,
      "system": 0.004894273504273503,
      "min": 0.00863076682,
      "max": 0.011098210820000001
    },
    {
      "command": "pnpr@main",
      "mean": 0.009748473772941177,
      "stddev": 0.0003665701734203252,
      "median": 0.00968403982,
      "user": 0.005989162352941172,
      "system": 0.004738672156862748,
      "min": 0.00892882782,
      "max": 0.011237450820000001
    }
  ]
}

Scenario: Isolated linker: fresh install, cold cache + cold store

Command Mean [s] Min [s] Max [s] Relative
pacquet@HEAD 2.402 ± 0.040 2.370 2.511 1.56 ± 0.08
pacquet@main 2.382 ± 0.049 2.334 2.512 1.55 ± 0.08
pnpr@HEAD 1.572 ± 0.125 1.409 1.780 1.02 ± 0.09
pnpr@main 1.537 ± 0.070 1.422 1.683 1.00
BENCHMARK_REPORT.json
{
  "results": [
    {
      "command": "pacquet@HEAD",
      "mean": 2.40188640556,
      "stddev": 0.0403915858741581,
      "median": 2.38515496116,
      "user": 2.2363549999999996,
      "system": 1.5438070999999998,
      "min": 2.36986145366,
      "max": 2.51074283266
    },
    {
      "command": "pacquet@main",
      "mean": 2.38214057506,
      "stddev": 0.04872871485105206,
      "median": 2.3752115916600003,
      "user": 2.0877795,
      "system": 1.5236671999999998,
      "min": 2.33354433066,
      "max": 2.5120735296600003
    },
    {
      "command": "pnpr@HEAD",
      "mean": 1.57228299946,
      "stddev": 0.12456024164816108,
      "median": 1.5611429861600001,
      "user": 1.7927779999999998,
      "system": 1.4636696999999999,
      "min": 1.4093079396600001,
      "max": 1.78047261966
    },
    {
      "command": "pnpr@main",
      "mean": 1.53692770286,
      "stddev": 0.06981361065939216,
      "median": 1.5461623686600001,
      "user": 1.7314246999999998,
      "system": 1.4829626999999999,
      "min": 1.4221986746600002,
      "max": 1.68317626666
    }
  ]
}

Scenario: Isolated linker: fresh install, hot cache + hot store

Command Mean [ms] Min [ms] Max [ms] Relative
pacquet@HEAD 470.2 ± 16.4 451.3 498.9 1.71 ± 0.09
pacquet@main 468.3 ± 14.8 451.5 496.6 1.70 ± 0.09
pnpr@HEAD 284.5 ± 5.8 277.4 296.4 1.03 ± 0.05
pnpr@main 275.4 ± 10.8 261.5 302.1 1.00
BENCHMARK_REPORT.json
{
  "results": [
    {
      "command": "pacquet@HEAD",
      "mean": 0.47018704723999993,
      "stddev": 0.016446867402181438,
      "median": 0.46405589284000004,
      "user": 0.66619484,
      "system": 1.0063575400000002,
      "min": 0.45128327934,
      "max": 0.49888358634
    },
    {
      "command": "pacquet@main",
      "mean": 0.46833487044,
      "stddev": 0.014774280734452663,
      "median": 0.46650039884000005,
      "user": 0.68776904,
      "system": 0.9834028400000001,
      "min": 0.45152525434,
      "max": 0.49658215434
    },
    {
      "command": "pnpr@HEAD",
      "mean": 0.28452371194000003,
      "stddev": 0.00577107141092334,
      "median": 0.28390840234000003,
      "user": 0.29995143999999996,
      "system": 0.5203757399999999,
      "min": 0.27740285434,
      "max": 0.29641271134
    },
    {
      "command": "pnpr@main",
      "mean": 0.27538884724,
      "stddev": 0.010837987984156512,
      "median": 0.27310176034,
      "user": 0.27490724,
      "system": 0.5014299400000001,
      "min": 0.26147141534,
      "max": 0.30213843934
    }
  ]
}

Scenario: Isolated linker: fresh install, cold cache + hot store

Command Mean [s] Min [s] Max [s] Relative
pacquet@HEAD 1.532 ± 0.041 1.500 1.644 5.00 ± 0.18
pacquet@main 1.534 ± 0.047 1.502 1.657 5.01 ± 0.20
pnpr@HEAD 0.306 ± 0.008 0.294 0.322 1.00
pnpr@main 0.309 ± 0.010 0.299 0.332 1.01 ± 0.04
BENCHMARK_REPORT.json
{
  "results": [
    {
      "command": "pacquet@HEAD",
      "mean": 1.5317941567600002,
      "stddev": 0.04069378092469502,
      "median": 1.52112491006,
      "user": 0.8289171399999999,
      "system": 0.84210184,
      "min": 1.49966025706,
      "max": 1.64406384806
    },
    {
      "command": "pacquet@main",
      "mean": 1.5337501696599998,
      "stddev": 0.04654729665677588,
      "median": 1.51626975856,
      "user": 0.8342852399999998,
      "system": 0.81736744,
      "min": 1.50236731306,
      "max": 1.65743371206
    },
    {
      "command": "pnpr@HEAD",
      "mean": 0.3063332818600001,
      "stddev": 0.007824890816870052,
      "median": 0.30768357756,
      "user": 0.27693724,
      "system": 0.5906401399999999,
      "min": 0.29356123906000003,
      "max": 0.32224655406
    },
    {
      "command": "pnpr@main",
      "mean": 0.30877870336,
      "stddev": 0.010028962062420065,
      "median": 0.30611203856,
      "user": 0.2909329399999999,
      "system": 0.58779634,
      "min": 0.29868201606,
      "max": 0.33241173006
    }
  ]
}

Scenario: Isolated linker: fresh install, cold cache + hot store + cold pnpr resolve

Command Mean [s] Min [s] Max [s] Relative
pacquet@HEAD 1.555 ± 0.032 1.524 1.637 2.12 ± 0.07
pacquet@main 1.550 ± 0.033 1.530 1.639 2.12 ± 0.07
pnpr@HEAD 0.747 ± 0.015 0.721 0.772 1.02 ± 0.03
pnpr@main 0.732 ± 0.019 0.702 0.773 1.00
BENCHMARK_REPORT.json
{
  "results": [
    {
      "command": "pacquet@HEAD",
      "mean": 1.55500539182,
      "stddev": 0.03159479972978964,
      "median": 1.54884344002,
      "user": 0.8783656999999998,
      "system": 0.8945033400000002,
      "min": 1.5239657525199999,
      "max": 1.63691599152
    },
    {
      "command": "pacquet@main",
      "mean": 1.54972439982,
      "stddev": 0.032968818645371135,
      "median": 1.53835485502,
      "user": 0.8907143999999999,
      "system": 0.9382175399999998,
      "min": 1.53013077752,
      "max": 1.63930422952
    },
    {
      "command": "pnpr@HEAD",
      "mean": 0.7473986824199998,
      "stddev": 0.015043547077240652,
      "median": 0.74462828752,
      "user": 0.49739560000000005,
      "system": 0.76908134,
      "min": 0.72087255152,
      "max": 0.77180349452
    },
    {
      "command": "pnpr@main",
      "mean": 0.73185600682,
      "stddev": 0.018878132698557697,
      "median": 0.73088075852,
      "user": 0.4964474,
      "system": 0.7564807399999999,
      "min": 0.70189327652,
      "max": 0.77291660452
    }
  ]
}

Scenario: Isolated linker: fresh resolve, hot cache, offline

Command Mean [ms] Min [ms] Max [ms] Relative
pacquet@HEAD 257.8 ± 16.8 233.6 295.1 2.75 ± 0.20
pacquet@main 262.6 ± 17.6 230.8 292.1 2.80 ± 0.21
pnpr@HEAD 94.3 ± 3.4 88.6 105.8 1.01 ± 0.05
pnpr@main 93.8 ± 2.9 91.0 102.4 1.00
BENCHMARK_REPORT.json
{
  "results": [
    {
      "command": "pacquet@HEAD",
      "mean": 0.2577870858100001,
      "stddev": 0.016755405754460797,
      "median": 0.25467188656000006,
      "user": 0.23864802999999998,
      "system": 0.17003645999999997,
      "min": 0.23358632406000002,
      "max": 0.29510388606000004
    },
    {
      "command": "pacquet@main",
      "mean": 0.26255210306000004,
      "stddev": 0.01755684482637324,
      "median": 0.26694530606000005,
      "user": 0.24148005272727274,
      "system": 0.17176441454545452,
      "min": 0.23082408406000002,
      "max": 0.29212397506000004
    },
    {
      "command": "pnpr@HEAD",
      "mean": 0.09429274781862068,
      "stddev": 0.003447942716237485,
      "median": 0.09344983706000001,
      "user": 0.03503143517241379,
      "system": 0.020292994482758623,
      "min": 0.08864658606000002,
      "max": 0.10580621106000002
    },
    {
      "command": "pnpr@main",
      "mean": 0.09380040416344827,
      "stddev": 0.0029059087483695465,
      "median": 0.09290271706000001,
      "user": 0.035972469655172416,
      "system": 0.019527339310344827,
      "min": 0.09100348606000001,
      "max": 0.10243166106000001
    }
  ]
}

Scenario: Isolated linker: peer-heavy resolve, hot cache, offline

Command Mean [ms] Min [ms] Max [ms] Relative
pacquet@HEAD 180.7 ± 9.4 171.0 199.6 1.00
pacquet@main 195.7 ± 14.7 173.5 219.1 1.08 ± 0.10
pnpm@HEAD 3198.7 ± 42.1 3131.6 3243.7 17.70 ± 0.95
BENCHMARK_REPORT.json
{
  "results": [
    {
      "command": "pacquet@HEAD",
      "mean": 0.1806695701488889,
      "stddev": 0.00936746586448513,
      "median": 0.17704644026000002,
      "user": 0.1911212688888889,
      "system": 0.04507968,
      "min": 0.17103937626000001,
      "max": 0.19955860826000002
    },
    {
      "command": "pacquet@main",
      "mean": 0.19568352003777775,
      "stddev": 0.014746141872496447,
      "median": 0.19328094726,
      "user": 0.21300949111111112,
      "system": 0.03389879111111111,
      "min": 0.17350839926,
      "max": 0.21910731526000002
    },
    {
      "command": "pnpm@HEAD",
      "mean": 3.1986995567044443,
      "stddev": 0.04211241494927833,
      "median": 3.20479257826,
      "user": 4.827439268888889,
      "system": 0.29909390222222215,
      "min": 3.13159996626,
      "max": 3.24366583226
    }
  ]
}

Scenario: Isolated linker: linked-workspace resolve, hot cache, offline

Command Mean [ms] Min [ms] Max [ms] Relative
pacquet@HEAD 76.7 ± 1.9 73.9 82.8 1.00 ± 0.07
pacquet@main 76.3 ± 5.2 72.6 105.9 1.00
BENCHMARK_REPORT.json
{
  "results": [
    {
      "command": "pacquet@HEAD",
      "mean": 0.07667254253567565,
      "stddev": 0.0019055236934440395,
      "median": 0.07660888586000002,
      "user": 0.07953830648648649,
      "system": 0.03626214918918919,
      "min": 0.07393338586,
      "max": 0.08278197786000001
    },
    {
      "command": "pacquet@main",
      "mean": 0.07634156537351353,
      "stddev": 0.005172701937797144,
      "median": 0.07542343586000001,
      "user": 0.07508171189189188,
      "system": 0.03762836540540541,
      "min": 0.07258282586,
      "max": 0.10585331586000002
    }
  ]
}

Scenario: Isolated linker: injected workspace repeat install, hot cache + hot store

Command Mean [ms] Min [ms] Max [ms] Relative
pacquet@HEAD 74.0 ± 1.9 71.4 80.2 1.01 ± 0.03
pacquet@main 73.5 ± 1.6 71.4 80.4 1.00
BENCHMARK_REPORT.json
{
  "results": [
    {
      "command": "pacquet@HEAD",
      "mean": 0.07402569072410257,
      "stddev": 0.0019351355704543074,
      "median": 0.07349186516000002,
      "user": 0.026364159999999998,
      "system": 0.05667079025641028,
      "min": 0.07142859616000001,
      "max": 0.08015650716000002
    },
    {
      "command": "pacquet@main",
      "mean": 0.07352740763368422,
      "stddev": 0.001582634376565887,
      "median": 0.07315988566,
      "user": 0.02807710736842105,
      "system": 0.054581274736842086,
      "min": 0.07142754316000001,
      "max": 0.08044825416000001
    }
  ]
}

Scenario: Isolated linker: fresh restore, cold cache + cold store + cold pnpr

Command Mean [s] Min [s] Max [s] Relative
pacquet@HEAD 4.439 ± 0.081 4.375 4.636 1.27 ± 0.05
pacquet@main 4.499 ± 0.148 4.369 4.842 1.29 ± 0.06
pnpr@HEAD 3.493 ± 0.126 3.417 3.791 1.00
pnpr@main 3.558 ± 0.141 3.402 3.790 1.02 ± 0.05
BENCHMARK_REPORT.json
{
  "results": [
    {
      "command": "pacquet@HEAD",
      "mean": 4.43874929342,
      "stddev": 0.08062425825334585,
      "median": 4.39886984072,
      "user": 1.9736655999999997,
      "system": 1.57359624,
      "min": 4.37540707522,
      "max": 4.636091341219999
    },
    {
      "command": "pacquet@main",
      "mean": 4.49898308392,
      "stddev": 0.14788536687790196,
      "median": 4.453035528219999,
      "user": 1.9534474999999998,
      "system": 1.5544298399999998,
      "min": 4.36947008622,
      "max": 4.84230507922
    },
    {
      "command": "pnpr@HEAD",
      "mean": 3.4925314606199995,
      "stddev": 0.126038271903238,
      "median": 3.43806259772,
      "user": 1.8819700999999998,
      "system": 1.51903924,
      "min": 3.4168330662199997,
      "max": 3.7910396032199998
    },
    {
      "command": "pnpr@main",
      "mean": 3.55774413982,
      "stddev": 0.14059898168349128,
      "median": 3.49132965122,
      "user": 1.8532097,
      "system": 1.52606404,
      "min": 3.40162337222,
      "max": 3.7896002692199997
    }
  ]
}

Scenario: GVS linker: fresh restore, hot cache + hot store

Same install as the isolated fresh-restore hot/hot scenario, into the shared virtual store, the layout pnpm 12 installs into by default. Scenarios run on separate machines, so compare main and branch within each table.

Command Mean [ms] Min [ms] Max [ms] Relative
pacquet@HEAD 121.6 ± 5.7 111.9 134.2 1.05 ± 0.05
pacquet@main 115.3 ± 2.0 109.5 118.0 1.00
pnpr@HEAD 125.8 ± 2.7 121.4 131.2 1.09 ± 0.03
pnpr@main 125.7 ± 3.3 120.3 131.4 1.09 ± 0.03
BENCHMARK_REPORT.json
{
  "results": [
    {
      "command": "pacquet@HEAD",
      "mean": 0.12155688225047619,
      "stddev": 0.005658739183640456,
      "median": 0.12064075306000001,
      "user": 0.15268130476190475,
      "system": 0.15153717619047616,
      "min": 0.11186631006,
      "max": 0.13421056806
    },
    {
      "command": "pacquet@main",
      "mean": 0.11532484655999999,
      "stddev": 0.002022580542044288,
      "median": 0.11543923156000001,
      "user": 0.1519992181818182,
      "system": 0.1373503818181818,
      "min": 0.10945418906000001,
      "max": 0.11803613306
    },
    {
      "command": "pnpr@HEAD",
      "mean": 0.12581436731,
      "stddev": 0.002731357076294162,
      "median": 0.12618410556,
      "user": 0.1544549,
      "system": 0.13899199999999995,
      "min": 0.12136441406000001,
      "max": 0.13124930706000001
    },
    {
      "command": "pnpr@main",
      "mean": 0.12567785046,
      "stddev": 0.0032967194498611965,
      "median": 0.12585992506000002,
      "user": 0.15729054999999997,
      "system": 0.1387361,
      "min": 0.12034450306000001,
      "max": 0.13138671706000002
    }
  ]
}

Scenario: Store only: unlocked direct deps, cold cache + hot store

Store-only install (enableModulesDir: false, per-file store index, trusted lockfile) against a lockfile missing the direct dependencies that have peers, with the metadata cache wiped per iteration: the install resolves those from the registry, reuses their subtrees from the lockfile and checks the store, linking nothing. Direct installs only.

Command Mean [s] Min [s] Max [s] Relative
pacquet@HEAD 1.156 ± 0.048 1.110 1.233 1.02 ± 0.06
pacquet@main 1.128 ± 0.040 1.103 1.233 1.00
BENCHMARK_REPORT.json
{
  "results": [
    {
      "command": "pacquet@HEAD",
      "mean": 1.1561954982599998,
      "stddev": 0.047731673408601696,
      "median": 1.13486598206,
      "user": 0.57581042,
      "system": 0.24997132,
      "min": 1.11002172306,
      "max": 1.23343074506
    },
    {
      "command": "pacquet@main",
      "mean": 1.1280978997599997,
      "stddev": 0.039506262049743654,
      "median": 1.1126594345599998,
      "user": 0.53313932,
      "system": 0.23704441999999998,
      "min": 1.1029657420599999,
      "max": 1.23288804606
    }
  ]
}

Scenario: Cargo: repeat install, hot cache + hot store

Frozen repeat install of a Cargo workspace (cargo.enabled: true) whose crates are already materialized in <storeDir>/v11/crates/ and linked into .pnpm/crates/crates-io. Direct installs only.

Command Mean [ms] Min [ms] Max [ms] Relative
pacquet@HEAD 31.2 ± 0.9 29.8 35.0 1.00
pacquet@main 32.0 ± 1.0 30.4 38.4 1.02 ± 0.04
BENCHMARK_REPORT.json
{
  "results": [
    {
      "command": "pacquet@HEAD",
      "mean": 0.03124718169111112,
      "stddev": 0.0008830487437181813,
      "median": 0.030944193180000003,
      "user": 0.024864895555555544,
      "system": 0.019557979999999996,
      "min": 0.029845746680000004,
      "max": 0.03495671368
    },
    {
      "command": "pacquet@main",
      "mean": 0.03201493647569892,
      "stddev": 0.0010240125989622408,
      "median": 0.031761739680000005,
      "user": 0.026076443225806448,
      "system": 0.019531483870967745,
      "min": 0.030412607680000002,
      "max": 0.03840967968
    }
  ]
}

@codecov-commenter

codecov-commenter commented Nov 21, 2026 •

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 68.18182% with 7 lines in your changes missing coverage. Please review.
✅ Project coverage is 92.10%. Comparing base (843ca95) to head (41f01fc).
⚠️ Report is 1 commits behind head on main.

Files with missing lines Patch % Lines
...m/crates/deps-restorer/src/virtual_store_layout.rs 0.00% 4 Missing ⚠️
pnpm/crates/deps-restorer/src/dir_clone_cache.rs 83.33% 3 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main   #18294      +/-   ##
==========================================
- Coverage   92.10%   92.10%   -0.01%     
==========================================
  Files        2520     2520              
  Lines      318783   318832      +49     
==========================================
+ Hits       293608   293649      +41     
- Misses      25175    25183       +8     

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@jamenh
jamenh force-pushed the jhuang7/dir-clone-content-slots branch from 5b38265 to 000d415 Compare November 21, 2026 10:12
@jamenh
jamenh marked this pull request as ready for review November 21, 2026 10:50
@jamenh
jamenh requested a review from zkochan as a code owner November 21, 2026 10:50
@qodo-code-review

Copy link
Copy Markdown

Qodo reviews are paused for this user.

Troubleshooting steps vary by plan Learn more →

On a Teams plan?
Reviews resume once this user has a paid seat and their Git account is linked in Qodo.
Link Git account →

Using GitHub Enterprise Server, GitLab Self-Managed, or Bitbucket Data Center?
These require an Enterprise plan - Contact us
Contact us →

@greptile-apps

greptile-apps Bot commented Nov 21, 2026 •

Copy link
Copy Markdown
Contributor

RetriggerView in GreptileConfidence Score: 5/5

[Medium impact] The PR appears safe to merge; no actionable new issues remain.

Reviews (3) · Last reviewed commit: "test(deps-restorer): verify dir-clone ca..." · Reviewed by Greptile

greptile-apps[bot]
greptile-apps Bot previously approved these changes Nov 21, 2026
@github-actions github-actions Bot added the reviewed: coderabbit CodeRabbit submitted an approving review label Nov 21, 2026
jamenh and others added 4 commits November 21, 2026 12:28
@zkochan
zkochan force-pushed the jhuang7/dir-clone-content-slots branch from 8d218be to 41f01fc Compare November 21, 2026 11:33
@greptile-apps
greptile-apps Bot dismissed their stale review November 21, 2026 11:33

Dismissed because a newer commit was pushed; Greptile will re-review the current head.

@qodo-code-review

qodo-code-review Bot commented Nov 21, 2026 •

Copy link
Copy Markdown

Code Review by Qodo

🐞 Bugs (3) 📘 Rule violations (0) 🔗 Cross-repo conflicts (0) 📜 Skill insights (0)

Grey Divider


Remediation recommended

1. Installs can inherit another variant's permissions 🐞 Bug ≡ Correctness
Description
content_slot_dir hashes file names and CAS paths but omits the install's umask, while
clone_canonical_slot copies the permissions of the first variant's cached files. When another peer
variant uses the same store under a different umask, it now reuses that slot instead of
materializing files at the permissions its own install requires.
Code

pnpm/crates/deps-restorer/src/dir_clone_cache.rs[R339-344]

+    for (name, file) in files {
+        hasher.update(name.as_bytes());
+        hasher.update([0]);
+        hasher.update(file.path.as_os_str().as_encoded_bytes());
+        hasher.update([0]);
+    }
Relevance

●● Moderate

Mode/permission correctness on shared inodes has mixed history: a rejected target_mode suggestion
(#17549) and an accepted mode-caching suggestion (#17544); no umask-keyed precedent exists.

PR-#17549
PR-#17544

ⓘ Recommendations generated based on similar findings in past PRs

Evidence
The new key uses only names and CAS paths. Normal materialization derives file modes from the
current umask, but a warm canonical slot is accepted by its marker and directory-cloned without mode
alignment. Previously distinct peer variants selected distinct graph-hashed slots; the new key lets
them share permissions from an earlier install.

pnpm/crates/deps-restorer/src/dir_clone_cache.rs[236-250]
pnpm/crates/deps-restorer/src/dir_clone_cache.rs[280-323]
pnpm/crates/deps-restorer/src/dir_clone_cache.rs[335-350]
pnpm/crates/deps-restorer/src/link_file/target_mode.rs[19-35]
pnpm/crates/deps-restorer/src/import_indexed_dir/placement.rs[444-464]

Agent prompt
The issue below was found during a code review. Follow the provided context and guidance below and implement a solution

## Issue description
Peer variants installed under different umasks now share a canonical slot, so directory cloning can give the later install the first install's file permissions.
## Fix Focus Areas
- pnpm/crates/deps-restorer/src/dir_clone_cache.rs[335-350]
- pnpm/crates/deps-restorer/src/dir_clone_cache/tests.rs[64-86]
## Recommended Fix
Partition content slots by the current umask on macOS, or otherwise ensure cloned files receive the permissions fresh materialization would produce. Add a test that populates a slot for one peer variant and imports another under a different umask.

ⓘ Copy this prompt and use it to remediate the issue with your preferred AI generation tools

Dismiss ↗ | View ↗


2. Large packages slow warm cache lookups 🐞 Bug ➹ Performance
Description
content_slot_dir allocates and sorts the entire file map, then hashes every file name and CAS path
on each try_import call. Warm slots therefore repeat file-count-dependent CPU work for each peer
variant or hoisted import, despite needing only a marker check and directory clone after their slot
key is known.
Code

pnpm/crates/deps-restorer/src/dir_clone_cache.rs[R335-338]

+fn content_slot_dir(cache_dir: &Path, cas_paths: &pnpm_fs::CasPaths) -> PathBuf {
+    let mut files: Vec<_> = cas_paths.iter().collect();
+    files.sort_unstable_by_key(|(a, _)| *a);
+    let mut hasher = Sha256::new();
Relevance

●● Moderate

Per-call hashing cost is a performance claim; similar perf-motivated suggestions show mixed
outcomes, and the only close rejection (#18296) concerns measurement requests, not this change.

PR-#18296

ⓘ Recommendations generated based on similar findings in past PRs

Evidence
CasPaths is a per-file hash map, and the added function collects, sorts, and hashes all its
entries. Non-global-store slots are processed individually and each reaches try_import; on an
existing canonical directory, the importer returns after its marker check before the directory
clone. The full-map computation is consequently additional work on each warm lookup, most noticeable
for large packages or repeated variants.

pnpm/crates/fs/src/store_file.rs[105-105]
pnpm/crates/deps-restorer/src/dir_clone_cache.rs[233-250]
pnpm/crates/deps-restorer/src/dir_clone_cache.rs[335-350]
pnpm/crates/deps-restorer/src/create_virtual_store/slot_linking.rs[67-84]
pnpm/crates/deps-restorer/src/create_virtual_dir_by_snapshot.rs[220-242]
pnpm/crates/deps-restorer/src/import_indexed_dir.rs[416-438]

Agent prompt
The issue below was found during a code review. Follow the provided context and guidance below and implement a solution

## Issue description
Every warm cache lookup allocates, sorts, and hashes all package files, including repeated lookups for peer variants sharing the same file map.
## Fix Focus Areas
- pnpm/crates/deps-restorer/src/dir_clone_cache.rs[233-240]
- pnpm/crates/deps-restorer/src/dir_clone_cache.rs[335-350]
## Recommended Fix
Compute the content key once for each eligible package file map during preparation and reuse it for its imports and peer variants. Preserve the complete filename-and-CAS-path identity and add coverage for repeated lookups.

ⓘ Copy this prompt and use it to remediate the issue with your preferred AI generation tools

Dismiss ↗ | View ↗


3. Warm installs still hash the entire graph 🐞 Bug ➹ Performance
Description
try_import calls layout().has_hashed_slot merely to test snapshot membership, but initializing
that layout computes global-store suffixes for every snapshot. On the first cache lookup of a
non-global-store install, this adds graph-wide hashing and can wait for the Node version probe even
though the canonical path no longer uses either result.
Code

pnpm/crates/deps-restorer/src/dir_clone_cache.rs[236]

+        if !self.layout().has_hashed_slot(package_key) {
Relevance

●● Moderate

Perf concern about overlapping the Node probe in GVS-disabled cache path has a closely related
rejection (#16563), but the fix here is a real refactor with no direct precedent.

PR-#16563

ⓘ Recommendations generated based on similar findings in past PRs

Evidence
The cache runs only with the global virtual store disabled. Its layout builder nevertheless waits
for a pending engine value and calls VirtualStoreLayout::global, which generates a suffix for
every snapshot; has_hashed_slot then only checks whether the generated map contains the requested
key. The graph-hash code records approximately 10 ms of graph construction and suffix work for 1,355
nodes.

pnpm/crates/deps-restorer/src/dir_clone_cache.rs[127-133]
pnpm/crates/deps-restorer/src/dir_clone_cache.rs[195-202]
pnpm/crates/deps-restorer/src/dir_clone_cache.rs[421-437]
pnpm/crates/deps-restorer/src/virtual_store_layout.rs[296-304]
pnpm/crates/deps-restorer/src/virtual_store_layout.rs[361-366]
pnpm/crates/deps-restorer/src/virtual_store_layout/graph_hash.rs[185-207]

Agent prompt
The issue below was found during a code review. Follow the provided context and guidance below and implement a solution

## Issue description
The content-slot cache still builds every global-store suffix to answer a membership check, adding avoidable work and a possible probe wait to the first warm cache lookup.
## Fix Focus Areas
- pnpm/crates/deps-restorer/src/dir_clone_cache.rs[195-202]
- pnpm/crates/deps-restorer/src/dir_clone_cache.rs[233-240]
- pnpm/crates/deps-restorer/src/dir_clone_cache.rs[421-437]
## Recommended Fix
Check membership in the supplied snapshot map directly instead of constructing a global virtual store layout. Remove the layout and engine-probe dependency from this cache if they have no remaining purpose, preserving the existing behavior when snapshots are absent.

ⓘ Copy this prompt and use it to remediate the issue with your preferred AI generation tools

Dismiss ↗ | View ↗


Grey Divider

Context sources
✅ Compliance rules (platform): 45 rules
✅ Cross-repo context — repo relationships
Review mode: Auto: ⚖️ Balanced: Cache-key and import behavior changes create meaningful performance and correctness risk.

Grey Divider

Tip of the day
💡 Did you know, you can add REVIEW.md to your repo root and Qodo follows it on every PR

More tips ↗ | Customize Qodo ↗ | Qodo docs ↗

Grey Divider

Qodo Logo

@qodo-code-review

Copy link
Copy Markdown

PR Code Suggestions ✨

Warning

/improve is deprecated. Use /agentic_review instead (removal date not yet scheduled).

No code suggestions found for the PR.

@zkochan
zkochan merged commit fa3c44b into pnpm:main Nov 21, 2026
70 checks passed

@zkochan zkochan left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Reviewed the change and reproduced the numbers on a different machine.

Benchmark (M1 Max, macOS with an endpoint-security agent, synthesized-giant-monorepo, warm CAS store, empty node_modules). I compared 8d218be against its merge base f5f59e3. Before each run I rebuilt that binary's own dir-clone cache with a cold-slot install, as in the PR description. Two alternating runs each:

Scenario merge base this PR change
Warm store, cold slots 103.8 / 104.4 s 81.1 / 80.1 s -22%
Warm store, warm slots 62.8 / 62.4 s 54.4 / 54.7 s -13%

link_slots went from 72.1–72.8 s to 47.7–48.0 s with cold slots, and from 30.3–30.7 s to 22.4 s with warm slots. The runs agree to within a second.

Correctness. I found no problems:

  • Two peer variants that fill one content slot at the same time go through the import_indexed_dir marker protocol. That protocol already handles concurrent installs into one global virtual store slot.
  • Patched snapshots count as needing a build (snapshot_needs_build_marker), so they never reach the cache.
  • Packages with the same file set but different names get separate node_modules/<name> directories inside the shared slot.
  • pnpm store prune removes the whole cache directory, so slots in the old layout are only orphaned until the next prune. Nothing else looks slots up by the old path.

Nits:

  1. The module doc in dir_clone_cache.rs still says the cache uses "the global virtual store's slot layout". The doc on integrity_identifies_content in create_virtual_store/cache_keys.rs says the slot path "hashes that integrity and nothing else". Neither is true after this change.
  2. try_import still gates on hashed_slot_dir(package_key).is_none(), but the slot path no longer comes from it. If it only keeps the eligible set unchanged, a short comment saying so would stop a reader from looking for a dependency that isn't there.
  3. Possible follow-up, not for this PR: the content key now pins exactly the files the slot holds. The file: and git-hosted tarball exclusions in integrity_identifies_content existed because an integrity-keyed slot could be served stale, so they may no longer be needed.

Written by an agent (Claude Code, claude-opus-5-5).

@zkochan

zkochan commented Nov 21, 2026

Copy link
Copy Markdown
Member

Thanks for the repro (https://github.com/jamenh/synthesized-giant-monorepo), it made the materialization gap easy to dig into. Here is where things stand:

  • This PR is the main fix for the isolated layout. I reproduced it on an M1 Max: −22% with an empty clone cache and −13% with a warm one (details in my review above). No blocking issues, only a few doc nits.
  • Fastest option today: enableGlobalVirtualStore: true. With warm caches a fresh install only creates symlinks into the store, and it took 11–13 s here vs ~50 s for your Yarn fork.
  • The remaining gap to Yarn mostly comes from the lockfile: about 1,500 packages are installed in several peer-dependency variants, and the isolated layout needs a separate copy of each.
  • nodeLinker: hoisted: you were right that it's broken here. The layout calculation blows up on this peer graph and never finishes. That's tracked in Hoisted linker blows up on dense peer-variant graphs since peer variants keep distinct hoister references tasks#323.
  • Smaller fix: perf(deps-restorer): read each link: target's manifest once per bin pass #18296 (merged) stops pnpm from re-reading each workspace package's package.json when linking bins.

Written by an agent (Claude Code, claude-opus-5-5).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

product: pacquet reviewed: coderabbit CodeRabbit submitted an approving review state: automerge

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants