Repository navigation
fix(deps-restorer): build a shared global virtual store slot again when nothing is cached - #17528
Conversation
…en nothing is cached With enableGlobalVirtualStore, an install skipped the build scripts of a dependency whose slot an earlier install had built, even when the side-effects cache had no build output to restore for it. A build whose effect lands outside its own package, such as a git hook installer, then never took effect in a second project that shares the slot. pnpm v11 decides whether a slot is built only from the side-effects cache (`isBuilt` from the matched row), apart from waiting out a concurrent build. The slot-level skip had no v11 counterpart, so it is removed; the side-effects `is_built` gate still skips builds that have output to restore. Closes #17526 Co-Authored-By: Claude Opus 5.5 <[email protected]>
|
No actionable comments were generated in the recent review.
|
| Layer / File(s) | Summary |
|---|---|
Shared-slot build eligibility and regression coverage pnpm/crates/deps-restorer/src/build_modules/build_one_snapshot/slot_to_build.rs, pnpm/crates/cli/tests/suite/global_virtual_store/builds.rs, .changeset/gvs-rebuild-shared-slot.md |
The earlier-install check is removed, so eligible slots proceed to marker checks and locking. The updated test verifies that postinstall output is recreated on both installs. The changeset describes the shared-slot build scenario. |
Estimated code review effort: 2 (Simple) | ~10 minutes
Change: Bug fix · Severity of issue fixed: Medium
Assessment against linked issues
| Objective | Addressed | Explanation |
|---|---|---|
Run a dependency’s build script in a project when another project has already built the shared global virtual store slot [#17526] |
✅ |
Possibly related PRs
- pnpm/pnpm#17231: Both changes address build execution for dependencies in global virtual-store slots, through different slot-building paths.
- pnpm/pnpm#17318: Both changes alter dependency-restorer decisions about whether shared slots can be reused without running a build.
- pnpm/pnpm#17499: Both changes address lifecycle scripts for packages used in shared installation layouts.
Suggested labels: product: pacquet
Suggested reviewers: rubnogueira
Merge Risk: 
Minimal · up to c7d28
-
The concurrent-install limitation predates this change. No identified issue with the new shared-slot build behavior blocks merging.
Finishing Touches
-
📝 Generate docstrings
-
- Commit to this branch
- Create a new PR
🧪 Generate unit tests (beta)
-
- Commit to this branch
- 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.
Comment @coderabbitai help to get the list of available commands.
Micro-Benchmark ResultsLinux |
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.
Integrated-Benchmark Report (Linux)Commit: 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.40655422944,
"stddev": 0.10882228491201204,
"median": 2.42226874264,
"user": 1.9652159599999997,
"system": 1.45158104,
"min": 2.26147602364,
"max": 2.5619968336400003
},
{
"command": "pacquet@main",
"mean": 2.30517653064,
"stddev": 0.11677337912384073,
"median": 2.2637093116400004,
"user": 2.04461936,
"system": 1.53343874,
"min": 2.23522453564,
"max": 2.62353210464
},
{
"command": "pnpr@HEAD",
"mean": 1.4382670676399998,
"stddev": 0.12436327382587045,
"median": 1.41589292014,
"user": 1.77649936,
"system": 1.33595154,
"min": 1.27817196364,
"max": 1.63829834264
},
{
"command": "pnpr@main",
"mean": 1.3551073433399998,
"stddev": 0.09030714517882879,
"median": 1.3207100176399997,
"user": 1.81032736,
"system": 1.3632209400000002,
"min": 1.2741589676399998,
"max": 1.5556792146399998
}
]
}Scenario: Isolated linker: fresh restore, hot cache + hot store
BENCHMARK_REPORT.json{
"results": [
{
"command": "pacquet@HEAD",
"mean": 0.25600274204000006,
"stddev": 0.009785586751089054,
"median": 0.25340688664,
"user": 0.32428842,
"system": 0.6192541799999999,
"min": 0.24554081064000002,
"max": 0.27922400064
},
{
"command": "pacquet@main",
"mean": 0.25307491514,
"stddev": 0.007963328703271452,
"median": 0.25357433764000004,
"user": 0.29550701999999995,
"system": 0.6391823799999998,
"min": 0.24142867764000003,
"max": 0.26932252664
},
{
"command": "pnpr@HEAD",
"mean": 0.27087281964,
"stddev": 0.010210194788781329,
"median": 0.27053969763999997,
"user": 0.33180732,
"system": 0.6565551799999998,
"min": 0.25506199264,
"max": 0.28621845264
},
{
"command": "pnpr@main",
"mean": 0.26827595953999994,
"stddev": 0.009194089515017823,
"median": 0.26549277514,
"user": 0.31963832000000003,
"system": 0.62050578,
"min": 0.25537820564,
"max": 0.28318257664
}
]
}Scenario: Isolated linker: repeat install, hot cache + hot store
BENCHMARK_REPORT.json{
"results": [
{
"command": "pacquet@HEAD",
"mean": 0.009272084429635037,
"stddev": 0.0006563041231943803,
"median": 0.009235007780000002,
"user": 0.0051529464233576626,
"system": 0.005013319051094891,
"min": 0.007929879280000001,
"max": 0.012710146280000001
},
{
"command": "pacquet@main",
"mean": 0.009123764240365853,
"stddev": 0.0008041818832295003,
"median": 0.009000498280000001,
"user": 0.005345966585365853,
"system": 0.004563098292682927,
"min": 0.007967190280000001,
"max": 0.014019651280000002
},
{
"command": "pnpr@HEAD",
"mean": 0.009402529890921506,
"stddev": 0.0006754033224446251,
"median": 0.00928585328,
"user": 0.005545200477815704,
"system": 0.004668310921501706,
"min": 0.008207540280000002,
"max": 0.01273595528
},
{
"command": "pnpr@main",
"mean": 0.009408836320816327,
"stddev": 0.0006067852728880632,
"median": 0.00932572278,
"user": 0.005709258231292517,
"system": 0.004513734829931969,
"min": 0.008085632280000001,
"max": 0.01183944328
}
]
}Scenario: Isolated linker: repeat install, cold cache + hot store
BENCHMARK_REPORT.json{
"results": [
{
"command": "pacquet@HEAD",
"mean": 0.008489103205098042,
"stddev": 0.0007191164851085578,
"median": 0.008387580660000001,
"user": 0.005035391764705885,
"system": 0.0041780605490196075,
"min": 0.0072503316600000004,
"max": 0.013062871660000001
},
{
"command": "pacquet@main",
"mean": 0.00871782571904059,
"stddev": 0.0006776914688409446,
"median": 0.008579701660000001,
"user": 0.005277455276752768,
"system": 0.004192585977859777,
"min": 0.007620517660000001,
"max": 0.014618946660000002
},
{
"command": "pnpr@HEAD",
"mean": 0.008588001601979523,
"stddev": 0.0005209378994163197,
"median": 0.008477580660000001,
"user": 0.005446725392491467,
"system": 0.0039450318088737205,
"min": 0.007440169660000001,
"max": 0.011598356660000001
},
{
"command": "pnpr@main",
"mean": 0.008633935194883726,
"stddev": 0.0009514242995972357,
"median": 0.008539586660000001,
"user": 0.005144185315614619,
"system": 0.004191402657807308,
"min": 0.007307549660000001,
"max": 0.012650796660000001
}
]
}Scenario: Isolated linker: fresh install, cold cache + cold store
BENCHMARK_REPORT.json{
"results": [
{
"command": "pacquet@HEAD",
"mean": 2.87366313374,
"stddev": 0.1740179310870082,
"median": 2.82426835374,
"user": 3.347315079999999,
"system": 2.30973648,
"min": 2.6870004847400004,
"max": 3.18344106274
},
{
"command": "pacquet@main",
"mean": 2.94720351774,
"stddev": 0.18407148921488659,
"median": 2.91042439774,
"user": 3.3148181799999996,
"system": 2.4694771799999997,
"min": 2.7288996727400003,
"max": 3.27346698874
},
{
"command": "pnpr@HEAD",
"mean": 1.64649109024,
"stddev": 0.08331842802248046,
"median": 1.64342639174,
"user": 2.3617463800000005,
"system": 2.00728148,
"min": 1.52150426074,
"max": 1.8255074627399999
},
{
"command": "pnpr@main",
"mean": 1.6182083942399998,
"stddev": 0.10666955351399236,
"median": 1.59612851674,
"user": 2.22936518,
"system": 1.88340518,
"min": 1.5051731987399999,
"max": 1.84540753674
}
]
}Scenario: Isolated linker: fresh install, hot cache + hot store
BENCHMARK_REPORT.json{
"results": [
{
"command": "pacquet@HEAD",
"mean": 0.50437448668,
"stddev": 0.030983098582563477,
"median": 0.50099352798,
"user": 0.7300378000000001,
"system": 1.09771988,
"min": 0.44384371398000005,
"max": 0.54917162098
},
{
"command": "pacquet@main",
"mean": 0.51695854118,
"stddev": 0.03125469264257942,
"median": 0.51936571248,
"user": 0.7718700999999999,
"system": 1.1127802800000002,
"min": 0.47596652498,
"max": 0.55986681098
},
{
"command": "pnpr@HEAD",
"mean": 0.32438334998000007,
"stddev": 0.015923588926281002,
"median": 0.32877964398000004,
"user": 0.3124138,
"system": 0.6426587799999999,
"min": 0.29245434098000006,
"max": 0.34699763698
},
{
"command": "pnpr@main",
"mean": 0.31999775358,
"stddev": 0.013163794428821141,
"median": 0.31700729948000006,
"user": 0.3056358,
"system": 0.65532638,
"min": 0.30038954598000006,
"max": 0.33751890498000003
}
]
}Scenario: Isolated linker: fresh install, cold cache + hot store
BENCHMARK_REPORT.json{
"results": [
{
"command": "pacquet@HEAD",
"mean": 1.5741563458599999,
"stddev": 0.014343323549838586,
"median": 1.5698937644600002,
"user": 0.8178859800000001,
"system": 0.7797301799999999,
"min": 1.55900090846,
"max": 1.60026169846
},
{
"command": "pacquet@main",
"mean": 1.5776316720600003,
"stddev": 0.010878979878388038,
"median": 1.5793336739600001,
"user": 0.7784715799999999,
"system": 0.78600158,
"min": 1.56272119946,
"max": 1.59155503446
},
{
"command": "pnpr@HEAD",
"mean": 0.28143715536,
"stddev": 0.010386405144768778,
"median": 0.27756158496000005,
"user": 0.27572778,
"system": 0.5491997799999999,
"min": 0.27078241946000003,
"max": 0.30232671846000003
},
{
"command": "pnpr@main",
"mean": 0.28361917376,
"stddev": 0.013083552591447159,
"median": 0.28020944046,
"user": 0.26422567999999996,
"system": 0.57882628,
"min": 0.26448169946,
"max": 0.30886137746000003
}
]
}Scenario: Isolated linker: fresh resolve, hot cache, offline
BENCHMARK_REPORT.json{
"results": [
{
"command": "pacquet@HEAD",
"mean": 0.27792279261999997,
"stddev": 0.011619480965224404,
"median": 0.27887424892,
"user": 0.27108375999999995,
"system": 0.31552226,
"min": 0.25371445142,
"max": 0.29731636542
},
{
"command": "pacquet@main",
"mean": 0.2778638413290909,
"stddev": 0.013239556170810258,
"median": 0.28140387542,
"user": 0.2748027145454545,
"system": 0.30755181454545455,
"min": 0.25091833342000003,
"max": 0.29315141342
},
{
"command": "pnpr@HEAD",
"mean": 0.10152591514413792,
"stddev": 0.004474586067479953,
"median": 0.10091312142000002,
"user": 0.04029450137931034,
"system": 0.03260922206896552,
"min": 0.09316919042,
"max": 0.11154920042000001
},
{
"command": "pnpr@main",
"mean": 0.09886913452344828,
"stddev": 0.0059990717621073875,
"median": 0.09802615342000001,
"user": 0.04158167379310345,
"system": 0.025975222068965517,
"min": 0.08847794042000001,
"max": 0.11414592242
}
]
}Scenario: Isolated linker: peer-heavy resolve, hot cache, offline
BENCHMARK_REPORT.json{
"results": [
{
"command": "pacquet@HEAD",
"mean": 0.17903931665777778,
"stddev": 0.009149239623557433,
"median": 0.17627035588,
"user": 0.19198798444444443,
"system": 0.053137035555555566,
"min": 0.16873152488,
"max": 0.19329652088
},
{
"command": "pacquet@main",
"mean": 0.2016191127688889,
"stddev": 0.014180364955467081,
"median": 0.20416159988,
"user": 0.22003954,
"system": 0.05279881333333333,
"min": 0.17838691588,
"max": 0.23117159388
},
{
"command": "pnpm@HEAD",
"mean": 3.913799207213333,
"stddev": 0.36270793530840445,
"median": 3.77049478488,
"user": 6.097112873333334,
"system": 0.3737902577777778,
"min": 3.4433346658799997,
"max": 4.5487747268800005
}
]
}Scenario: Isolated linker: linked-workspace resolve, hot cache, offline
BENCHMARK_REPORT.json{
"results": [
{
"command": "pacquet@HEAD",
"mean": 0.08173781620285714,
"stddev": 0.0014850808255433717,
"median": 0.08164379786,
"user": 0.07077965714285712,
"system": 0.047099720000000005,
"min": 0.07895186586000001,
"max": 0.08554059186
},
{
"command": "pacquet@main",
"mean": 0.08329049960285713,
"stddev": 0.003561199783341567,
"median": 0.08268438886000001,
"user": 0.0779828,
"system": 0.04163846285714285,
"min": 0.07949352586000001,
"max": 0.09994602486000001
}
]
}Scenario: Isolated linker: injected workspace repeat install, hot cache + hot store
BENCHMARK_REPORT.json{
"results": [
{
"command": "pacquet@HEAD",
"mean": 0.07650725383333333,
"stddev": 0.0019000466202069518,
"median": 0.0759274635,
"user": 0.027113207692307694,
"system": 0.05523485897435897,
"min": 0.0744468465,
"max": 0.08381994649999999
},
{
"command": "pacquet@main",
"mean": 0.07580496103846156,
"stddev": 0.0031834588873449875,
"median": 0.0748865405,
"user": 0.026490053846153848,
"system": 0.054971346153846155,
"min": 0.0736400235,
"max": 0.0924434625
}
]
}Scenario: Isolated linker: fresh restore, cold cache + cold store + cold pnpr
BENCHMARK_REPORT.json{
"results": [
{
"command": "pacquet@HEAD",
"mean": 4.66005235648,
"stddev": 0.15603525382440045,
"median": 4.57487608298,
"user": 2.5145580399999994,
"system": 1.8865029200000003,
"min": 4.51339845498,
"max": 4.94525402198
},
{
"command": "pacquet@main",
"mean": 4.500524518480001,
"stddev": 0.15951085312891183,
"median": 4.41677490248,
"user": 2.1901108399999996,
"system": 1.6227175199999997,
"min": 4.36573155498,
"max": 4.85748900998
},
{
"command": "pnpr@HEAD",
"mean": 3.5874103988800004,
"stddev": 0.10181119697991897,
"median": 3.56806940298,
"user": 2.3376727399999995,
"system": 1.71352942,
"min": 3.48993416098,
"max": 3.82809248498
},
{
"command": "pnpr@main",
"mean": 3.63327792168,
"stddev": 0.15789441375562077,
"median": 3.57993724648,
"user": 2.28232384,
"system": 1.7394115200000002,
"min": 3.47741307498,
"max": 3.94506988198
}
]
}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.1326610059911111,
"stddev": 0.006837106386959582,
"median": 0.13148440488000002,
"user": 0.16883786888888888,
"system": 0.15919986666666666,
"min": 0.12287082788,
"max": 0.14522825688000002
},
{
"command": "pacquet@main",
"mean": 0.1384720297221053,
"stddev": 0.006348146479673363,
"median": 0.13721243488,
"user": 0.1790785326315789,
"system": 0.1662095947368421,
"min": 0.12866761788000003,
"max": 0.15607294788
},
{
"command": "pnpr@HEAD",
"mean": 0.14421153010222224,
"stddev": 0.00521934802252776,
"median": 0.14318283088,
"user": 0.17445247999999997,
"system": 0.15946369999999996,
"min": 0.13487907688,
"max": 0.15625978988000003
},
{
"command": "pnpr@main",
"mean": 0.14314355838000006,
"stddev": 0.005823222972591723,
"median": 0.14189827088,
"user": 0.17622897999999998,
"system": 0.15770014444444444,
"min": 0.13296450688000003,
"max": 0.15313093688
}
]
}Scenario: Store only: unlocked direct deps, cold cache + hot storeStore-only install (
BENCHMARK_REPORT.json{
"results": [
{
"command": "pacquet@HEAD",
"mean": 1.20340640902,
"stddev": 0.05158473058046694,
"median": 1.18454628342,
"user": 0.5338513399999999,
"system": 0.2337574,
"min": 1.1501329289200002,
"max": 1.3126930299200001
},
{
"command": "pacquet@main",
"mean": 1.23145137232,
"stddev": 0.04383114402044707,
"median": 1.2207693754200002,
"user": 0.5472590399999999,
"system": 0.27496139999999997,
"min": 1.17763480192,
"max": 1.29761411592
}
]
}Scenario: Cargo: repeat install, hot cache + hot storeFrozen repeat install of a Cargo workspace (
BENCHMARK_REPORT.json{
"results": [
{
"command": "pacquet@HEAD",
"mean": 0.03626203830941176,
"stddev": 0.004382730111924727,
"median": 0.03505417978,
"user": 0.02638593647058824,
"system": 0.02109843058823529,
"min": 0.03138514578,
"max": 0.06044105878
},
{
"command": "pacquet@main",
"mean": 0.03691120209168831,
"stddev": 0.0032789467904118567,
"median": 0.03639918778,
"user": 0.027254643116883127,
"system": 0.0211332612987013,
"min": 0.03183146378,
"max": 0.049498285780000005
}
]
} |
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #17528 +/- ##
=======================================
Coverage 92.67% 92.67%
=======================================
Files 1927 1927
Lines 251409 251384 -25
=======================================
- Hits 232988 232971 -17
+ Misses 18421 18413 -8 ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
There was a problem hiding this comment.
Your trial has ended. Reactivate Greptile to resume code reviews.
PR Summary by QodoRebuild shared global-store slots when no build output is cached
AI Description
Diagram
High-Level Assessment
Files changed (3)
|
Code Review by Qodo🐞 Bugs (0) 📘 Rule violations (0) 📎 Requirement gaps (0)
Great, no issues found!Qodo reviewed your code and found no material issues that require reviewTip of the day💡 Did you know, you can route each severity your way: inline, summary, both, or drop
|
PR Code Suggestions ✨Warning
No code suggestions found for the PR. |
Summary
Closes #17526.
With
enableGlobalVirtualStore, pnpm 12 skipped a dependency's build scripts in a project whose global virtual store slot another project had already built. When the build writes only outside its own package (a git hook installer writing intoINIT_CWD), the side-effects cache row is empty, so nothing is restored either, and the second project never gets the effect. pnpm 11 runs the script again there.The skip is
built_by_an_earlier_installinslot_to_build.rs, added by #16286. That PR described it as matching v11, but v11 derivesisBuiltonly from the side-effects cache row (getFlatMapinstore/create-cafs-store).safeToSkipchanges how files are imported into the shared slot, notisBuilt. The only other v11 skip is inimportIntoSlot: a slot that carried.pnpm-needs-build, then lost it while this install waited for the slot lock. v12 keeps that wait inslot_to_buildas before.This PR removes the slot-level skip. A slot whose build left output in the package still skips through the side-effects
is_builtgate, as in v11.Notes for reviewers
sideEffectsCache: false, or for a build that changes nothing inside its package, every install into a freshnode_modulesnow runs the build again. pnpm 11 does the same. v13: cache builds that change no package files tasks#242 plans to make skipping these the intended behavior in the next major version, withsideEffectsCache.excludeas the opt-out.gvs_reinstall_does_not_rebuild_a_built_slotpinned the skip withsideEffectsCache: false. It is replaced bygvs_reinstall_builds_a_built_slot_with_nothing_cached, which uses the issue's shape: a git dependency whose postinstall writes into the project, side-effects cache on, two installs into a freshnode_modules.pnpm11/is unchanged.Validation
main(the second install did not run the postinstall) and passes with the fix.hook-installedfor both projects.pnpm test:rust -p pnpm-cli -p pnpm-deps-restorerfiltered topnpm-deps-restorer,global_virtual_store,workspace_installandgvs: 813 passed.pnpm/scripts/pre-push-rust.shpasses.Squash Commit Body
Checklist
already linked to it solves it.
are implemented in every affected version.
pnpm changeset) if this PR changes any publishedpackage. Keep it short and written for pnpm users — it becomes a release note.
🤖 Generated with Claude Code
Written by an agent (Claude Code, claude-opus-5-5).
Need help on this PR? Tag
@codesmith-botwith what you need.Summary by CodeRabbit