Repository navigation
perf(resolving-deps-resolver): answer the hoist scope's ancestor queries per shared suffix - #13587
Conversation
…ies per shared suffix Deciding whether a missing-peer issue is covered by another importer's walk scans the issue's ancestor chain for a package that importer owns. The scan ran per issue, and issues of one peer come from occurrences spread through the tree whose chains share long suffixes, so the same suffix was rescanned once per issue: `O(issues x depth)` per importer, with the issue count growing with the workspace. `SharedChain` already shares those suffixes structurally, so the answer for a link covers that link and everything above it, for every chain built on it. `any_memoized` records that answer per link, taking the total to the number of distinct links; a suffix that already matched spares each branch's own tip as well. Both callers memoize: the post-round scope filter, per peer name, and the walk's own suppression check, which holds one memo per peer name for the walk (its scope is fixed for the walk's lifetime). Output is unchanged. On the full-size workspace resolution fixture, whose chains are 250 deep, resolution goes from ~1.56s to ~1.25s. It is neutral on the 114-importer bit.cloud workspace and on the CI-sized fixture, both of which have chains too shallow for the rescan to dominate: the term this removes scales with the issue count, but only in proportion to chain depth. Related to https://github.com/pnpm/pnpm/issues/13505.
📝 WalkthroughWalkthroughThe resolver adds memoized shared-chain suffix checks for missing-peer suppression. ChangesPeer suppression memoization
Estimated code review effort: 3 (Moderate) | ~20 minutes Possibly related PRs
Suggested labels: Suggested reviewers: ✨ Finishing Touches 💡 1🛠️ Fix failing CI checks 💡
📝 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 QodoMemoize hoist-scope ancestor scans per SharedChain suffix
AI Description
Diagram
High-Level Assessment
Files changed (6)
|
Confidence Score: 5/5The PR appears safe to merge. The previously reported pointer-key lifetime defect is fixed because every cached address is paired with an owning Arc that keeps the allocation alive until its memo is dropped, and no blocking failure remains. Reviews (2): Last reviewed commit: "fix(resolving-deps-resolver): key the ch..." | Re-trigger Greptile |
There was a problem hiding this comment.
Actionable comments posted: 1
🧹 Nitpick comments (2)
.changeset/hoist-scope-suffix-memo.md (1)
5-5: 📐 Maintainability & Code Quality | 🔵 Trivial | ⚡ Quick winDescribe the observable performance result.
Replace the cache implementation detail with a concise user-facing result, such as:
Improve workspace resolution performance for deep dependency trees.As per path instructions, changeset text must be concise and user-facing.
🤖 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 @.changeset/hoist-scope-suffix-memo.md at line 5, Rewrite the changeset description to be concise and user-facing, focusing on improved workspace resolution performance for deep dependency trees. Remove implementation details about caching, shared chain segments, and reports while preserving the observable performance improvement.Sources: Path instructions, Learnings
pnpm/crates/resolving-deps-resolver/src/resolve_peers/context/tests.rs (1)
159-162: 📐 Maintainability & Code Quality | 🔵 Trivial | 💤 Low valueRemove the redundant doc comment.
The comment only restates the helper behavior. The helper name and implementation already define this behavior.
As per coding guidelines, comments must not restate code. As per path instructions, document only non-obvious invariants.
🤖 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/context/tests.rs` around lines 159 - 162, Remove the redundant doc comment above the chain_of helper; leave the function name and implementation unchanged.Sources: Coding guidelines, 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.
Inline comments:
In `@pnpm/crates/resolving-deps-resolver/src/resolve_peers/context.rs`:
- Around line 99-136: Update ChainSuffixMemo and SharedChain::any_memoized so
every memoized verdict retains the corresponding Arc<SharedChainLink<Element>>
alongside its result, preventing link addresses from being reused while cached.
Adjust lookups and inserts to validate the retained identity, and add a
regression test covering a dropped memoized branch followed by a distinct branch
with a different coverage result.
---
Nitpick comments:
In @.changeset/hoist-scope-suffix-memo.md:
- Line 5: Rewrite the changeset description to be concise and user-facing,
focusing on improved workspace resolution performance for deep dependency trees.
Remove implementation details about caching, shared chain segments, and reports
while preserving the observable performance improvement.
In `@pnpm/crates/resolving-deps-resolver/src/resolve_peers/context/tests.rs`:
- Around line 159-162: Remove the redundant doc comment above the chain_of
helper; leave the function name and implementation unchanged.
🪄 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: 22d65617-340f-4204-b429-02ae0405e781
📒 Files selected for processing (6)
.changeset/hoist-scope-suffix-memo.mdpnpm/crates/resolving-deps-resolver/src/resolve_peers.rspnpm/crates/resolving-deps-resolver/src/resolve_peers/context.rspnpm/crates/resolving-deps-resolver/src/resolve_peers/context/tests.rspnpm/crates/resolving-deps-resolver/src/resolve_peers/discovery.rspnpm/crates/resolving-deps-resolver/src/resolve_peers/walker.rs
Code Review by Qodo
Context used✅ Compliance rules (platform):
24 rules 1.
|
PR Code Suggestions ✨Warning
No code suggestions found for the PR. |
Micro-Benchmark ResultsLinux |
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #13587 +/- ##
=======================================
Coverage 87.98% 87.99%
=======================================
Files 563 563
Lines 97596 97636 +40
=======================================
+ Hits 85874 85918 +44
+ Misses 11722 11718 -4 ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
…eeps alive An address identifies a link only while that link is alive, so a memo keyed on `Arc::as_ptr` answers for whatever occupies the address now. The walk-level memo held addresses for the length of a walk, which allocates and drops chain links throughout: a recycled address would have handed an unrelated chain a suppression verdict computed for a dropped one, silently keeping or dropping a missing-peer report. Drop that memo — it was also the one that had to allocate a `String` per call to find its bucket, and measuring says the walk never needed it: the fixture is faster without it, 1.25s to 1.19s. What remains is the post-round filter, whose chains all predate it, and it now holds an `Arc` to every link it keys on, so an entry cannot outlive its link's address. The invariant is structural instead of a rule for callers to remember. Reported by three reviewers on #13587.
|
Good catch, and it was a real defect — fixed in 5fcc9d9. Three of the four findings share one root cause. Pointer-key memo collision (Greptile P1, CodeRabbit, Qodo #1). Correct. An address identifies a link only while that link is alive. The post-round filter happened to be safe — its chains are all built before the fold and nothing allocates during it — but the Two changes:
Peer name reallocated (Qodo #3) and Memo memory amplification (Qodo #4) were both properties of that same walk-level memo — the Changeset missing (Qodo #2) is a false positive: Net effect improves: 1.56s → 1.19s (1.31x) on the full-size fixture. 7,565 tests pass; Written by an agent (Claude Code, claude-opus-5). |
There was a problem hiding this comment.
🧹 Nitpick comments (1)
pnpm/crates/resolving-deps-resolver/src/resolve_peers/context/tests.rs (1)
159-160: 📐 Maintainability & Code Quality | 🔵 Trivial | 💤 Low valueRemove or replace the helper comment.
The comment restates
link_strong_count. Remove it, or document a non-obvious test invariant instead.As per coding guidelines, comments must explain non-obvious invariants or rationale and must not restate the implementation.
🤖 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/context/tests.rs` around lines 159 - 160, Remove the redundant doc comment above the link_strong_count helper, or replace it with a comment describing a non-obvious test invariant or rationale rather than restating the function’s behavior.Sources: Coding guidelines, 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.
Nitpick comments:
In `@pnpm/crates/resolving-deps-resolver/src/resolve_peers/context/tests.rs`:
- Around line 159-160: Remove the redundant doc comment above the
link_strong_count helper, or replace it with a comment describing a non-obvious
test invariant or rationale rather than restating the function’s behavior.
ℹ️ Review info
⚙️ Run configuration
Configuration used: Path: .coderabbit.yaml
Review profile: CHILL
Plan: Pro Plus
Run ID: 8bad9ad1-90e0-4110-bd5b-120894157277
📒 Files selected for processing (4)
pnpm/crates/resolving-deps-resolver/src/resolve_peers.rspnpm/crates/resolving-deps-resolver/src/resolve_peers/context.rspnpm/crates/resolving-deps-resolver/src/resolve_peers/context/tests.rspnpm/crates/resolving-deps-resolver/src/resolve_peers/discovery.rs
🚧 Files skipped from review as they are similar to previous changes (3)
- pnpm/crates/resolving-deps-resolver/src/resolve_peers/discovery.rs
- pnpm/crates/resolving-deps-resolver/src/resolve_peers.rs
- pnpm/crates/resolving-deps-resolver/src/resolve_peers/context.rs
|
Code review by qodo was updated up to the latest commit 5fcc9d9 |
PR Code Suggestions ✨Warning
No code suggestions found for the PR. |
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.4428630573,
"stddev": 0.11272344861897984,
"median": 2.3808523316,
"user": 1.5005592799999998,
"system": 1.2729997600000003,
"min": 2.3628078306,
"max": 2.7070802906,
"times": [
2.3721275086,
2.4585630576,
2.7070802906,
2.4521477286,
2.3793420426000003,
2.3823626206,
2.3758942406,
2.3628078306,
2.3710683346,
2.5672369186
]
},
{
"command": "pacquet@main",
"mean": 2.5078011010000005,
"stddev": 0.16326611054961146,
"median": 2.4324206896000002,
"user": 1.4956112799999999,
"system": 1.2648362599999998,
"min": 2.3610961866,
"max": 2.8055068906000002,
"times": [
2.7707838976,
2.4267061346000003,
2.3896949266000003,
2.4381352446,
2.3610961866,
2.4140725206,
2.3713601766,
2.8055068906000002,
2.5961228606,
2.5045321716
]
},
{
"command": "pnpr@HEAD",
"mean": 1.4643591208999998,
"stddev": 0.13798934280881964,
"median": 1.3973038376,
"user": 1.0436842800000001,
"system": 1.1347189600000003,
"min": 1.3571153046000002,
"max": 1.7410893486,
"times": [
1.3577146536,
1.3957361356,
1.7410893486,
1.3779630046000002,
1.6638910246,
1.3791861466,
1.3571153046000002,
1.4249854246,
1.5470386266,
1.3988715396
]
},
{
"command": "pnpr@main",
"mean": 1.5021206662000002,
"stddev": 0.15600830776452695,
"median": 1.4845592756000001,
"user": 1.03992638,
"system": 1.09657556,
"min": 1.3411119756,
"max": 1.7252627406,
"times": [
1.5668674786,
1.3687707776,
1.4022510726000001,
1.6782162556000002,
1.6410334406000002,
1.6087379476,
1.3462750456,
1.7252627406,
1.3411119756,
1.3426799276
]
}
]
}Scenario: Isolated linker: fresh restore, hot cache + hot store
BENCHMARK_REPORT.json{
"results": [
{
"command": "pacquet@HEAD",
"mean": 0.25619657020000003,
"stddev": 0.005787733595662651,
"median": 0.25546764920000004,
"user": 0.20368092,
"system": 0.5177492399999999,
"min": 0.2452716697,
"max": 0.2657265757,
"times": [
0.25792162970000004,
0.2657265757,
0.25121878870000003,
0.25559602070000004,
0.25834568770000005,
0.2549962707,
0.25413260470000004,
0.25533927770000003,
0.2452716697,
0.26341717670000003
]
},
{
"command": "pacquet@main",
"mean": 0.2485593956,
"stddev": 0.007169396491932746,
"median": 0.24821935570000003,
"user": 0.19583431999999998,
"system": 0.49631283999999987,
"min": 0.23412275770000002,
"max": 0.25899483970000003,
"times": [
0.2460653857,
0.2518910737,
0.25037332570000004,
0.24527269170000002,
0.24519195970000002,
0.23412275770000002,
0.2452014977,
0.25899483970000003,
0.25789505970000004,
0.25058536470000004
]
},
{
"command": "pnpr@HEAD",
"mean": 0.26959564910000006,
"stddev": 0.005714019463512499,
"median": 0.2676315932,
"user": 0.21411702,
"system": 0.53454334,
"min": 0.26060463170000003,
"max": 0.27874956770000003,
"times": [
0.27874956770000003,
0.26641509170000005,
0.27465762270000005,
0.2673723747,
0.2669515927,
0.2672371397,
0.26060463170000003,
0.27800692870000004,
0.2680707297,
0.2678908117
]
},
{
"command": "pnpr@main",
"mean": 0.26817019210000004,
"stddev": 0.005310308443750249,
"median": 0.2708519117,
"user": 0.21259492,
"system": 0.5164872400000001,
"min": 0.25882500070000003,
"max": 0.27322076770000003,
"times": [
0.2632564647,
0.2620014117,
0.25882500070000003,
0.27125808170000004,
0.26529520370000004,
0.27322076770000003,
0.27230658570000005,
0.27211901270000005,
0.2704457417,
0.2729736507
]
}
]
}Scenario: Isolated linker: fresh install, cold cache + cold store
BENCHMARK_REPORT.json{
"results": [
{
"command": "pacquet@HEAD",
"mean": 2.5931027856799997,
"stddev": 0.015288526013965803,
"median": 2.59356068568,
"user": 1.44767306,
"system": 1.3150739399999998,
"min": 2.56150754018,
"max": 2.61508053718,
"times": [
2.58245353118,
2.60771344518,
2.60426036418,
2.58687858418,
2.58520843818,
2.59130121118,
2.60080404518,
2.61508053718,
2.56150754018,
2.59582016018
]
},
{
"command": "pacquet@main",
"mean": 2.59296018218,
"stddev": 0.02681564967854741,
"median": 2.5963388516799997,
"user": 1.4393790599999998,
"system": 1.29831764,
"min": 2.5519726871799997,
"max": 2.6318211791799997,
"times": [
2.59477728618,
2.56574290618,
2.60364298018,
2.5519726871799997,
2.62939056218,
2.56265469018,
2.58758344218,
2.59790041718,
2.60411567118,
2.6318211791799997
]
},
{
"command": "pnpr@HEAD",
"mean": 1.5370376651800002,
"stddev": 0.12130432443799498,
"median": 1.49785647118,
"user": 1.0124275600000001,
"system": 1.1417868399999995,
"min": 1.42391180118,
"max": 1.80914821018,
"times": [
1.47940364918,
1.43121883918,
1.42391180118,
1.61666788518,
1.48040308218,
1.42621950518,
1.5603540271799998,
1.80914821018,
1.51530986018,
1.6277397921799999
]
},
{
"command": "pnpr@main",
"mean": 1.5992258590799997,
"stddev": 0.17976698822499645,
"median": 1.54945095568,
"user": 1.02389426,
"system": 1.1196775399999999,
"min": 1.4219316491799998,
"max": 1.86228788918,
"times": [
1.8052145181800001,
1.53302009118,
1.56588182018,
1.61641636818,
1.47366335118,
1.86228788918,
1.4331329521799998,
1.4221202551799998,
1.85858969618,
1.4219316491799998
]
}
]
}Scenario: Isolated linker: fresh install, hot cache + hot store
BENCHMARK_REPORT.json{
"results": [
{
"command": "pacquet@HEAD",
"mean": 0.39592085596,
"stddev": 0.006680856005778916,
"median": 0.39414926646000004,
"user": 0.4783182799999999,
"system": 0.72004652,
"min": 0.38823484046,
"max": 0.40800358546,
"times": [
0.39033188846,
0.39377937046,
0.38823484046,
0.39451916246,
0.39005565846,
0.39545155046,
0.40653872646,
0.40800358546,
0.39853309246,
0.39376068446
]
},
{
"command": "pacquet@main",
"mean": 0.38310514285999997,
"stddev": 0.004369662541162958,
"median": 0.38297759496,
"user": 0.4979955799999999,
"system": 0.6773980199999999,
"min": 0.37637576946,
"max": 0.39218345546,
"times": [
0.38020977846,
0.38042340146000003,
0.37637576946,
0.38581671746,
0.38601348746,
0.38232690446,
0.39218345546,
0.38362828546,
0.38422740446000003,
0.37984622446
]
},
{
"command": "pnpr@HEAD",
"mean": 0.29953024436,
"stddev": 0.00820620353122266,
"median": 0.30033289846,
"user": 0.19728067999999996,
"system": 0.51810092,
"min": 0.28660529946,
"max": 0.31144093546,
"times": [
0.28660529946,
0.29229145646,
0.28866098046,
0.29983456046,
0.30893055846,
0.30035461946,
0.30165432646,
0.31144093546,
0.30521852946,
0.30031117746
]
},
{
"command": "pnpr@main",
"mean": 0.30256025046000007,
"stddev": 0.006651999331030397,
"median": 0.30276772896000004,
"user": 0.17445038000000002,
"system": 0.5517518199999999,
"min": 0.29122885546,
"max": 0.31177577546,
"times": [
0.30706050746,
0.30743040446000003,
0.29122885546,
0.29401643646,
0.30362700246,
0.30076798846,
0.30935328546,
0.30190845546,
0.31177577546,
0.29843379346
]
}
]
}Scenario: Isolated linker: fresh install, cold cache + hot store
BENCHMARK_REPORT.json{
"results": [
{
"command": "pacquet@HEAD",
"mean": 1.72887776042,
"stddev": 0.006452310095906919,
"median": 1.72826396432,
"user": 0.7089734999999999,
"system": 0.77430084,
"min": 1.7212670243200001,
"max": 1.74016675332,
"times": [
1.73440179732,
1.7361267263200002,
1.72782870032,
1.72318548632,
1.73094690132,
1.72383961832,
1.72869922832,
1.7212670243200001,
1.72231536832,
1.74016675332
]
},
{
"command": "pacquet@main",
"mean": 1.7180064526199998,
"stddev": 0.004410075720987899,
"median": 1.71818554232,
"user": 0.7043225,
"system": 0.7442219399999999,
"min": 1.7110615173200001,
"max": 1.72540885332,
"times": [
1.7230258853200002,
1.71563121232,
1.72540885332,
1.7110615173200001,
1.71787682132,
1.71471812232,
1.7202802563200001,
1.72009642032,
1.71347117432,
1.7184942633200002
]
},
{
"command": "pnpr@HEAD",
"mean": 0.29980292322,
"stddev": 0.0054088742067792085,
"median": 0.29870205782000003,
"user": 0.18406730000000002,
"system": 0.52396194,
"min": 0.29241626032,
"max": 0.30691691532000004,
"times": [
0.29445330632000005,
0.29241626032,
0.29853348032000004,
0.30544354132,
0.29373929232,
0.30691691532000004,
0.30356215932,
0.29887063532,
0.30618483732,
0.29790880432000005
]
},
{
"command": "pnpr@main",
"mean": 0.30058239832000005,
"stddev": 0.009905966637831781,
"median": 0.29901219732000006,
"user": 0.19288619999999998,
"system": 0.52325404,
"min": 0.28331101532,
"max": 0.31903469432000003,
"times": [
0.28331101532,
0.29552129832,
0.29777290832000003,
0.31903469432000003,
0.29723805132000003,
0.30925131232,
0.30025148632000004,
0.30561103632000003,
0.29207602032,
0.30575616032
]
}
]
}Scenario: Isolated linker: fresh resolve, hot cache, offline
BENCHMARK_REPORT.json{
"results": [
{
"command": "pacquet@HEAD",
"mean": 0.1800321220215385,
"stddev": 0.013119525610075676,
"median": 0.17668314256,
"user": 0.1682755,
"system": 0.06820259230769231,
"min": 0.17067145256000002,
"max": 0.22248291956000002,
"times": [
0.22248291956000002,
0.17373107356,
0.17067145256000002,
0.18332337756,
0.17672181656,
0.18005471256,
0.17749501256,
0.17668314256,
0.17612744656,
0.17812076956,
0.17546921756,
0.17563124256,
0.17390540256
]
},
{
"command": "pacquet@main",
"mean": 0.17342504420705884,
"stddev": 0.0032518493909017543,
"median": 0.17247452856,
"user": 0.15960826470588232,
"system": 0.06897307647058822,
"min": 0.16871619056,
"max": 0.17973832656,
"times": [
0.17156450356,
0.17973832656,
0.17247452856,
0.17371263956,
0.17441137456,
0.17208333156,
0.17920801756000002,
0.17019567656,
0.17717366656,
0.17039991156,
0.17436252256,
0.16871619056,
0.17135254456000001,
0.17673218556,
0.16991910556,
0.17163477656,
0.17454644956
]
},
{
"command": "pnpr@HEAD",
"mean": 0.08685390309125,
"stddev": 0.0020761136897303584,
"median": 0.08689353356,
"user": 0.018915593750000004,
"system": 0.01032446875,
"min": 0.08259433356,
"max": 0.09162453756,
"times": [
0.08767863656,
0.08517935056,
0.08750481956,
0.08963473056,
0.08513785256,
0.08751344656,
0.08744690056,
0.08747643656,
0.08679407156,
0.08752258356,
0.08695280056,
0.08259433356,
0.08830070856,
0.08718741156,
0.08680789756,
0.08758703456,
0.08630120356,
0.08398108356,
0.08864701056,
0.08559073556,
0.08996032456,
0.08410435656,
0.09162453756,
0.08629489156,
0.08475992056000001,
0.09018261256,
0.08614151256,
0.08505029756,
0.08683426656,
0.08406949056,
0.09002412356,
0.08443951656
]
},
{
"command": "pnpr@main",
"mean": 0.08635433371625001,
"stddev": 0.0019067704817463732,
"median": 0.08677917805999999,
"user": 0.0191888125,
"system": 0.010096996874999998,
"min": 0.08235658556,
"max": 0.08918143656000001,
"times": [
0.08738978356,
0.08551653556,
0.08269533356,
0.08785879656000001,
0.08816262856,
0.08710266256,
0.08595274656,
0.08308216156,
0.08756620556,
0.08608283256,
0.08245516056,
0.08837898556,
0.08615999756,
0.08298378656,
0.08235658556,
0.08334930556,
0.08658964656,
0.08755580556,
0.08752430656,
0.08918143656000001,
0.08618113756,
0.08647081256,
0.08785769456,
0.08708629156,
0.08830975556,
0.08656193456,
0.08758937956,
0.08667188056,
0.08688647556,
0.08773813856,
0.08774539356,
0.08629508156
]
}
]
}Scenario: Isolated linker: peer-heavy resolve, hot cache, offline
BENCHMARK_REPORT.json{
"results": [
{
"command": "pacquet@HEAD",
"mean": 0.7934521282777778,
"stddev": 0.1767249451973417,
"median": 0.7836260355,
"user": 0.7375264933333332,
"system": 0.16867620444444442,
"min": 0.5541144385,
"max": 1.1376802225,
"times": [
0.7836260355,
0.9320211915000001,
1.1376802225,
0.6259164395,
0.7172114185,
0.8143647405000001,
0.6870623345,
0.5541144385,
0.8890723335
]
},
{
"command": "pacquet@main",
"mean": 0.8590639028333333,
"stddev": 0.26487579731797095,
"median": 0.7102249835,
"user": 0.8069269377777776,
"system": 0.1756952044444444,
"min": 0.5848340765,
"max": 1.2639900474999999,
"times": [
0.5848340765,
1.0421056535,
0.7009514185,
1.2627604024999999,
0.7102249835,
0.8423778625,
1.2639900474999999,
0.6439707785000001,
0.6803599025
]
},
{
"command": "pnpm@HEAD",
"mean": 2.9097861530555558,
"stddev": 0.057324624085112984,
"median": 2.9225005385,
"user": 4.409064271111111,
"system": 0.2736854266666666,
"min": 2.8049659665,
"max": 2.9759115775000002,
"times": [
2.9558061755000002,
2.9759115775000002,
2.8435558355,
2.8049659665,
2.8761131755,
2.9225005385,
2.9592158675,
2.9144478935,
2.9355583475
]
}
]
}Scenario: Isolated linker: fresh restore, cold cache + cold store + cold pnpr
BENCHMARK_REPORT.json{
"results": [
{
"command": "pacquet@HEAD",
"mean": 4.52848711956,
"stddev": 0.1210657301776986,
"median": 4.51074347926,
"user": 1.6739746999999998,
"system": 1.3362377799999998,
"min": 4.40937669826,
"max": 4.78382387026,
"times": [
4.40937669826,
4.54868334826,
4.52066771226,
4.68518325826,
4.40959594926,
4.432125543260001,
4.52350480326,
4.471090766260001,
4.78382387026,
4.50081924626
]
},
{
"command": "pacquet@main",
"mean": 4.60163923146,
"stddev": 0.14485070126355393,
"median": 4.58973266226,
"user": 1.6748655999999997,
"system": 1.3494045799999999,
"min": 4.41009724426,
"max": 4.83227446326,
"times": [
4.66355986026,
4.64789925026,
4.81528537426,
4.56430319826,
4.58726961426,
4.83227446326,
4.41009724426,
4.59219571026,
4.43284838626,
4.47065921326
]
},
{
"command": "pnpr@HEAD",
"mean": 3.5291315288600003,
"stddev": 0.08464733027010335,
"median": 3.4981249987600003,
"user": 1.1646985,
"system": 1.21124778,
"min": 3.4512794062600003,
"max": 3.6851423062600004,
"times": [
3.4512794062600003,
3.4600011902600003,
3.4528434812600004,
3.6851423062600004,
3.51135032126,
3.60563915126,
3.4848996762600004,
3.6231553352600003,
3.56174547726,
3.45525894326
]
},
{
"command": "pnpr@main",
"mean": 3.56431947396,
"stddev": 0.1363802110906505,
"median": 3.4886830907600004,
"user": 1.1761171,
"system": 1.20479738,
"min": 3.42778504826,
"max": 3.80000669026,
"times": [
3.80000669026,
3.4995352752600004,
3.5993033112600004,
3.45350781526,
3.4778309062600004,
3.42778504826,
3.4661152142600002,
3.47408630426,
3.7322506652600005,
3.7127735092600003
]
}
]
} |
|
| Project | pnpm's project |
| Branch | pr/13587 |
| 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,423.91 ms |
| isolated-linker.fresh-install.cold-cache.hot-store | 📈 view plot | 292.42 ms |
| isolated-linker.fresh-install.hot-cache.hot-store | 📈 view plot | 286.61 ms |
| isolated-linker.fresh-resolve.hot-cache.offline | 📈 view plot | 82.59 ms |
| isolated-linker.fresh-restore.cold-cache.cold-store | 📈 view plot | 1,357.12 ms |
| isolated-linker.fresh-restore.cold-cache.cold-store.cold-pnpr | 📈 view plot | 3,451.28 ms |
| isolated-linker.fresh-restore.hot-cache.hot-store | 📈 view plot | 260.60 ms |
Summary
Deciding whether a missing-peer issue is already covered by another
importer's walk scans the issue's ancestor chain for a package that
importer owns. That scan ran per issue, and the issues reported for
one peer come from occurrences spread through the tree whose ancestor
chains share long suffixes — so the same suffix was rescanned once per
issue.
SharedChainis a cons-list whose links are shared, which is exactlywhat makes the rescan avoidable: the answer for a link covers that link
and everything above it, for every chain built on it.
any_memoizedrecords the answer per link, so the total cost is the number of distinct
links rather than the sum over chains. A suffix that already matched
spares each branch's own tip as well, since the fold short-circuits.
Per importer this takes
O(issues × depth)toO(distinct links). Theissue count grows with the workspace, so the removed term is superlinear
in workspace size — multiplied by chain depth, which is what decides
whether it is visible.
Only the post-round scope filter memoizes, per peer name. I first
memoized the walk's own suppression check too; reviewers found that
unsound — a memo keyed on
Arc::as_ptroutliving its links can answerfor whatever is allocated at that address next, and a walk allocates and
drops chain links throughout. That memo is gone, and measurement says
the walk never wanted it anyway (the fixture is faster without it). The
memo that remains holds an
Arcto every link it keys on, so an entrycannot outlive its link's address.
Measurements
Output is unchanged; 7,565 workspace tests pass.
I want to be straight about the last two rows. The win needs chains
deeper than either realistic workload has — deeper even than the
pathological chain from #13574, which was 15–26 packages. So
this is not a change users will time. What it buys is the removal of a
term that scales with the issue count, and the guarantee that a
deep-chain workspace cannot pay it quadratically. It measured
equal-or-better everywhere and slower nowhere.
The CI gate added in #13581 does register it — 3%, at its own
0.3% variance — though my local runs of that size were too noisy to see
it. Deepening its fixture to 150 layers separates the builds much more
clearly (573ms vs 663ms) but triples that group's cost on every PR,
which I did not think this was worth.
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.
Written by an agent (Claude Code, claude-opus-5).
Summary by CodeRabbit
Performance
Bug Fixes
Tests