Repository navigation
perf(deps-restorer): key dir-clone cache slots by package content - #18294
Conversation
|
No actionable comments were generated in the recent review. Walkthrough
Merge Risk:
|
Same-run regression checkHEAD 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.
Same-run syscall checkEach install runs 2 more times per revision, untimed, under
Integrated-Benchmark Report (Linux)Commit: Compared against main at: 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
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
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
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
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
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
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
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
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
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
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
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
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
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 storeSame 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.
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 storeStore-only install (
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 storeFrozen repeat install of a Cargo workspace (
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 Report❌ Patch coverage is
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. 🚀 New features to boost your workflow:
|
5b38265 to
000d415
Compare
Qodo reviews are paused for this user.Troubleshooting steps vary by plan Learn more → On a Teams plan? Using GitHub Enterprise Server, GitLab Self-Managed, or Bitbucket Data Center? |
[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 |
Cover file names, CAS paths, executable variants, and insertion order. Use a suffix lookup for the eligibility gate to avoid constructing an unused path.
8d218be to
41f01fc
Compare
Dismissed because a newer commit was pushed; Greptile will re-review the current head.
Code Review by Qodo
1. Installs can inherit another variant's permissions
|
PR Code Suggestions ✨Warning
No code suggestions found for the PR. |
zkochan
left a comment
There was a problem hiding this comment.
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_dirmarker 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 pruneremoves 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:
- The module doc in
dir_clone_cache.rsstill says the cache uses "the global virtual store's slot layout". The doc onintegrity_identifies_contentincreate_virtual_store/cache_keys.rssays the slot path "hashes that integrity and nothing else". Neither is true after this change. try_importstill gates onhashed_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.- 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 inintegrity_identifies_contentexisted 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).
|
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:
Written by an agent (Claude Code, claude-opus-5-5). |
Summary
On macOS,
pnpm installimports a package by cloning a cached copy of its files (the dir-clone cache) into the project's virtual store with oneclonefile. 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:
content_slot_dirmaps the package's files to<dir-clone-cache>/content/xx/<rest>.has_hashed_slotchecks whether the snapshot has a precomputed global virtual store suffix.dir_clone_cacheableexcludes packages that need builds, mutable sources,file:and git-hosted tarballs.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.peer_variants_share_one_canonical_slotchecks 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 CLIdir_clone_cachesuite looks up slots by package manifest.Slots written under the old layout are no longer read.
pnpm store prunealready 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.
Our private monorepo, 1 run each:
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
mainatf937394e67.pnpm v11
The dir-clone cache exists only in v12, so v11 needs no change.
Open in [code]smith · Need help on this PR? Tag
@codesmith-botwith what you need.Summary by CodeRabbit
pnpm installspeed 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).