Repository navigation
Conversation
Stream lazy child resolution through caches and share ancestry and missing-peer state across repeated peer contexts. Recursively hoist nested conflict roots so the linker does not create deeply repeated paths. Closes #13540.
|
Note Reviews pausedIt looks like this branch is under active development. To avoid overwhelming you with review comments due to an influx of new commits, CodeRabbit has automatically paused this review. You can configure this behavior by changing the Use the following commands to manage reviews:
Use the checkboxes below for quick actions:
📝 WalkthroughWalkthroughThe resolver shares ancestry, peer, missing-peer, and dependency-path state. Peer discovery defers child realization and reuses cached state. Nested hoisting processes each result node independently. A peer-heavy benchmark measures lockfile parity and performance. ChangesPeer resolution and hoisting
Estimated code review effort: 5 (Critical) | ~120 minutes Sequence Diagram(s)sequenceDiagram
participant DependencyResolver
participant ResolvedTree
participant PeerDiscovery
participant RealHoist
participant Benchmark
DependencyResolver->>ResolvedTree: Share ancestor chains for lazy nodes
DependencyResolver->>PeerDiscovery: Resolve providers with shared caches
PeerDiscovery->>ResolvedTree: Preview or defer child materialization
PeerDiscovery-->>DependencyResolver: Return peer and missing summaries
DependencyResolver->>RealHoist: Pass the resolved result graph
RealHoist->>RealHoist: Hoist each nested result node
Benchmark->>PeerDiscovery: Run peer-heavy resolution scenario
Benchmark->>Benchmark: Compare lockfiles and performance
Assessment against linked issues
Possibly related issues
Possibly related PRs
Suggested labels: Suggested reviewers: ✨ Finishing Touches📝 Generate docstrings
🧪 Generate unit tests (beta)
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 |
PR Summary by Qodoperf(pacquet): bound memory in peer-heavy hoisted installs
AI Description
Diagram
High-Level Assessment
Files changed (12)
|
Confidence Score: 5/5The PR appears safe to merge. No blocking failure remains. Reviews (6): Last reviewed commit: "docs(pacquet): explain benchmark prewarm" | Re-trigger Greptile |
Micro-Benchmark ResultsLinux |
There was a problem hiding this comment.
Pull request overview
This PR reduces peak memory and pathological node_modules path expansion in pacquet (the Rust engine) for peer-heavy, hoisted installs by avoiding unnecessary occurrence materialization, increasing structural sharing across repeated peer contexts, and recursively hoisting nested conflict roots so the linker receives a bounded graph.
Changes:
- Introduces shared ancestor-chain representations (
AncestorIds,SharedChain) and updates lazy-children handling to avoid copying ancestor vectors and to enable cache checks before materializing lazy children. - Makes peer-resolution caches and “missing peer” summaries structurally shareable (using
Arc<...>and a persistent summary structure) to reduce repeated allocations across revisits. - Recursively hoists nested package-conflict roots in the hoister to prevent deep repeated
node_modulespaths, plus adds/updates tests and a changeset.
Reviewed changes
Copilot reviewed 12 out of 12 changed files in this pull request and generated 2 comments.
Show a summary per file
| File | Description |
|---|---|
| pnpm/crates/resolving-deps-resolver/src/resolved_tree.rs | Adds AncestorIds, updates TreeChildren::Lazy to use it, and wires module tests. |
| pnpm/crates/resolving-deps-resolver/src/resolved_tree/tests.rs | Adds a focused test for ancestor-cycle detection across base + appended chains. |
| pnpm/crates/resolving-deps-resolver/src/resolve_peers.rs | Refactors peer discovery/walker to use shared chains, earlier cache checks, structurally shared maps/summaries, and reduced retained per-occurrence state. |
| pnpm/crates/resolving-deps-resolver/src/resolve_peers/tests.rs | Updates tests for new cache/map shapes (Arc<HashMap>, pure_pkgs: HashMap, etc.). |
| pnpm/crates/resolving-deps-resolver/src/resolve_dependency_tree.rs | Switches lazy parent-id threading to the new ancestor representation and avoids per-seed empty vec allocations. |
| pnpm/crates/resolving-deps-resolver/src/resolve_dependency_tree/tests.rs | Updates tests for TreeChildren::Lazy { parent_ids: AncestorIds }. |
| pnpm/crates/package-manager/src/dependencies_graph_to_lockfile/tests.rs | Updates tests to match AncestorIds in lazy nodes. |
| pnpm/crates/deps-path/src/dep_path.rs | Changes DepPath storage to Arc<str> to reduce depPath string duplication. |
| pnpm/crates/real-hoist/src/lib.rs | Adds recursive hoisting for nested conflict roots (hoist_nested_roots) and updates docs. |
| pnpm/crates/real-hoist/src/tests.rs | Strengthens the conflict test to cover hoisting descendants of nested conflict roots. |
| pnpm/crates/resolving-deps-resolver/src/lib.rs | Re-exports AncestorIds from the crate API surface. |
| .changeset/quick-plums-hoist.md | Adds a pacquet patch changeset describing the memory/path-expansion reduction. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Code Review by Qodo
Context used✅ Compliance rules (platform):
24 rules 1.
|
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## main pnpm/pnpm#13545 +/- ##
========================================
Coverage 87.92% 87.92%
========================================
Files 550 550
Lines 96449 97060 +611
========================================
+ Hits 84800 85343 +543
- Misses 11649 11717 +68 ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
There was a problem hiding this comment.
Actionable comments posted: 2
🧹 Nitpick comments (2)
pnpm/crates/resolving-deps-resolver/src/resolve_peers.rs (2)
130-143: 📐 Maintainability & Code Quality | 🔵 Trivial | ⚡ Quick winAdd a rustdoc contract tying
package_name_matchestopkg_name_version.
package_name_matchesreimplements, field by field, the name thatpkg_name_versionbuilds withname_ver.name.to_string(). The allocation-free comparison is the point, so keep it. Butis_peer_relevantanswers the same "does this package supply this name" question throughpkg_name_version, so the repo now holds two spellings of one rule. If they drift, a child stops being recognized as a peer provider and depPaths change silently.Document the invariant on
package_name_matches: it must stay equivalent topkg_name_version(result).0 == expected.♻️ Proposed rustdoc
+/// Whether `result`'s real package name equals `expected`, without +/// allocating the joined `@scope/bare` string. +/// +/// Must stay equivalent to `pkg_name_version(result).0 == expected`. fn package_name_matches(result: &ResolveResult, expected: &str) -> bool {🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the rest with a brief reason, keep changes minimal, and validate. In `@pnpm/crates/resolving-deps-resolver/src/resolve_peers.rs` around lines 130 - 143, Add rustdoc immediately above package_name_matches documenting the invariant that its allocation-free comparison must remain equivalent to pkg_name_version(result).0 == expected. Preserve the existing field-by-field implementation and behavior; only establish this contract so future changes keep it synchronized with pkg_name_version and is_peer_relevant.
944-955: 📐 Maintainability & Code Quality | 🔵 Trivial | ⚡ Quick winRecord why
merge_realize_undomay discard the secondprev_parent_ids.
merge_realize_undokeepsfirst.prev_parent_idsand drops the second one. That is correct only because both undos come from the samenode_idand both captured the same pre-realization chain:preview_peer_provider_childrenreadsparent_idswithout flipping the node'schildren, so the laterrealize_children_withobserves the identicalLazychain. If a future change made the preview flipchildrentoRealized, the second undo would carry a different chain andundo_realizewould restore the wrong ancestry — silently changing cycle breaks on later occurrences.State the invariant so the coupling is not rediscovered by debugging.
♻️ Proposed comment
+/// Both undos must describe the same node. `preview_peer_provider_children` +/// leaves `children` on its `Lazy` arm, so both captured the same +/// pre-realization chain and keeping `first.prev_parent_ids` is exact. fn merge_realize_undo(🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the rest with a brief reason, keep changes minimal, and validate. In `@pnpm/crates/resolving-deps-resolver/src/resolve_peers.rs` around lines 944 - 955, Add a concise comment above merge_realize_undo documenting why first.prev_parent_ids is retained: both undos must refer to the same node_id and identical pre-realization parent chain because preview_peer_provider_children reads parent_ids without changing children from Lazy to Realized. Note that changing this preview behavior would make discarding second.prev_parent_ids unsafe and could restore incorrect ancestry.
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Inline comments:
In `@pnpm/crates/real-hoist/src/lib.rs`:
- Around line 611-624: The hoist_nested_roots function reconstructs locators
from an arbitrary first reference, which can select incorrect hoisting limits
when a HoisterResult has multiple references. Preserve the single
HoisterResult-to-locator mapping during conversion, as done for the root, and
use that retained locator when calling hoist_into_root for each nested node;
keep traversal and visited-node behavior unchanged.
In `@pnpm/crates/resolving-deps-resolver/src/resolve_peers.rs`:
- Around line 3364-3368: Align the deferred-child cleanup guard with
undo_realize: in the block removing entries from dependencies_tree,
node_dep_paths, and visited_this_call, require that the node is neither retained
in retained_peer_node_ids nor referenced by the returned output. Preserve
materialized nodes needed by retained peer resolutions so cached PeersCacheItem
entries continue to match and build_peer_id cannot access a removed node.
---
Nitpick comments:
In `@pnpm/crates/resolving-deps-resolver/src/resolve_peers.rs`:
- Around line 130-143: Add rustdoc immediately above package_name_matches
documenting the invariant that its allocation-free comparison must remain
equivalent to pkg_name_version(result).0 == expected. Preserve the existing
field-by-field implementation and behavior; only establish this contract so
future changes keep it synchronized with pkg_name_version and is_peer_relevant.
- Around line 944-955: Add a concise comment above merge_realize_undo
documenting why first.prev_parent_ids is retained: both undos must refer to the
same node_id and identical pre-realization parent chain because
preview_peer_provider_children reads parent_ids without changing children from
Lazy to Realized. Note that changing this preview behavior would make discarding
second.prev_parent_ids unsafe and could restore incorrect ancestry.
🪄 Autofix (Beta)
Fix all unresolved CodeRabbit comments on this PR:
- Push a commit to this branch (recommended)
- Create a new PR with the fixes
ℹ️ Review info
⚙️ Run configuration
Configuration used: Path: .coderabbit.yaml
Review profile: CHILL
Plan: Pro Plus
Run ID: 6794d431-b52e-4ba1-836a-07f5e172c2c1
📒 Files selected for processing (12)
.changeset/quick-plums-hoist.mdpnpm/crates/deps-path/src/dep_path.rspnpm/crates/package-manager/src/dependencies_graph_to_lockfile/tests.rspnpm/crates/real-hoist/src/lib.rspnpm/crates/real-hoist/src/tests.rspnpm/crates/resolving-deps-resolver/src/lib.rspnpm/crates/resolving-deps-resolver/src/resolve_dependency_tree.rspnpm/crates/resolving-deps-resolver/src/resolve_dependency_tree/tests.rspnpm/crates/resolving-deps-resolver/src/resolve_peers.rspnpm/crates/resolving-deps-resolver/src/resolve_peers/tests.rspnpm/crates/resolving-deps-resolver/src/resolved_tree.rspnpm/crates/resolving-deps-resolver/src/resolved_tree/tests.rs
PR Code Suggestions ✨Latest suggestions up to f53bf65 Warning
Previous suggestionsSuggestions up to commit 33721eb
Suggestions up to commit d73a81c
✅ Suggestions up to commit d780c18
|
||||||||||||||||||||||||||||||||||||||
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. Bencher consumes pacquet@HEAD and pnpr@HEAD. The tables below show mean ± σ; Bencher thresholds on the minimum latency, which is far less perturbed by shared-runner contention (noise only adds time). Scenario: Isolated linker: fresh restore, cold cache + cold store
BENCHMARK_REPORT.json{
"results": [
{
"command": "pacquet@HEAD",
"mean": 2.49797308204,
"stddev": 0.1610426133432856,
"median": 2.42187934294,
"user": 1.47407362,
"system": 1.31740846,
"min": 2.34817272494,
"max": 2.7736298119400002,
"times": [
2.56646092694,
2.44900600394,
2.71382861794,
2.7736298119400002,
2.38177893294,
2.34817272494,
2.36792742894,
2.63380321594,
2.35037047494,
2.39475268194
]
},
{
"command": "pacquet@main",
"mean": 2.53354022344,
"stddev": 0.16514572134926128,
"median": 2.47906724194,
"user": 1.50028692,
"system": 1.26342176,
"min": 2.35555650194,
"max": 2.75566339694,
"times": [
2.75566339694,
2.45685394894,
2.36755891494,
2.36213098094,
2.35555650194,
2.5012805349400002,
2.73302913894,
2.73741639894,
2.63100383594,
2.4349085819400003
]
},
{
"command": "pnpr@HEAD",
"mean": 1.5547938290400003,
"stddev": 0.15261192094496592,
"median": 1.58152510644,
"user": 1.05095802,
"system": 1.13443106,
"min": 1.3470098139400002,
"max": 1.74945453494,
"times": [
1.6707316579400002,
1.74945453494,
1.7486068779400001,
1.58520123094,
1.64702570594,
1.5778489819400001,
1.4459956279400001,
1.3470098139400002,
1.3802044099400002,
1.39585944894
]
},
{
"command": "pnpr@main",
"mean": 1.5071901022399998,
"stddev": 0.12220158161691336,
"median": 1.46760078344,
"user": 1.03810582,
"system": 1.12455006,
"min": 1.3767426789400001,
"max": 1.77326091694,
"times": [
1.53253537694,
1.46339471094,
1.77326091694,
1.44477336394,
1.6206641299400002,
1.57830182394,
1.4718068559400002,
1.3767426789400001,
1.39661666494,
1.4138044999400001
]
}
]
}Scenario: Isolated linker: fresh restore, hot cache + hot store
BENCHMARK_REPORT.json{
"results": [
{
"command": "pacquet@HEAD",
"mean": 0.25837288948000003,
"stddev": 0.00804613091151853,
"median": 0.25815282878,
"user": 0.22586240000000002,
"system": 0.5070596199999999,
"min": 0.24649469978000002,
"max": 0.27040244278000003,
"times": [
0.27040244278000003,
0.25734344478,
0.25547734978000003,
0.26142949078,
0.26252922278,
0.25438753578,
0.24649469978000002,
0.24729305278000002,
0.25896221278000003,
0.26940944278
]
},
{
"command": "pacquet@main",
"mean": 0.25400034308,
"stddev": 0.004403785213583747,
"median": 0.25373651478000003,
"user": 0.19940829999999998,
"system": 0.52918232,
"min": 0.24689393178000002,
"max": 0.26169241578,
"times": [
0.26169241578,
0.24951254378,
0.25211721978,
0.25792738478,
0.25149365478,
0.25535580978,
0.25747677578,
0.24689393178000002,
0.25541719578,
0.25211649878000003
]
},
{
"command": "pnpr@HEAD",
"mean": 0.27507181438000006,
"stddev": 0.004828354192831531,
"median": 0.27391681328,
"user": 0.2091443,
"system": 0.5383649199999999,
"min": 0.26702614278000003,
"max": 0.28177545578,
"times": [
0.27324791378,
0.28122385578000003,
0.27108857578,
0.27789067878,
0.27458571278,
0.27932167378,
0.28177545578,
0.26702614278000003,
0.27148455078,
0.27307358378
]
},
{
"command": "pnpr@main",
"mean": 0.26573784338,
"stddev": 0.0091277377700561,
"median": 0.26351888178,
"user": 0.21974769999999996,
"system": 0.50622422,
"min": 0.25768061978,
"max": 0.28723634178,
"times": [
0.25768061978,
0.28723634178,
0.26525249178,
0.25868316878000003,
0.25963920878,
0.26888752878,
0.27396382078000003,
0.26467464378,
0.25899748978000003,
0.26236311978
]
}
]
}Scenario: Isolated linker: fresh install, cold cache + cold store
BENCHMARK_REPORT.json{
"results": [
{
"command": "pacquet@HEAD",
"mean": 2.5954598966000004,
"stddev": 0.02147653117686855,
"median": 2.5951277924000005,
"user": 1.5074561,
"system": 1.3350898199999999,
"min": 2.5676078179,
"max": 2.6397638729,
"times": [
2.5782804119000002,
2.5676078179,
2.5942569639000004,
2.6397638729,
2.6007123349,
2.5846242999,
2.6159547679,
2.5959986209,
2.5735459309,
2.6038539449
]
},
{
"command": "pacquet@main",
"mean": 2.5886913478,
"stddev": 0.0166033784443507,
"median": 2.5894378934000004,
"user": 1.5190952,
"system": 1.29057982,
"min": 2.5597119739000003,
"max": 2.6100687109000003,
"times": [
2.5965916769,
2.5722071989,
2.5862463919,
2.6093635819000003,
2.6012317469,
2.5895168919000002,
2.5597119739000003,
2.6100687109000003,
2.5893588949,
2.5726164099
]
},
{
"command": "pnpr@HEAD",
"mean": 1.6266554765999999,
"stddev": 0.15122803504351784,
"median": 1.6197279639,
"user": 1.0367355999999999,
"system": 1.13052002,
"min": 1.4521271289000002,
"max": 1.8807857779000001,
"times": [
1.8056765279000002,
1.6109750379,
1.6697796579000002,
1.4521271289000002,
1.4704097239,
1.5224849979000001,
1.6284808899,
1.8807857779000001,
1.4697606299000001,
1.7560743939
]
},
{
"command": "pnpr@main",
"mean": 1.4956459753,
"stddev": 0.059115719712474785,
"median": 1.4967921404000002,
"user": 1.0210243999999997,
"system": 1.1643852199999998,
"min": 1.4221230659000001,
"max": 1.5683764639,
"times": [
1.5683764639,
1.5676538729000002,
1.4741782819,
1.5544516469,
1.4367695029,
1.4240032069000002,
1.5300142279000002,
1.4221230659000001,
1.5194059989000002,
1.4594834849000002
]
}
]
}Scenario: Isolated linker: fresh install, hot cache + hot store
BENCHMARK_REPORT.json{
"results": [
{
"command": "pacquet@HEAD",
"mean": 0.4075799104800001,
"stddev": 0.007032955080486626,
"median": 0.40681585418000005,
"user": 0.5244180999999999,
"system": 0.6989951000000001,
"min": 0.39843628518000007,
"max": 0.42370914618000005,
"times": [
0.40478694718,
0.40249746518000007,
0.40728377018000006,
0.41138656718000005,
0.40634793818000003,
0.40940273018000006,
0.41062150618000004,
0.42370914618000005,
0.39843628518000007,
0.40132674918000005
]
},
{
"command": "pacquet@main",
"mean": 0.4078622229800001,
"stddev": 0.007914988166534385,
"median": 0.40580920168,
"user": 0.5416158999999999,
"system": 0.6742774999999999,
"min": 0.39745608918,
"max": 0.42121229418000006,
"times": [
0.40406814218000003,
0.40308652418000007,
0.39986511618000004,
0.4018315101800001,
0.40755026118000004,
0.42121229418000006,
0.41353798918000007,
0.41336792918000004,
0.41664637418000006,
0.39745608918
]
},
{
"command": "pnpr@HEAD",
"mean": 0.30539722088000004,
"stddev": 0.008763730212910454,
"median": 0.30635683668,
"user": 0.17711149999999998,
"system": 0.5409153,
"min": 0.28981247218000006,
"max": 0.32194957618000003,
"times": [
0.30934884918000005,
0.29643128818000003,
0.28981247218000006,
0.30753405018,
0.30631462418000005,
0.30471619918000004,
0.29976405318000005,
0.32194957618000003,
0.30639904918000005,
0.31170204718000005
]
},
{
"command": "pnpr@main",
"mean": 0.30661964108000006,
"stddev": 0.004966703812680008,
"median": 0.3073752981800001,
"user": 0.20105089999999998,
"system": 0.5503785000000001,
"min": 0.29821038718000004,
"max": 0.31401647518000003,
"times": [
0.30388413318,
0.31058143718000003,
0.30691869818000006,
0.30783189818000006,
0.29821038718000004,
0.30786014118000005,
0.30003423318000005,
0.31162239718000007,
0.30523661018000003,
0.31401647518000003
]
}
]
}Scenario: Isolated linker: fresh install, cold cache + hot store
BENCHMARK_REPORT.json{
"results": [
{
"command": "pacquet@HEAD",
"mean": 1.7383097876800004,
"stddev": 0.010719776129689409,
"median": 1.7394136690800002,
"user": 0.74676756,
"system": 0.7598467,
"min": 1.7139220945800002,
"max": 1.75128676658,
"times": [
1.75128676658,
1.7346028345800002,
1.7139220945800002,
1.74690334058,
1.7412061995800001,
1.7433114355800001,
1.73724103258,
1.74711471958,
1.72988831458,
1.73762113858
]
},
{
"command": "pacquet@main",
"mean": 1.7336853942800001,
"stddev": 0.01048808514461774,
"median": 1.7353750835800001,
"user": 0.7551463599999999,
"system": 0.7373287,
"min": 1.71726193458,
"max": 1.74757232958,
"times": [
1.73062416058,
1.7425221585800001,
1.7428932785800002,
1.73659742058,
1.74078392558,
1.7181415125800001,
1.74757232958,
1.7341527465800002,
1.72630447558,
1.71726193458
]
},
{
"command": "pnpr@HEAD",
"mean": 0.3022104741800001,
"stddev": 0.0062741518323559875,
"median": 0.30226251958000006,
"user": 0.17454975999999997,
"system": 0.5393340999999999,
"min": 0.29252007658,
"max": 0.31257867458000005,
"times": [
0.30530171858000005,
0.30955594158000005,
0.29823434858000003,
0.30390544958000004,
0.29795469258,
0.29594300358000003,
0.29252007658,
0.30061958958,
0.30549124658000004,
0.31257867458000005
]
},
{
"command": "pnpr@main",
"mean": 0.30438989788000004,
"stddev": 0.006776898850537666,
"median": 0.30435038758000005,
"user": 0.18076356,
"system": 0.5436905999999999,
"min": 0.29518774058,
"max": 0.31919641858000003,
"times": [
0.29701298858,
0.31919641858000003,
0.30250436958000004,
0.30334669758000005,
0.29518774058,
0.29969198458,
0.30645173558000005,
0.30876019258000004,
0.30535407758000005,
0.30639277358000006
]
}
]
}Scenario: Isolated linker: fresh resolve, hot cache, offline
BENCHMARK_REPORT.json{
"results": [
{
"command": "pacquet@HEAD",
"mean": 0.18727382482285715,
"stddev": 0.006228522724118345,
"median": 0.18509441768,
"user": 0.17263195714285712,
"system": 0.06550072,
"min": 0.18165950368000003,
"max": 0.20662137668000002,
"times": [
0.20662137668000002,
0.19087336668000002,
0.19086717468000003,
0.18534061668000001,
0.18165950368000003,
0.18649411968000001,
0.18744239468,
0.18383602368000002,
0.18484821868,
0.18867128968000002,
0.18369510768000002,
0.18414381268000002,
0.18361018768,
0.18373035468
]
},
{
"command": "pacquet@main",
"mean": 0.19240949127999998,
"stddev": 0.002994900517616017,
"median": 0.19143631768000002,
"user": 0.18144186666666665,
"system": 0.06337578666666667,
"min": 0.18790276268000003,
"max": 0.19914463468000002,
"times": [
0.19353838668000004,
0.19109309068000002,
0.19118369068000002,
0.18884316268,
0.19914463468000002,
0.19743524568,
0.19351924968000003,
0.19020917568,
0.19126812168000001,
0.19143631768000002,
0.19018162368000002,
0.19378655368000003,
0.18790276268000003,
0.19386734468000003,
0.19273300868
]
},
{
"command": "pnpr@HEAD",
"mean": 0.08715679852848486,
"stddev": 0.0013684034639938787,
"median": 0.08710342068,
"user": 0.020902266666666666,
"system": 0.008675009696969698,
"min": 0.08417153868,
"max": 0.09032363568,
"times": [
0.08694974168,
0.08643578368,
0.08568916768,
0.08417153868,
0.08710342068,
0.08752289068,
0.08804426268,
0.08596660968,
0.08808453968,
0.08763039368,
0.09032363568,
0.08588332368,
0.08556572568,
0.09022174368000001,
0.08576616368000001,
0.08704976068,
0.08912881568,
0.08578310368,
0.08711308868,
0.08782340668000001,
0.08580146868,
0.08913385568,
0.08593911768,
0.08640257168,
0.08778692868,
0.08834523068,
0.08710857068,
0.08859442968,
0.08732209268,
0.08696446868,
0.08768831168,
0.08642039368,
0.08640979468
]
},
{
"command": "pnpr@main",
"mean": 0.08717885019515152,
"stddev": 0.0015095147627965594,
"median": 0.08727829068000001,
"user": 0.020936993939393935,
"system": 0.00853885818181818,
"min": 0.08491756368,
"max": 0.09017860268,
"times": [
0.08657552668,
0.08630159168,
0.08990450668,
0.08521611668,
0.08901792768,
0.08610374868000001,
0.08727829068000001,
0.08809520868000001,
0.08821050568000001,
0.08757977868,
0.08672376568000001,
0.08794942468,
0.08514021468,
0.08939519668,
0.08595344568,
0.08799562268,
0.08562394468000001,
0.08515393968,
0.08571254068,
0.08711271868,
0.08795345168,
0.08728020468,
0.08785243168,
0.08569140268,
0.08820455468,
0.08992823168,
0.08540250768,
0.08678582268,
0.09017860268,
0.08491756368,
0.08853524668,
0.08576623268,
0.08736178768
]
}
]
}Scenario: Isolated linker: peer-heavy resolve, hot cache, offline
BENCHMARK_REPORT.json{
"results": [
{
"command": "pacquet@HEAD",
"mean": 1.4666109565333334,
"stddev": 0.3463009146915491,
"median": 1.6092721262,
"user": 1.36860448,
"system": 0.19028440666666666,
"min": 1.0717681362,
"max": 1.7187926072000002,
"times": [
1.6092721262,
1.7187926072000002,
1.0717681362
]
},
{
"command": "pacquet@main",
"mean": 7.031467437533333,
"stddev": 1.0696410720490335,
"median": 6.4319455672,
"user": 6.412845146666665,
"system": 0.70177374,
"min": 6.3960480861999995,
"max": 8.2664086592,
"times": [
6.3960480861999995,
6.4319455672,
8.2664086592
]
},
{
"command": "pnpm@HEAD",
"mean": 34.66341373086666,
"stddev": 1.071723552537345,
"median": 35.268932789199994,
"user": 79.76397514666667,
"system": 3.741499073333333,
"min": 33.425987750199994,
"max": 35.295320653199994,
"times": [
35.268932789199994,
35.295320653199994,
33.425987750199994
]
}
]
}Scenario: Isolated linker: fresh restore, cold cache + cold store + cold pnpr
BENCHMARK_REPORT.json{
"results": [
{
"command": "pacquet@HEAD",
"mean": 4.49695842884,
"stddev": 0.11324336825886364,
"median": 4.44062404754,
"user": 1.654092,
"system": 1.34690686,
"min": 4.42160428504,
"max": 4.77482812604,
"times": [
4.43196884104,
4.47529832104,
4.43467662004,
4.42160428504,
4.43879326504,
4.60731832104,
4.42600422204,
4.44245483004,
4.51663745704,
4.77482812604
]
},
{
"command": "pacquet@main",
"mean": 4.54672863974,
"stddev": 0.13477995978305488,
"median": 4.49769736304,
"user": 1.6625775999999999,
"system": 1.34744426,
"min": 4.4247701390400005,
"max": 4.85518134304,
"times": [
4.85518134304,
4.44490799004,
4.46506975504,
4.530324971040001,
4.5990488990400005,
4.450582514040001,
4.609565373040001,
4.64447452804,
4.4247701390400005,
4.443360885040001
]
},
{
"command": "pnpr@HEAD",
"mean": 3.5534989887400004,
"stddev": 0.1126892292097113,
"median": 3.5179483725400003,
"user": 1.1461777999999998,
"system": 1.2250462599999998,
"min": 3.4562603210400002,
"max": 3.8399564920400002,
"times": [
3.8399564920400002,
3.62412159004,
3.5110690480400004,
3.52482769704,
3.47896407304,
3.57861013104,
3.5477125000400003,
3.4907326260400002,
3.4562603210400002,
3.48273540904
]
},
{
"command": "pnpr@main",
"mean": 3.5217534795400005,
"stddev": 0.057205769505048666,
"median": 3.5291094105400003,
"user": 1.1466796999999997,
"system": 1.23324506,
"min": 3.44388426004,
"max": 3.6377972630400004,
"times": [
3.5216819090400002,
3.46199509404,
3.4647159280400004,
3.5365369120400003,
3.6377972630400004,
3.55684825904,
3.5503461350400003,
3.50148541704,
3.44388426004,
3.54224361804
]
}
]
} |
|
| Project | pnpm's project |
| Branch | pr/13545 |
| Testbed | pnpr |
⚠️ WARNING: No Threshold found!Without a Threshold, no Alerts will ever be generated.
Click here to create a new Threshold
For more information, see the Threshold documentation.
To only post results if a Threshold exists, set the--ci-only-thresholdsflag.
Click to view all benchmark results
| Benchmark | Latency | milliseconds (ms) |
|---|---|---|
| isolated-linker.fresh-install.cold-cache.cold-store | 📈 view plot | 1,452.13 ms |
| isolated-linker.fresh-install.cold-cache.hot-store | 📈 view plot | 292.52 ms |
| isolated-linker.fresh-install.hot-cache.hot-store | 📈 view plot | 289.81 ms |
| isolated-linker.fresh-resolve.hot-cache.offline | 📈 view plot | 84.17 ms |
| isolated-linker.fresh-restore.cold-cache.cold-store | 📈 view plot | 1,347.01 ms |
| isolated-linker.fresh-restore.cold-cache.cold-store.cold-pnpr | 📈 view plot | 3,456.26 ms |
| isolated-linker.fresh-restore.hot-cache.hot-store | 📈 view plot | 267.03 ms |
Use the original locator for every recursive hoist root. Keep deferred materializations that peer outputs still reference.
There was a problem hiding this comment.
Caution
Some comments are outside the diff and can’t be posted inline due to platform limitations.
⚠️ Outside diff range comments (1)
pnpm/crates/resolving-deps-resolver/src/resolve_peers.rs (1)
3260-3267: 📐 Maintainability & Code Quality | 🟠 Major | ⚡ Quick winAdd an end-to-end retention regression test.
The current
materialized_nodes_referenced_by_peer_outputs_are_retainedtest invokes onlyshould_retain_materialized_node.It still passes if
undo_realizeor deferred-child cleanup stops calling that helper.Add a discovery-walk fixture that materializes a deferred provider and verifies that a peer-referenced node remains in
dependencies_tree, while an unreferenced transient node is removed.As per path instructions, require regression tests that fail without the fix, especially for cache-hit/deferred materialization and retained peer-provider nodes.
Also applies to: 3362-3368
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the rest with a brief reason, keep changes minimal, and validate. In `@pnpm/crates/resolving-deps-resolver/src/resolve_peers.rs` around lines 3260 - 3267, Add an end-to-end discovery-walk regression test covering deferred materialization: use a fixture that materializes a deferred provider, then verify the peer-referenced node remains in dependencies_tree while an unreferenced transient node is removed. Exercise the undo_realize/deferred-child cleanup path rather than calling should_retain_materialized_node directly, so the test fails if that integration call is removed.Source: Path instructions
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Outside diff comments:
In `@pnpm/crates/resolving-deps-resolver/src/resolve_peers.rs`:
- Around line 3260-3267: Add an end-to-end discovery-walk regression test
covering deferred materialization: use a fixture that materializes a deferred
provider, then verify the peer-referenced node remains in dependencies_tree
while an unreferenced transient node is removed. Exercise the
undo_realize/deferred-child cleanup path rather than calling
should_retain_materialized_node directly, so the test fails if that integration
call is removed.
ℹ️ Review info
⚙️ Run configuration
Configuration used: Path: .coderabbit.yaml
Review profile: CHILL
Plan: Pro Plus
Run ID: 2b756bdc-475a-4a01-b698-1a4195e00103
📒 Files selected for processing (4)
pnpm/crates/real-hoist/src/lib.rspnpm/crates/real-hoist/src/tests.rspnpm/crates/resolving-deps-resolver/src/resolve_peers.rspnpm/crates/resolving-deps-resolver/src/resolve_peers/tests.rs
🚧 Files skipped from review as they are similar to previous changes (2)
- pnpm/crates/real-hoist/src/lib.rs
- pnpm/crates/resolving-deps-resolver/src/resolve_peers/tests.rs
|
Review follow-up:
Validation passed: focused crate tests, full workspace readiness checks, clippy with warnings denied, Rust documentation, custom dylints, TypeScript compilation and linting, spelling, and formatting. Written by an agent (Codex, GPT-5). |
|
Code review by qodo was updated up to the latest commit 6ebf80d |
PR Code Suggestions ✨Warning
No code suggestions found for the PR. |
Summary
Closes #13540.
Large peer-heavy installs through the Rust engine expanded a few thousand packages into millions
of temporary dependency-tree occurrences. Cache hits happened only after their lazy children had
been materialized, and discovery retained occurrence-keyed state that was not needed by the final
graph. Hoisted linking then expanded nested conflict roots into very deep
node_modulespaths.This change:
children on true cache misses, and retains only nodes needed as peer providers;
child for each cached peer lookup;
dependency-path strings across repeated contexts;
of hundreds of thousands of deeply nested paths; and
comparing Rust HEAD with main and TypeScript pnpm and requiring Rust to remain at least 10x faster.
The linked draft #13538 implements two bounded allocation reductions but explicitly leaves
the occurrence-keyed discovery state and hoisted-linker expansion unresolved. This PR includes those
reductions and addresses both remaining costs.
This is Rust-only. The TypeScript engine remains the behavioral reference, the emitted lockfile
contract is unchanged, and there is no TypeScript-side behavior to port.
The issue reproduction was run with
@bitdevand@teambitscoped tohttps://node-registry.bit.cloud/. To isolate resolver CPU from registry latency, the comparisonused fresh output directories with no lockfile, offline
lockfileOnlyinstalls, and the sameprewarmed metadata cache generated from that registry:
The final Rust implementation is 2.1–3.0x faster than TypeScript on this controlled reproduction.
The Rust lockfile before and after the optimization is byte-identical: 2,781,634 bytes with SHA-256
4a02feb99f5d1af834803a9bf3ba57a445f72488af1cb89a068355d63e019d45.The permanent integrated case is self-contained so registry metadata cannot drift. It generates a
five-layer, 80-package-wide DAG: 400 peer-dependent packages, 25,600 shared dependency edges, and
more than 3.3 billion possible root-to-leaf occurrence paths. An online lockfile-only pass warms
metadata, then the timed pass removes the lockfile and resolves offline without linking. Three runs
produced:
The earlier 24% example compared HEAD with intermediate commit
6ebf80d432, which already containedmost of the fix. Comparing with the actual PR base exposes the intended 3.60x reduction. The
benchmark also performs an untimed correctness pass and fails if target lockfiles differ. All three
lockfiles are byte-identical: 2,526,383 bytes with SHA-256
241575b87b2202d92c05fd313191afd0531162abe188a939c49e83deb0bb7b8c.Resolver benchmarks also improved:
The corrected nested hoister graph has 4,755 occurrences at maximum depth 5; before recursively
hoisting conflict roots, the same graph expanded to roughly 222,000 deeply nested paths.
Validation:
pre-index and post-index Rust lockfiles are byte-identical.
17.29x faster than TypeScript; all target lockfiles are byte-identical.
just ready: 7,529 tests passed, 4 skipped; formatting, checks, and clippy passed.just dylint: passed.passed.
pnpm change status: passed.Squash Commit Body
Checklist
already linked to it solves it.
pnpm/port, or the description notes what still needs porting.pnpm changeset) if this PR changes any publishedpackage. Keep it short and written for pnpm users — it becomes a release note.
Written by an agent (Codex, GPT-5).
Summary by CodeRabbit
Performance
Bug Fixes