Repository navigation
Conversation
…t key
The peer-resolution passes sort `NodeId`s so their output does not depend
on hash iteration order. The comparison key was a freshly formatted
`String` per element — `"0:{value:020}"` for a counter, `"1:{id}"` for a
leaf — and `sort_by_key` re-invokes the key function on every comparison,
so each sort allocated `O(n log n)` strings. `build_final_dep_paths` and
the Tarjan pass under it run those sorts over every node that resolved a
peer, plus one sorted successor list per node.
Derive `Ord` on `NodeId` instead and sort the values directly. The
derived order is the same total order the rendered keys encoded: the
variant order puts counters before leaves, a fixed-width zero-padded
u64 compares like the number it renders, and leaf ids compare as their
`str` either way. The resolved graph is unchanged.
On the 114-project Bit workspace from
https://github.com/pnpm/pnpm/issues/13505, resolution drops from ~16.0s
to ~13.4s, with the final depPath pass falling from 2.50s to 0.76s. The
peer-heavy `workspace_full_resolution` benchmark goes from ~1.01s to
~0.85s.
📝 WalkthroughWalkthroughThe resolver now derives total ordering for ChangesPeer resolution ordering
Estimated code review effort: 2 (Simple) | ~10 minutes 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 |
Confidence Score: 5/5The PR appears safe to merge with no actionable correctness or security issues identified. Derived NodeId ordering preserves the previous counter-before-leaf, numeric-counter, and lexical-leaf order at every changed sort site, so the optimization does not alter resolver traversal or output. Reviews (1): Last reviewed commit: "perf(resolving-deps-resolver): order nod..." | Re-trigger Greptile |
PR Summary by Qodoperf(resolving-deps-resolver): sort NodeId directly via derived Ord
AI Description
Diagram
High-Level Assessment
Files changed (6)
|
There was a problem hiding this comment.
Pull request overview
Improves pacquet’s peer-resolution finalization performance by removing per-comparison String allocations when ordering NodeIds, replacing sort_by_key(node_id_sort_key) with direct Ord-based sorting and adding a test to lock in the ordering contract.
Changes:
- Derive
PartialOrd/OrdforNodeIdand switch peer-phase sorts toVec::sort(). - Remove the string-based
node_id_sort_keyhelper previously used for deterministic ordering. - Add a unit test asserting the
NodeIdordering (counters first, numeric order; then leaves by id) and include a changeset for the pacquet patch release.
Reviewed changes
Copilot reviewed 6 out of 6 changed files in this pull request and generated 1 comment.
Show a summary per file
| File | Description |
|---|---|
| pnpm/crates/resolving-deps-resolver/src/resolve_peers/finalize.rs | Replaces sort-key allocation with direct NodeId ordering for deterministic peer finalization and Tarjan neighbor ordering. |
| pnpm/crates/resolving-deps-resolver/src/resolve_peers/context.rs | Removes node_id_sort_key now that NodeId has a native total order. |
| pnpm/crates/resolving-deps-resolver/src/resolve_peers.rs | Switches deterministic sorting of dependency-tree NodeIds to sort() over &NodeId. |
| pnpm/crates/resolving-deps-resolver/src/node_id.rs | Derives Ord for NodeId and documents the ordering contract used by peer-resolution. |
| pnpm/crates/resolving-deps-resolver/src/node_id/tests.rs | Adds a unit test pinning the NodeId ordering semantics. |
| .changeset/faster-peer-dep-path-finalization.md | Records the pacquet patch-level perf improvement for release notes. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
There was a problem hiding this comment.
🧹 Nitpick comments (1)
pnpm/crates/resolving-deps-resolver/src/node_id/tests.rs (1)
16-16: 📐 Maintainability & Code Quality | 🔵 Trivial | ⚡ Quick winRemove the committed
dbg!output.
dbg!(&node_ids)writes to test stderr on every run. Theassert_eq!already exposes the values when the test fails. Remove this debug artifact to keep CI output quiet.Proposed change
- dbg!(&node_ids);🤖 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/node_id/tests.rs` at line 16, Remove the committed dbg!(&node_ids) statement from the test, leaving the existing assert_eq! validation unchanged so values are still reported only on failure.
🤖 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/node_id/tests.rs`:
- Line 16: Remove the committed dbg!(&node_ids) statement from the test, leaving
the existing assert_eq! validation unchanged so values are still reported only
on failure.
ℹ️ Review info
⚙️ Run configuration
Configuration used: Path: .coderabbit.yaml
Review profile: CHILL
Plan: Pro Plus
Run ID: e5e8069a-41ce-4978-be24-1eafe10ed6eb
📒 Files selected for processing (6)
.changeset/faster-peer-dep-path-finalization.mdpnpm/crates/resolving-deps-resolver/src/node_id.rspnpm/crates/resolving-deps-resolver/src/node_id/tests.rspnpm/crates/resolving-deps-resolver/src/resolve_peers.rspnpm/crates/resolving-deps-resolver/src/resolve_peers/context.rspnpm/crates/resolving-deps-resolver/src/resolve_peers/finalize.rs
💤 Files with no reviewable changes (1)
- pnpm/crates/resolving-deps-resolver/src/resolve_peers/context.rs
Code Review by Qodo
Context used✅ Compliance rules (platform):
24 rules 1. Stray dbg! in test
|
PR Code Suggestions ✨Warning
No code suggestions found for the PR. |
|
Thanks — going through the three Qodo findings: 1. 2. Ordering contract tied to 3. Changeset missing a Written by an agent (Claude Code, claude-opus-5). |
Micro-Benchmark ResultsLinux |
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main pnpm/pnpm#13568 +/- ##
==========================================
- Coverage 87.96% 87.96% -0.01%
==========================================
Files 563 563
Lines 97341 97339 -2
==========================================
- Hits 85624 85622 -2
Misses 11717 11717 ☔ 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.5232203285200003,
"stddev": 0.13970471464293324,
"median": 2.5423404840200003,
"user": 1.5127224399999997,
"system": 1.2333211400000001,
"min": 2.35376548202,
"max": 2.8083329430200004,
"times": [
2.4624375780200003,
2.56973571902,
2.8083329430200004,
2.57319420102,
2.35376548202,
2.5817322330200003,
2.36181910702,
2.61919453502,
2.51494524902,
2.3870462380200004
]
},
{
"command": "pacquet@main",
"mean": 2.4171783596200003,
"stddev": 0.0732905515128862,
"median": 2.4176369165200002,
"user": 1.4731255399999996,
"system": 1.27003494,
"min": 2.33101172802,
"max": 2.55994364402,
"times": [
2.3355274010200002,
2.42089356602,
2.4143802670200003,
2.55994364402,
2.36237089902,
2.48730394202,
2.47278465602,
2.4232819450200003,
2.33101172802,
2.3642855480200002
]
},
{
"command": "pnpr@HEAD",
"mean": 1.52521035732,
"stddev": 0.1641843130065678,
"median": 1.55861421202,
"user": 1.02716554,
"system": 1.12399994,
"min": 1.3415445280199998,
"max": 1.74050352102,
"times": [
1.74050352102,
1.65286687002,
1.3541401070199999,
1.34267619802,
1.72119152202,
1.3415445280199998,
1.63279513602,
1.54387053002,
1.34915726702,
1.57335789402
]
},
{
"command": "pnpr@main",
"mean": 1.57134645342,
"stddev": 0.16663324990576853,
"median": 1.66678560902,
"user": 1.0163092399999998,
"system": 1.12384774,
"min": 1.35813570702,
"max": 1.75229310202,
"times": [
1.35813570702,
1.67648995902,
1.65708125902,
1.75229310202,
1.67778868602,
1.74226534402,
1.36288258502,
1.6788447440199998,
1.43231596502,
1.37536718302
]
}
]
}Scenario: Isolated linker: fresh restore, hot cache + hot store
BENCHMARK_REPORT.json{
"results": [
{
"command": "pacquet@HEAD",
"mean": 0.2562938389800001,
"stddev": 0.00218880182568272,
"median": 0.25650155108000006,
"user": 0.2130764,
"system": 0.52236614,
"min": 0.25317954958000005,
"max": 0.26019748458,
"times": [
0.25369021558000004,
0.25619316758000005,
0.25504917458000004,
0.25693549058000004,
0.25680993458000007,
0.26019748458,
0.25822634958,
0.25797580958000005,
0.25317954958000005,
0.25468121358000007
]
},
{
"command": "pacquet@main",
"mean": 0.25390930477999996,
"stddev": 0.007981980668477757,
"median": 0.25141295158000004,
"user": 0.20335609999999998,
"system": 0.52696554,
"min": 0.24508053358,
"max": 0.27343047558000005,
"times": [
0.24881676958,
0.25177089758000004,
0.25764321658000006,
0.25643359958000006,
0.25665953358000004,
0.24508053358,
0.24820057358,
0.25000244258000004,
0.25105500558000005,
0.27343047558000005
]
},
{
"command": "pnpr@HEAD",
"mean": 0.2684321592800001,
"stddev": 0.00961500607414793,
"median": 0.26664789558,
"user": 0.21873359999999997,
"system": 0.5183929400000001,
"min": 0.25705364258,
"max": 0.28389126858,
"times": [
0.27309413458000004,
0.28079937158000007,
0.28389126858,
0.27548194358000005,
0.26015617858000006,
0.25705364258,
0.26100258558000006,
0.25954667658,
0.27053309458,
0.26276269658000007
]
},
{
"command": "pnpr@main",
"mean": 0.26451264238000005,
"stddev": 0.0035975993603774453,
"median": 0.26421514358000003,
"user": 0.20557309999999998,
"system": 0.5326315399999999,
"min": 0.25919325258000003,
"max": 0.27050548158000004,
"times": [
0.26209443358000006,
0.26915244558000007,
0.25919325258000003,
0.26193992258000004,
0.27050548158000004,
0.26476040058000005,
0.26429811358000005,
0.26752739858,
0.26413217358,
0.26152280158
]
}
]
}Scenario: Isolated linker: fresh install, cold cache + cold store
BENCHMARK_REPORT.json{
"results": [
{
"command": "pacquet@HEAD",
"mean": 2.57344228938,
"stddev": 0.023765586188864193,
"median": 2.5749132583799996,
"user": 1.3961533799999999,
"system": 1.33647118,
"min": 2.53063969338,
"max": 2.60285323638,
"times": [
2.58044966238,
2.59966137238,
2.56782852138,
2.5571992423800003,
2.60285323638,
2.54741469838,
2.53063969338,
2.57032470938,
2.57950180738,
2.59854995038
]
},
{
"command": "pacquet@main",
"mean": 2.57501901358,
"stddev": 0.017654882320938724,
"median": 2.57874551388,
"user": 1.4169457799999998,
"system": 1.31595518,
"min": 2.54786459938,
"max": 2.59709476138,
"times": [
2.58204157838,
2.58501242838,
2.59709476138,
2.54786459938,
2.5908277113800002,
2.59410898338,
2.5754494493799998,
2.55703014438,
2.55469454438,
2.56606593538
]
},
{
"command": "pnpr@HEAD",
"mean": 1.57004378478,
"stddev": 0.1505673014392829,
"median": 1.4882227213800001,
"user": 0.9887062799999999,
"system": 1.1682552800000001,
"min": 1.4188978193800001,
"max": 1.78943353938,
"times": [
1.74303743138,
1.67313469038,
1.4188978193800001,
1.78943353938,
1.75475895738,
1.4834831503800001,
1.46450752338,
1.4929622923800001,
1.44492096938,
1.43530147438
]
},
{
"command": "pnpr@main",
"mean": 1.59145020698,
"stddev": 0.10610947055503826,
"median": 1.56901744888,
"user": 1.02258908,
"system": 1.1349618799999999,
"min": 1.43972134138,
"max": 1.76628677138,
"times": [
1.72085074438,
1.50567472838,
1.54164598038,
1.69390927038,
1.61048667038,
1.59638891738,
1.51989697338,
1.43972134138,
1.51964067238,
1.76628677138
]
}
]
}Scenario: Isolated linker: fresh install, hot cache + hot store
BENCHMARK_REPORT.json{
"results": [
{
"command": "pacquet@HEAD",
"mean": 0.38859809520000005,
"stddev": 0.007650664992709523,
"median": 0.3889287632,
"user": 0.49497125999999997,
"system": 0.70539928,
"min": 0.37750621170000004,
"max": 0.3996957057,
"times": [
0.37750621170000004,
0.39066596470000003,
0.38404852770000003,
0.39666300870000004,
0.3881775397,
0.39707337870000003,
0.38967998670000004,
0.3996957057,
0.3791150687,
0.3833555597
]
},
{
"command": "pacquet@main",
"mean": 0.38352654450000007,
"stddev": 0.009604572317918187,
"median": 0.38337499070000003,
"user": 0.51379396,
"system": 0.6513816799999999,
"min": 0.37025889370000004,
"max": 0.4001735007,
"times": [
0.37025889370000004,
0.3838254307,
0.38292455070000003,
0.3891644307,
0.39213413770000005,
0.3889306817,
0.37319578070000003,
0.4001735007,
0.3719437427,
0.38271429570000004
]
},
{
"command": "pnpr@HEAD",
"mean": 0.2996486892,
"stddev": 0.00627932176203585,
"median": 0.2982997217,
"user": 0.20014685999999998,
"system": 0.5101580800000001,
"min": 0.2893026387,
"max": 0.3094923017,
"times": [
0.3094923017,
0.29474488270000004,
0.2893026387,
0.2959961177,
0.2995484377,
0.30803399870000003,
0.30544936170000003,
0.2977957217,
0.29731970970000005,
0.2988037217
]
},
{
"command": "pnpr@main",
"mean": 0.30547125480000004,
"stddev": 0.006529147365575743,
"median": 0.30460177120000004,
"user": 0.19966695999999998,
"system": 0.53494428,
"min": 0.2956672857,
"max": 0.31877755570000005,
"times": [
0.30441560170000004,
0.30507874570000004,
0.30478794070000004,
0.2956672857,
0.3006787347,
0.31877755570000005,
0.30418601170000004,
0.31167005670000003,
0.3094475387,
0.30000307670000004
]
}
]
}Scenario: Isolated linker: fresh install, cold cache + hot store
BENCHMARK_REPORT.json{
"results": [
{
"command": "pacquet@HEAD",
"mean": 1.7252968586800002,
"stddev": 0.009430180638398839,
"median": 1.7292498305800001,
"user": 0.7045827800000001,
"system": 0.74721576,
"min": 1.7073123405800001,
"max": 1.7368473295800002,
"times": [
1.7285253015800002,
1.7330520105800002,
1.7368473295800002,
1.7142118905800001,
1.7299743595800001,
1.7322741225800002,
1.73008995658,
1.7184179465800002,
1.7073123405800001,
1.72226332858
]
},
{
"command": "pacquet@main",
"mean": 1.71940046908,
"stddev": 0.00723465959382519,
"median": 1.7179076655800003,
"user": 0.68644188,
"system": 0.73385556,
"min": 1.70818416558,
"max": 1.73057396458,
"times": [
1.7123851235800003,
1.7177459075800001,
1.7301727015800001,
1.7249981275800002,
1.73057396458,
1.7188395185800003,
1.71542750958,
1.7180694235800003,
1.7176082485800002,
1.70818416558
]
},
{
"command": "pnpr@HEAD",
"mean": 0.29947308168000003,
"stddev": 0.0055533837881362276,
"median": 0.29896871508000006,
"user": 0.18663007999999998,
"system": 0.51598996,
"min": 0.29193653258,
"max": 0.30718017858,
"times": [
0.29974961458000005,
0.29263908958000007,
0.29193653258,
0.29445304158,
0.29794611158000006,
0.30718017858,
0.30087027658000004,
0.30509554858000004,
0.29818781558000007,
0.30667260758000003
]
},
{
"command": "pnpr@main",
"mean": 0.30432824488000004,
"stddev": 0.007655432934724024,
"median": 0.3044912215800001,
"user": 0.19040107999999997,
"system": 0.54319226,
"min": 0.29458307458000005,
"max": 0.31844753858,
"times": [
0.31203496458,
0.30954325058000004,
0.30054074858,
0.31844753858,
0.29485186958000004,
0.30439967458000006,
0.30458276858000005,
0.29809799658,
0.30620056258000006,
0.29458307458000005
]
}
]
}Scenario: Isolated linker: fresh resolve, hot cache, offline
BENCHMARK_REPORT.json{
"results": [
{
"command": "pacquet@HEAD",
"mean": 0.17845826481750002,
"stddev": 0.008731931509146567,
"median": 0.17913462288,
"user": 0.16187905749999998,
"system": 0.07228144750000001,
"min": 0.16423221138000002,
"max": 0.19391881238000003,
"times": [
0.17293379838000003,
0.16748492038,
0.16423221138000002,
0.17176402638000002,
0.17969149238,
0.17038337638000003,
0.18678169838000003,
0.18184748538000003,
0.17181815638000003,
0.18098203238000002,
0.19077166138,
0.18646029538000003,
0.17203672538000003,
0.18564779138,
0.19391881238000003,
0.17857775338
]
},
{
"command": "pacquet@main",
"mean": 0.17989915766571432,
"stddev": 0.00673433243329755,
"median": 0.17860147238000001,
"user": 0.1653599057142857,
"system": 0.06531426,
"min": 0.17521262138000002,
"max": 0.20191889538000002,
"times": [
0.20191889538000002,
0.17902889038000003,
0.17605443238000001,
0.18184999838000002,
0.17679417938000003,
0.17841458738000002,
0.17907742038000002,
0.18160987938000003,
0.17566508138000003,
0.17706266138,
0.17521262138000002,
0.17878835738,
0.18148173938000003,
0.17562946338000002
]
},
{
"command": "pnpr@HEAD",
"mean": 0.08734405380424246,
"stddev": 0.0007696379685796681,
"median": 0.08727231538,
"user": 0.02095493818181818,
"system": 0.00880164606060606,
"min": 0.08597328938,
"max": 0.08870354938,
"times": [
0.08597328938,
0.08714150138,
0.08814793838,
0.08747564738000001,
0.08621777838,
0.08837032438,
0.08748531438,
0.08660236838,
0.08709768838,
0.08863868738,
0.08619685838,
0.08758485138000001,
0.08783460938,
0.08748001438,
0.08852899138,
0.08727231538,
0.08655460838000001,
0.08658878338,
0.08845872938,
0.08658995538,
0.08798077438,
0.08799251638,
0.08678929938,
0.08722125938,
0.08668952238000001,
0.08843484538,
0.08706859338,
0.08738282238,
0.08723886238,
0.08666245238,
0.08870354938,
0.08661795838,
0.08733106538
]
},
{
"command": "pnpr@main",
"mean": 0.08713755792545454,
"stddev": 0.001699898368094971,
"median": 0.08725706638,
"user": 0.021278301818181824,
"system": 0.008815327272727274,
"min": 0.08384898538,
"max": 0.09112279538,
"times": [
0.08480708338,
0.08589738638,
0.08911329738,
0.08680606038000001,
0.08762553738000001,
0.08688253338,
0.08671596138,
0.08814831838000001,
0.08774633438,
0.08784783438,
0.08685360938,
0.08716151738,
0.08799059238,
0.08737131138,
0.08721978638,
0.08932799038,
0.08493394938,
0.08780149738,
0.08969406738,
0.08435810038,
0.08662663438,
0.09112279538,
0.08480442738,
0.08745480838,
0.08782261838000001,
0.08494644438,
0.08384898538,
0.08772638638000001,
0.08982516238,
0.08604527338,
0.08498087738,
0.08877516338000001,
0.08725706638
]
}
]
}Scenario: Isolated linker: peer-heavy resolve, hot cache, offline
BENCHMARK_REPORT.json{
"results": [
{
"command": "pacquet@HEAD",
"mean": 1.4247208838866667,
"stddev": 0.4744929733263082,
"median": 1.4474978542199999,
"user": 1.33580854,
"system": 0.18256825333333335,
"min": 0.8988278942200001,
"max": 2.42385326122,
"times": [
1.72157311222,
1.0990304682199998,
0.9200429212200001,
1.4474978542199999,
1.21878360122,
1.59575783622,
0.8988278942200001,
2.42385326122,
1.49712100622
]
},
{
"command": "pacquet@main",
"mean": 1.6448442156644443,
"stddev": 0.5904244349284231,
"median": 1.59793244422,
"user": 1.5214263177777778,
"system": 0.2127108088888889,
"min": 0.8148109022200001,
"max": 2.81093860922,
"times": [
1.23462506922,
2.23258126522,
1.66267267722,
1.32491490522,
2.81093860922,
1.3302382982199998,
0.8148109022200001,
1.79488377022,
1.59793244422
]
},
{
"command": "pnpm@HEAD",
"mean": 2.8689636075533334,
"stddev": 0.0450950086053686,
"median": 2.89037294822,
"user": 4.412219873333333,
"system": 0.24694480888888892,
"min": 2.78488968722,
"max": 2.91809184122,
"times": [
2.89037294822,
2.78488968722,
2.83134313622,
2.84319016222,
2.84275599822,
2.90012567822,
2.90452177222,
2.90538124422,
2.91809184122
]
}
]
}Scenario: Isolated linker: fresh restore, cold cache + cold store + cold pnpr
BENCHMARK_REPORT.json{
"results": [
{
"command": "pacquet@HEAD",
"mean": 4.472034159280001,
"stddev": 0.07674383295710575,
"median": 4.442735541779999,
"user": 1.6221548799999996,
"system": 1.36403626,
"min": 4.38394709578,
"max": 4.62395601078,
"times": [
4.41871039078,
4.44375311578,
4.44953165078,
4.51416776878,
4.38394709578,
4.43403902778,
4.44171796778,
4.42886687878,
4.58165168578,
4.62395601078
]
},
{
"command": "pacquet@main",
"mean": 4.4694473733799995,
"stddev": 0.06333834951181475,
"median": 4.465736616280001,
"user": 1.6711782800000001,
"system": 1.29508076,
"min": 4.39295869678,
"max": 4.59311937578,
"times": [
4.49323106078,
4.52091832578,
4.4311521667800005,
4.40767462578,
4.4565091507800005,
4.59311937578,
4.51744184778,
4.39295869678,
4.4749640817800005,
4.40650440178
]
},
{
"command": "pnpr@HEAD",
"mean": 3.5409453767800008,
"stddev": 0.1300244720165349,
"median": 3.4759941562800005,
"user": 1.1621707799999998,
"system": 1.22081306,
"min": 3.4617288577800003,
"max": 3.8642839817800003,
"times": [
3.4705862297800003,
3.4617288577800003,
3.4814020827800003,
3.6232508717800003,
3.61937814878,
3.46373680278,
3.4997443827800003,
3.46247875378,
3.8642839817800003,
3.46286365578
]
},
{
"command": "pnpr@main",
"mean": 3.4850726861799997,
"stddev": 0.041191872548176335,
"median": 3.4939514747800002,
"user": 1.16439118,
"system": 1.1753521599999999,
"min": 3.42827484178,
"max": 3.55920981578,
"times": [
3.46151464678,
3.44266839978,
3.49012455178,
3.44034097678,
3.55920981578,
3.5151786187800003,
3.42827484178,
3.50205013878,
3.4977783977800003,
3.51358647378
]
}
]
} |
|
| Project | pnpm's project |
| Branch | pr/13568 |
| 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,418.90 ms |
| isolated-linker.fresh-install.cold-cache.hot-store | 📈 view plot | 291.94 ms |
| isolated-linker.fresh-install.hot-cache.hot-store | 📈 view plot | 289.30 ms |
| isolated-linker.fresh-resolve.hot-cache.offline | 📈 view plot | 85.97 ms |
| isolated-linker.fresh-restore.cold-cache.cold-store | 📈 view plot | 1,341.54 ms |
| isolated-linker.fresh-restore.cold-cache.cold-store.cold-pnpr | 📈 view plot | 3,461.73 ms |
| isolated-linker.fresh-restore.hot-cache.hot-store | 📈 view plot | 257.05 ms |
Summary
Third installment on the peer-phase performance work in
pnpm/tasks#16 (after #13506 and
#13545). Related to pnpm/tasks#16 — partial fix, the issue stays
open.
Profiling the reference Bit workspace (114 projects, ~21,000 lockfile entries;
resolution-only replay through
@pnpm/napiwithlockfileOnly: true) showedthat 2.50s of the 4.6s final peer pass was spent in
build_final_dep_paths— not in peer matching, but in sorting. The peer-resolution passes sort
NodeIds so their output does not depend on hash iteration order, and thecomparison key was a freshly formatted
Stringper element(
"0:{value:020}"for a counter,"1:{id}"for a leaf).sort_by_keyre-invokes the key function on every comparison, so each sort allocated
O(n log n)strings; the Tarjan pass underbuild_final_dep_pathsalso sortsone successor list per participating node.
Deriving
OrdonNodeIdand sorting the values directly removes thoseallocations. The derived order is the same total order the rendered keys
encoded, so the resolved graph is unchanged (see the commit body for why the
two orders coincide).
Measured on the reference workspace (resolution-only replay, warm cache,
offline):
build_final_dep_pathsThe in-repo
workspace_full_resolutionbenchmark's peer-heavy scenario goesfrom ~1.01s to ~0.85s (3 runs each, ±0.01s).
Side finding: resolution is not run-to-run deterministic on that workspace
While setting up the byte-comparison for this change I found that
mainalready produces different lockfiles on consecutive runs of the same binary,
with the same input lockfile and
offline: true— peer-variant bindings flipbetween still-valid providers (e.g.
[email protected]↔5.5.3↔5.9.3,several thousand lines). This predates this PR and is unrelated to it; it is
almost certainly the concurrent importer-init fan-out interacting with an
order-sensitive fold (the preferred-versions fold the hoist pickers read).
Filed separately as #13567.
Because of that, byte-identity of the emitted lockfile could not be used as the
gate here. The change is instead argued to be output-preserving by
construction (equal orders) and covered by the full suite (7,547 tests pass)
plus a unit test pinning the ordering contract.
Still open on pnpm/tasks#16
phase is still single-threaded (~4.6s discovery walks + ~2.3s final walk).
emission-parity check).
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).
Need help on this PR? Tag
@codesmith-botwith what you need. Autofix is disabled.Summary by CodeRabbit
Performance
Bug Fixes
Tests