Repository navigation
Conversation
…tial phases Walker::resolve_node was 549 lines — by a wide margin the largest function in the crate (next is resolve_node_seed at 321, the median is 13). Nesting was never the problem: real block depth peaks at 5, in the two-pass child loop that is legitimately nested. Length was, because eleven sequential phases shared one large local context. Lift the three phases that have clean seams into named helpers: - The graph-entry / NodeRecord capture moves to finalize.rs as Walker::record_walked_node, next to the post-walk passes that consume those records, taking a borrowed WalkedNode context. - Building the ParentRefs map descendants see — locked-peer scoping, provider children, locked pins — becomes Walker::build_child_parent_refs, returning the shared map, the node's own contribution, and whether anything changed. - The node's own peer resolution, its fold with the children's, and the depPath it renders to become Walker::resolve_node_peers. The early-return short-circuits (context-free depPath, cycle re-entry, fast cache hit, peersCache hit) stay inline: as Option<NodeOutput>-returning helpers they would make the control flow harder to follow, not easier. resolve_node is now 378 lines of linear short-circuits plus the child walk. No allocation, cloning, or traversal change. The extracted phases take borrowed context structs, following the CacheHitContext / DeferredChildContext precedent, so no borrow conflict is resolved with a clone. The one behavioral identity worth naming: resolve_node_peers folds the node's own resolved peers into auto_install_resolved_peers after its loop instead of during it — the two maps agree because resolve_one_peer only ever inserts under the peer name it was called for. Also fold in the adjacent micro-cleanup the issue called out: Walker::deferred_child_resolution did two pure_pkgs hash lookups where one if-let chain does. Closes #13553.
📝 WalkthroughWalkthroughThe PR splits peer-node resolution into parent-reference, peer-resolution, and walked-node recording phases. It adds internal state structures for phase boundaries and simplifies the pure-package cache lookup. ChangesPeer resolution refactor
Estimated code review effort: 3 (Moderate) | ~25 minutes 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 QodoSplit Walker::resolve_node into explicit phases (parent refs, peers, graph capture)
AI Description
Diagram
High-Level Assessment
Files changed (3)
|
Confidence Score: 5/5The PR appears safe to merge, with the extracted phases preserving the original peer-resolution and graph-recording behavior. The moved logic receives the same values, performs mutations in the same order, and produces equivalent parent-reference maps, peer maps, depPaths, cache state, and graph records; no actionable regression was identified. Reviews (1): Last reviewed commit: "refactor(resolving-deps-resolver): split..." | Re-trigger Greptile |
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 reviewTo customize comments, go to the Qodo configuration screen, or learn more in the docs. |
PR Code Suggestions ✨Warning
No code suggestions found for the PR. |
There was a problem hiding this comment.
🧹 Nitpick comments (1)
pnpm/crates/resolving-deps-resolver/src/resolve_peers/finalize.rs (1)
119-165: 🚀 Performance & Scalability | 🔵 Trivial | 💤 Low valueConsider computing
previously_resolved_childrenonce.Lines 121 and 161 call
previously_resolved_childrenwith the same three arguments. The method rebuilds aBTreeMapand clones every alias andNodeIdon each call. The extraction now places both calls in one function, so a single binding removes one full rebuild.record_edgesthen needs one map clone instead, which is cheaper than the repeated traversal. The resolver is a hot path, so this is worth doing while the code is being moved.♻️ Proposed consolidation
let mut graph_children = BTreeMap::new(); - for (alias, child_node_id) in - self.previously_resolved_children(parent_node_ids, parent_pkg_ids_chain, &pkg.id) - { + let previously_resolved = + self.previously_resolved_children(parent_node_ids, parent_pkg_ids_chain, &pkg.id); + for (alias, child_node_id) in previously_resolved.clone() { self.add_graph_child_or_pending(&mut graph_children, dep_path, alias, child_node_id); }- let mut record_edges = - self.previously_resolved_children(parent_node_ids, parent_pkg_ids_chain, &pkg.id); + let mut record_edges = previously_resolved; record_edges.extend(children.clone());🤖 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/finalize.rs` around lines 119 - 165, Compute previously_resolved_children once before the graph_children construction and store the resulting map in a local binding. Reuse that binding when populating graph_children, then clone the map when initializing record_edges before extending it with children and own_resolved_peers; preserve the existing edge contents and ordering.
🤖 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.
Nitpick comments:
In `@pnpm/crates/resolving-deps-resolver/src/resolve_peers/finalize.rs`:
- Around line 119-165: Compute previously_resolved_children once before the
graph_children construction and store the resulting map in a local binding.
Reuse that binding when populating graph_children, then clone the map when
initializing record_edges before extending it with children and
own_resolved_peers; preserve the existing edge contents and ordering.
ℹ️ Review info
⚙️ Run configuration
Configuration used: Path: .coderabbit.yaml
Review profile: CHILL
Plan: Pro Plus
Run ID: 194ab2cf-c01f-4dc2-846e-cf136ebdc1a2
📒 Files selected for processing (3)
pnpm/crates/resolving-deps-resolver/src/resolve_peers/cache.rspnpm/crates/resolving-deps-resolver/src/resolve_peers/finalize.rspnpm/crates/resolving-deps-resolver/src/resolve_peers/walker.rs
There was a problem hiding this comment.
Pull request overview
Refactors the Rust resolving-deps-resolver peer-resolution walker by extracting large, sequential chunks of Walker::resolve_node into focused helper functions, reducing function length while keeping the walk’s control flow and behavior intact.
Changes:
- Extracts descendant
ParentRefsconstruction intoWalker::build_child_parent_refsand node-local peer resolution/depPath rendering intoWalker::resolve_node_peers. - Moves graph-entry /
NodeRecordcapture intoWalker::record_walked_node(infinalize.rs) via aWalkedNodecontext struct. - Simplifies
deferred_child_resolutionto avoid a redundantpure_pkgslookup.
Reviewed changes
Copilot reviewed 3 out of 3 changed files in this pull request and generated no comments.
| File | Description |
|---|---|
| pnpm/crates/resolving-deps-resolver/src/resolve_peers/walker.rs | Splits resolve_node into named phases and routes graph/node-record capture through record_walked_node. |
| pnpm/crates/resolving-deps-resolver/src/resolve_peers/finalize.rs | Introduces WalkedNode and implements Walker::record_walked_node for graph entry + NodeRecord capture. |
| pnpm/crates/resolving-deps-resolver/src/resolve_peers/cache.rs | Uses a let-chain to reuse the pure_pkgs.get() result and avoid double hashing. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Micro-Benchmark ResultsLinux |
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## main #13564 +/- ##
=======================================
Coverage 87.94% 87.95%
=======================================
Files 556 556
Lines 97218 97290 +72
=======================================
+ Hits 85502 85574 +72
Misses 11716 11716 ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
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.5366197360599996,
"stddev": 0.16396173579577786,
"median": 2.5614080367599996,
"user": 1.6620065,
"system": 1.4438008999999998,
"min": 2.36291397726,
"max": 2.79345854326,
"times": [
2.64904344626,
2.58708531226,
2.74626997826,
2.5720632752599997,
2.55075279826,
2.36291397726,
2.37725212426,
2.36295369226,
2.36440421326,
2.79345854326
]
},
{
"command": "pacquet@main",
"mean": 2.54123696046,
"stddev": 0.13570920999032632,
"median": 2.55552455476,
"user": 1.5166585,
"system": 1.3346324999999997,
"min": 2.3584795972599997,
"max": 2.68498503326,
"times": [
2.68498503326,
2.46970722426,
2.45135933526,
2.67089170526,
2.4430647572599997,
2.65607660926,
2.36366960926,
2.67279384826,
2.64134188526,
2.3584795972599997
]
},
{
"command": "pnpr@HEAD",
"mean": 1.6160081144600003,
"stddev": 0.13613010894989158,
"median": 1.6625394417600001,
"user": 1.1143355000000001,
"system": 1.1525181,
"min": 1.3722566212600003,
"max": 1.7829520432600001,
"times": [
1.6997013152600002,
1.4463259512600002,
1.7829520432600001,
1.6420486172600002,
1.7059770222600001,
1.3722566212600003,
1.47150269726,
1.66833768326,
1.71423799326,
1.6567412002600002
]
},
{
"command": "pnpr@main",
"mean": 1.56410710066,
"stddev": 0.13000624178104034,
"median": 1.5617223407600003,
"user": 1.0973198,
"system": 1.1572128999999998,
"min": 1.3724774892600002,
"max": 1.76072519726,
"times": [
1.6571963662600002,
1.4458713572600002,
1.4759312962600002,
1.4350913602600002,
1.68525687426,
1.68507638426,
1.76072519726,
1.3724774892600002,
1.57488434526,
1.5485603362600002
]
}
]
}Scenario: Isolated linker: fresh restore, hot cache + hot store
BENCHMARK_REPORT.json{
"results": [
{
"command": "pacquet@HEAD",
"mean": 0.26786260784000004,
"stddev": 0.006385520380675129,
"median": 0.26679712144,
"user": 0.21325618,
"system": 0.5662082199999999,
"min": 0.25910149994000004,
"max": 0.28240671694,
"times": [
0.25910149994000004,
0.26361814894,
0.26540538194,
0.27132969194,
0.27175150494000005,
0.26486324294,
0.26835758794000003,
0.26360344194,
0.26818886094000005,
0.28240671694
]
},
{
"command": "pacquet@main",
"mean": 0.26515284394000005,
"stddev": 0.00636214590386498,
"median": 0.26442702094000003,
"user": 0.20737537999999994,
"system": 0.5415349199999999,
"min": 0.25559139394,
"max": 0.27841333194,
"times": [
0.27195305394,
0.26158083494,
0.26160776494000004,
0.26718046294000003,
0.26078618894000005,
0.26515541094000006,
0.25559139394,
0.26369863094,
0.26556136594,
0.27841333194
]
},
{
"command": "pnpr@HEAD",
"mean": 0.27389463654,
"stddev": 0.009037955012320983,
"median": 0.27310427144000005,
"user": 0.22649518,
"system": 0.53683192,
"min": 0.26201796894,
"max": 0.29441171894,
"times": [
0.26201796894,
0.27278623194,
0.26578806394000004,
0.26677034094,
0.27295274594,
0.27325579694,
0.28092309494,
0.27396502094,
0.29441171894,
0.27607538194000003
]
},
{
"command": "pnpr@main",
"mean": 0.26690346184,
"stddev": 0.007445017610083496,
"median": 0.26945110644000003,
"user": 0.20734328,
"system": 0.51834232,
"min": 0.25631692194000005,
"max": 0.27654475694,
"times": [
0.27654475694,
0.27234602394,
0.26084648294,
0.26913485094000006,
0.26976736194,
0.27375296994000003,
0.25968161694,
0.25631692194000005,
0.25789680194000003,
0.27274683094
]
}
]
}Scenario: Isolated linker: fresh install, cold cache + cold store
BENCHMARK_REPORT.json{
"results": [
{
"command": "pacquet@HEAD",
"mean": 2.62247140292,
"stddev": 0.02657543292316169,
"median": 2.62461895792,
"user": 1.5266627199999998,
"system": 1.3834747200000002,
"min": 2.57410748642,
"max": 2.6699865564200005,
"times": [
2.61758532942,
2.6375754024200004,
2.62670576642,
2.63678604642,
2.5976160654200005,
2.57410748642,
2.6699865564200005,
2.6225321494200005,
2.63910317342,
2.60271605342
]
},
{
"command": "pacquet@main",
"mean": 2.61226957402,
"stddev": 0.015982554640511723,
"median": 2.6156347459200004,
"user": 1.50075982,
"system": 1.3490272200000002,
"min": 2.57839721242,
"max": 2.6297883634200003,
"times": [
2.6276146344200004,
2.62223135342,
2.6168513194200003,
2.60632452742,
2.57839721242,
2.62284803942,
2.59402469842,
2.6101974194200004,
2.6297883634200003,
2.61441817242
]
},
{
"command": "pnpr@HEAD",
"mean": 1.60013076332,
"stddev": 0.14213346603148272,
"median": 1.59919636542,
"user": 1.05143292,
"system": 1.19387392,
"min": 1.42569728942,
"max": 1.79932221342,
"times": [
1.52922387842,
1.6104699634200002,
1.42569728942,
1.78853746942,
1.4460933464199999,
1.64299419142,
1.58792276742,
1.43562218342,
1.73542433042,
1.79932221342
]
},
{
"command": "pnpr@main",
"mean": 1.6135558142200002,
"stddev": 0.1392131667279271,
"median": 1.5924176399199998,
"user": 1.04575272,
"system": 1.19896052,
"min": 1.45298696842,
"max": 1.8149467424199999,
"times": [
1.52369104642,
1.45298696842,
1.5880303894199999,
1.5968048904199998,
1.72473393542,
1.8149467424199999,
1.45955438542,
1.46936343242,
1.79438075542,
1.71106559642
]
}
]
}Scenario: Isolated linker: fresh install, hot cache + hot store
BENCHMARK_REPORT.json{
"results": [
{
"command": "pacquet@HEAD",
"mean": 0.41668811442000003,
"stddev": 0.007555873723221158,
"median": 0.41793608102,
"user": 0.5480385799999999,
"system": 0.7179017599999999,
"min": 0.39781623252000003,
"max": 0.42389295152,
"times": [
0.41323025552000003,
0.39781623252000003,
0.41827654752000004,
0.42036048052,
0.42389295152,
0.41479364952000003,
0.41567353652,
0.42361052152,
0.42163135452,
0.41759561452
]
},
{
"command": "pacquet@main",
"mean": 0.40385547052000004,
"stddev": 0.006703899990773348,
"median": 0.40389230251999997,
"user": 0.53433478,
"system": 0.70147246,
"min": 0.39192761452,
"max": 0.41419179652000004,
"times": [
0.39929876352,
0.39942397952,
0.40002756552,
0.40442999452,
0.40485779152,
0.41274171552,
0.41419179652000004,
0.40335461052,
0.40830087352,
0.39192761452
]
},
{
"command": "pnpr@HEAD",
"mean": 0.31726750982,
"stddev": 0.0056877516204784815,
"median": 0.31669934002,
"user": 0.22115468,
"system": 0.5484001600000001,
"min": 0.30913441052,
"max": 0.32664018352,
"times": [
0.31883466552,
0.31366999052,
0.31493540352,
0.31995974452000003,
0.32664018352,
0.31843945152,
0.31093953952000003,
0.31495922852,
0.32516248052,
0.30913441052
]
},
{
"command": "pnpr@main",
"mean": 0.31182034382,
"stddev": 0.006051504873275873,
"median": 0.31294105802,
"user": 0.20498988,
"system": 0.5494460600000001,
"min": 0.29899522852,
"max": 0.31975134152,
"times": [
0.31081398252000003,
0.31413039752,
0.31731769852,
0.31975134152,
0.31029596852,
0.31175171852,
0.31542307152,
0.31448012652,
0.30524390452,
0.29899522852
]
}
]
}Scenario: Isolated linker: fresh install, cold cache + hot store
BENCHMARK_REPORT.json{
"results": [
{
"command": "pacquet@HEAD",
"mean": 1.7510197084599999,
"stddev": 0.00782730550117651,
"median": 1.7497980267600002,
"user": 0.7353836799999999,
"system": 0.7902086999999998,
"min": 1.74075771376,
"max": 1.7656986667599999,
"times": [
1.7656986667599999,
1.7493151577600001,
1.74075771376,
1.74238358576,
1.75028089576,
1.74419760176,
1.74866219776,
1.75574234876,
1.7537192017599998,
1.75943971476
]
},
{
"command": "pacquet@main",
"mean": 1.7504426723599997,
"stddev": 0.0085175578174428,
"median": 1.75074953926,
"user": 0.7653818799999998,
"system": 0.7529739999999998,
"min": 1.73610369776,
"max": 1.7641876567600001,
"times": [
1.7568368027599999,
1.75861429076,
1.75412593676,
1.74755292876,
1.7641876567600001,
1.73610369776,
1.74363165476,
1.75394614976,
1.7432093397600001,
1.7462182657599998
]
},
{
"command": "pnpr@HEAD",
"mean": 0.31206779116,
"stddev": 0.0037119920444754055,
"median": 0.31222559626,
"user": 0.21362877999999993,
"system": 0.5489993999999998,
"min": 0.30598756876000005,
"max": 0.31721001276000005,
"times": [
0.31274258976,
0.31176746376000003,
0.31653207676,
0.31263062876000003,
0.31182056376,
0.30598756876000005,
0.31457701576,
0.30637775276,
0.31721001276000005,
0.31103223876
]
},
{
"command": "pnpr@main",
"mean": 0.31516894136,
"stddev": 0.004235183127154506,
"median": 0.31518317126000006,
"user": 0.20181317999999998,
"system": 0.5670211,
"min": 0.30913146976,
"max": 0.32262379876,
"times": [
0.31217885776000004,
0.31896774276,
0.31455757776000004,
0.31042672876000005,
0.30913146976,
0.31871933576,
0.31682752276000004,
0.32262379876,
0.31580876476,
0.31244761476000005
]
}
]
}Scenario: Isolated linker: fresh resolve, hot cache, offline
BENCHMARK_REPORT.json{
"results": [
{
"command": "pacquet@HEAD",
"mean": 0.18912750864666666,
"stddev": 0.005358353193703929,
"median": 0.19076400198000001,
"user": 0.17006995333333333,
"system": 0.07743232666666668,
"min": 0.17888575198,
"max": 0.19634395998,
"times": [
0.18414066898,
0.19479055498,
0.18843869198000002,
0.18173982698,
0.17888575198,
0.19280300198,
0.19454688598,
0.19369918998,
0.18359029098000001,
0.19634395998,
0.19004072998000002,
0.18424403398,
0.19193579898000002,
0.19076400198000001,
0.19094924098000002
]
},
{
"command": "pacquet@main",
"mean": 0.18891894797999997,
"stddev": 0.005559890092865042,
"median": 0.18943461798,
"user": 0.16803488666666672,
"system": 0.07831846,
"min": 0.18021827298,
"max": 0.20121418198000002,
"times": [
0.18952857498,
0.18908770498,
0.19271326298,
0.18943461798,
0.18960676298,
0.18682255998,
0.18467250998,
0.19371181298,
0.19261700198,
0.18771854598,
0.19340995498,
0.20121418198000002,
0.18161090498000002,
0.18141754998,
0.18021827298
]
},
{
"command": "pnpr@HEAD",
"mean": 0.08743521813151515,
"stddev": 0.0015958600241565307,
"median": 0.08713533498,
"user": 0.02231980787878788,
"system": 0.008028967878787879,
"min": 0.08363676198,
"max": 0.09135121098000001,
"times": [
0.08629780398,
0.08745020998,
0.08593443998,
0.08363676198,
0.08816767298,
0.08704947398000001,
0.08707105498,
0.09130191898000001,
0.09061116497999999,
0.08700982798000001,
0.08536675698000001,
0.08818658998000001,
0.08740936198000002,
0.08970881198,
0.09135121098000001,
0.08567644198000002,
0.08713533498,
0.08693685998,
0.08870352498,
0.08647736398,
0.08695365298000002,
0.08804208598000002,
0.08675815298,
0.08792574698,
0.08725342897999999,
0.08624770998,
0.08753668198,
0.08829262898000001,
0.08643101598,
0.08774697098,
0.08662716498,
0.08758364098000002,
0.08648072898
]
},
{
"command": "pnpr@main",
"mean": 0.08736287394969697,
"stddev": 0.001243866333644927,
"median": 0.08727401598000001,
"user": 0.02061526242424242,
"system": 0.009272777575757575,
"min": 0.08525554698000001,
"max": 0.08962658798,
"times": [
0.08678801997999999,
0.08577593898,
0.08682069098,
0.08856267998,
0.08789726298,
0.08556427998000002,
0.08742285698000002,
0.08775160898,
0.08711424598,
0.08692407598000002,
0.08818559698,
0.08739557598,
0.08648449798000002,
0.08661964098,
0.08840012198,
0.08907633798,
0.08691069098000001,
0.08942264298,
0.08868355598,
0.08870457598,
0.08525554698000001,
0.08529056398000001,
0.08682958798000001,
0.08727401598000001,
0.08695522498,
0.08771317698,
0.08817137098,
0.08536665698000001,
0.08776126698,
0.08708495097999999,
0.08962658798,
0.08562218798000001,
0.08951880298
]
}
]
}Scenario: Isolated linker: peer-heavy resolve, hot cache, offline
BENCHMARK_REPORT.json{
"results": [
{
"command": "pacquet@HEAD",
"mean": 1.5866591262511112,
"stddev": 0.36321730907020716,
"median": 1.53122665814,
"user": 1.4825131666666664,
"system": 0.20418441333333337,
"min": 1.07768312914,
"max": 2.41339054514,
"times": [
1.71417514614,
2.41339054514,
1.41073060914,
1.46285352214,
1.67727812014,
1.53122665814,
1.3897162871400002,
1.6028781191400001,
1.07768312914
]
},
{
"command": "pacquet@main",
"mean": 1.675165267251111,
"stddev": 0.5006962950118337,
"median": 1.75514957014,
"user": 1.569011611111111,
"system": 0.20839563555555554,
"min": 1.01935173714,
"max": 2.44754694114,
"times": [
2.22056408314,
1.25824768914,
1.01935173714,
1.75514957014,
2.44754694114,
2.00336683414,
1.0783615501400001,
1.51325474714,
1.7806442531400002
]
},
{
"command": "pnpm@HEAD",
"mean": 2.9428498251399997,
"stddev": 0.07334738010663884,
"median": 2.93024626414,
"user": 4.5326445,
"system": 0.27396596888888886,
"min": 2.84048429114,
"max": 3.06333840714,
"times": [
3.02024016314,
2.88402330514,
3.06333840714,
2.84048429114,
2.89490092514,
2.93524372814,
3.01141391814,
2.93024626414,
2.90575742414
]
}
]
}Scenario: Isolated linker: fresh restore, cold cache + cold store + cold pnpr
BENCHMARK_REPORT.json{
"results": [
{
"command": "pacquet@HEAD",
"mean": 4.548073903380001,
"stddev": 0.11135516706673187,
"median": 4.54414049758,
"user": 1.74758192,
"system": 1.35151822,
"min": 4.42739480058,
"max": 4.77528453358,
"times": [
4.50901978558,
4.77528453358,
4.42739480058,
4.43904034758,
4.61738119358,
4.61876386158,
4.57926120958,
4.44932744858,
4.4584804695799995,
4.60678538358
]
},
{
"command": "pacquet@main",
"mean": 4.46636631158,
"stddev": 0.04041600746635626,
"median": 4.45513724458,
"user": 1.71715402,
"system": 1.42290492,
"min": 4.42686232258,
"max": 4.56397777458,
"times": [
4.4588349775800005,
4.45143951158,
4.50389980858,
4.46937089558,
4.46393362258,
4.44828247458,
4.56397777458,
4.43449159458,
4.42686232258,
4.44257013358
]
},
{
"command": "pnpr@HEAD",
"mean": 3.52543465288,
"stddev": 0.06506632140408841,
"median": 3.49998586958,
"user": 1.21576862,
"system": 1.29201012,
"min": 3.45847423458,
"max": 3.64985845158,
"times": [
3.5620635155800002,
3.56666926758,
3.59572352958,
3.51961621558,
3.64985845158,
3.48013105058,
3.48035552358,
3.45847423458,
3.4656780615800002,
3.47577667858
]
},
{
"command": "pnpr@main",
"mean": 3.5781310190799998,
"stddev": 0.14376946293647838,
"median": 3.51146010608,
"user": 1.2174785199999998,
"system": 1.27040532,
"min": 3.44791301858,
"max": 3.82085620058,
"times": [
3.70398129858,
3.45646157958,
3.4577862765800003,
3.49046367658,
3.49158645358,
3.5313337585799998,
3.82085620058,
3.5845696935799998,
3.79635823458,
3.44791301858
]
}
]
} |
|
| Project | pnpm's project |
| Branch | pr/13564 |
| 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,425.70 ms |
| isolated-linker.fresh-install.cold-cache.hot-store | 📈 view plot | 305.99 ms |
| isolated-linker.fresh-install.hot-cache.hot-store | 📈 view plot | 309.13 ms |
| isolated-linker.fresh-resolve.hot-cache.offline | 📈 view plot | 83.64 ms |
| isolated-linker.fresh-restore.cold-cache.cold-store | 📈 view plot | 1,372.26 ms |
| isolated-linker.fresh-restore.cold-cache.cold-store.cold-pnpr | 📈 view plot | 3,458.47 ms |
| isolated-linker.fresh-restore.hot-cache.hot-store | 📈 view plot | 262.02 ms |
…nce per node (#13565) record_walked_node called previously_resolved_children twice with identical arguments — once to seed the graph children, once to seed the record edges. Each call rescans the ancestor pkg-id chain and, on a match, re-realizes every matching occurrence's children, so the second one was pure repeat work in the peer-resolution hot path. Build the record edges first and iterate them by reference for the graph children. The clone count is unchanged — the per-entry clones in the loop replace the ones the second call made while rebuilding the map — while one chain scan and one realize_children pass go away, and the common case (the node's package is not in its own ancestor chain, so the map is empty) now does strictly less work. Raised by CodeRabbit on #13564. Its suggested fix cloned the map into the first loop instead, which trades one cost for another; building the record edges first removes the call without adding a clone.
Summary
Walker::resolve_nodewas 549 lines — by a wide margin the largest function inresolving-deps-resolver(next isresolve_node_seedat 321; the crate median is13). #13551 split the surrounding file into modules but deliberately left
function bodies untouched; this is the remaining piece.
Lifts the three phases the issue identified as having clean seams:
NodeRecordcapture →Walker::record_walked_nodeinresolve_peers/finalize.rs, next to the post-walk passes that consume thoserecords, taking a borrowed
WalkedNodecontext.ParentRefs(locked-peer scoping → providerchildren → locked pins) →
Walker::build_child_parent_refs, returning theshared map, the node's own contribution, and whether anything changed.
depPath) →
Walker::resolve_node_peers.The early-return short-circuits stay inline, as the issue asked: as
Option<NodeOutput>-returning helpers they make the control flow harder tofollow, not easier.
resolve_nodeis now 378 lines — linear short-circuits plusthe child walk. (The issue's ~290 estimate counted the removed bodies but not the
call sites the extraction adds back.)
Also folds in the adjacent micro-cleanup the issue called out:
Walker::deferred_child_resolutiondid twopure_pkgshash lookups where oneif letchain does.Verification:
just readygreen — 7541 tests passed, 0 failures.isolated-linker.peer-heavy-resolve.hot-cache.offline,--runs=9, HEAD vs. its parent), two passes: 1.04× ± 0.28 and 1.02× ± 0.20 infavour of the parent — well inside the fixture's known ~15% run-to-run spread
(test(pacquet): stabilize the peer-heavy benchmark and stop its gate dropping data #13559), i.e. no measurable change. Both passes also cleared the
harness's peer-heavy lockfile parity check.
Closes #13553.
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 (Claude Code, claude-opus-5[1m]).
Need help on this PR? Tag
@codesmith-botwith what you need. Autofix is disabled.Summary by CodeRabbit