Repository navigation
perf(resolver): make multi-importer peer-hoist discovery linear - #13491
Conversation
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: Path: .coderabbit.yaml Review profile: CHILL Plan: Pro Plus Run ID: 📒 Files selected for processing (5)
🚧 Files skipped from review as they are similar to previous changes (2)
📝 WalkthroughWalkthroughWorkspace peer-hoist resolution now performs persistent graph-free discovery with incremental synchronization and importer-scoped snapshots. Required rounds reuse discovery state and version cursors. A large-workspace benchmark, regression tests, release note, and deploy stderr normalization were added. ChangesWorkspace peer-hoist discovery
Deploy error-output test normalization
Estimated code review effort: 4 (Complex) | ~60 minutes Sequence Diagram(s)sequenceDiagram
participant resolve_workspace
participant ImporterHoistState
participant PeerHoistDiscovery
participant WorkspaceTreeCtx
resolve_workspace->>PeerHoistDiscovery: create shared discovery engine
resolve_workspace->>ImporterHoistState: execute required round
ImporterHoistState->>PeerHoistDiscovery: discover peer issues and providers
ImporterHoistState->>WorkspaceTreeCtx: read newly resolved versions
ImporterHoistState-->>resolve_workspace: apply hoisted providers and repeat
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 |
Micro-Benchmark ResultsLinux |
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## main #13491 +/- ##
========================================
Coverage 87.92% 87.93%
========================================
Files 549 549
Lines 95561 95872 +311
========================================
+ Hits 84018 84301 +283
- Misses 11543 11571 +28 ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
Integrated-Benchmark Report (Linux)Commit: Each scenario reports direct installs and pnpr installs. 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.6262860409,
"stddev": 0.13774241590139713,
"median": 2.6466960695,
"user": 1.9514065799999998,
"system": 1.5210219999999999,
"min": 2.4142172005,
"max": 2.8019152785,
"times": [
2.6931373115,
2.4890583295,
2.7215094045,
2.7092272294999997,
2.7861772184999998,
2.5884606505,
2.4589029585,
2.4142172005,
2.8019152785,
2.6002548275
]
},
{
"command": "pacquet@main",
"mean": 2.5641089590999995,
"stddev": 0.15623489046700137,
"median": 2.5166234725,
"user": 1.7219431800000002,
"system": 1.3823902,
"min": 2.3937466955,
"max": 2.7810623144999997,
"times": [
2.7588407745,
2.5314860605,
2.3937466955,
2.4057643465,
2.5941566295,
2.5017608845,
2.7810623144999997,
2.4989670045,
2.7739211304999998,
2.4013837505
]
},
{
"command": "pnpr@HEAD",
"mean": 1.6173187580000001,
"stddev": 0.17781551908374485,
"median": 1.6154905065,
"user": 1.25090028,
"system": 1.3341404999999997,
"min": 1.3806070995,
"max": 1.8175668645,
"times": [
1.8151251275,
1.5557886834999999,
1.3960962715,
1.7941869335,
1.3806070995,
1.8175668645,
1.5853914615,
1.6455895515,
1.4151535655,
1.7676820215
]
},
{
"command": "pnpr@main",
"mean": 1.5260904274000002,
"stddev": 0.1416212315618846,
"median": 1.497962256,
"user": 1.2143393799999997,
"system": 1.3140443999999998,
"min": 1.3750111505,
"max": 1.7814699704999999,
"times": [
1.5179202715,
1.4502312335,
1.7814699704999999,
1.7451239345,
1.4780042405,
1.4055222415,
1.5493832895000001,
1.5709456895,
1.3872922525,
1.3750111505
]
}
]
}Scenario: Isolated linker: fresh restore, hot cache + hot store
BENCHMARK_REPORT.json{
"results": [
{
"command": "pacquet@HEAD",
"mean": 0.3188593638800001,
"stddev": 0.02931798542031895,
"median": 0.30956920048000003,
"user": 0.27456610000000004,
"system": 0.6071104,
"min": 0.28917209648000003,
"max": 0.37506645848000003,
"times": [
0.37506645848000003,
0.34904421448000006,
0.32434321948000006,
0.31615235648,
0.30298604448000005,
0.29202925548,
0.28917209648000003,
0.29282583848000004,
0.34644800548000004,
0.30052614948
]
},
{
"command": "pacquet@main",
"mean": 0.27975280018000004,
"stddev": 0.012703376286417326,
"median": 0.27444179048000006,
"user": 0.2317868,
"system": 0.5572121,
"min": 0.26450238948000004,
"max": 0.30084668148000004,
"times": [
0.28579052448000003,
0.26838079348000005,
0.30084668148000004,
0.27303312948,
0.27448059348000003,
0.27440298748,
0.26450238948000004,
0.26924586548,
0.29684229248000005,
0.29000274448
]
},
{
"command": "pnpr@HEAD",
"mean": 0.29742348758000003,
"stddev": 0.012485160972571303,
"median": 0.29713919798,
"user": 0.24889260000000002,
"system": 0.5602288,
"min": 0.28130052348,
"max": 0.32158890348,
"times": [
0.30714646648000005,
0.28615789348000004,
0.29237292948000004,
0.28130052348,
0.28279404448,
0.30495588848000005,
0.29602663148,
0.29825176448,
0.30363983048000004,
0.32158890348
]
},
{
"command": "pnpr@main",
"mean": 0.31498857238,
"stddev": 0.02641536386798515,
"median": 0.31300854098,
"user": 0.2721787,
"system": 0.5974778,
"min": 0.27666910748,
"max": 0.36713561448000004,
"times": [
0.30552782148,
0.31297050948000005,
0.31705334648000005,
0.31304657248,
0.29191221548,
0.29237839948000005,
0.33915816348000005,
0.36713561448000004,
0.33403397348,
0.27666910748
]
}
]
}Scenario: Isolated linker: fresh install, cold cache + cold store
BENCHMARK_REPORT.json{
"results": [
{
"command": "pacquet@HEAD",
"mean": 2.7063385664400004,
"stddev": 0.009714354021915388,
"median": 2.70757871684,
"user": 1.7392925599999998,
"system": 1.38616978,
"min": 2.6910397893400004,
"max": 2.72379121334,
"times": [
2.6959309423400004,
2.70566808334,
2.70245210234,
2.70948935034,
2.72379121334,
2.6910397893400004,
2.6992191993400003,
2.70963796934,
2.7165745993400003,
2.7095824153400003
]
},
{
"command": "pacquet@main",
"mean": 2.8071581334400006,
"stddev": 0.039687195338023486,
"median": 2.8029365168400004,
"user": 1.8359317599999998,
"system": 1.34521048,
"min": 2.75209752634,
"max": 2.8939667203400004,
"times": [
2.8062470273400004,
2.7771262513400004,
2.75209752634,
2.7996260063400005,
2.81401512034,
2.78098742534,
2.8453757693400004,
2.8939667203400004,
2.81489244534,
2.78724704234
]
},
{
"command": "pnpr@HEAD",
"mean": 1.60162576874,
"stddev": 0.10934165083412299,
"median": 1.58123233934,
"user": 1.15228956,
"system": 1.24741238,
"min": 1.4733673483399998,
"max": 1.83799399134,
"times": [
1.57718732834,
1.63622383834,
1.4733673483399998,
1.83799399134,
1.53078625534,
1.56813849034,
1.58527735034,
1.48791555134,
1.59882505534,
1.7205424783399998
]
},
{
"command": "pnpr@main",
"mean": 1.5546691969400002,
"stddev": 0.07931858661202044,
"median": 1.5570471213400001,
"user": 1.1906818599999998,
"system": 1.26205708,
"min": 1.44122643634,
"max": 1.65980305634,
"times": [
1.55803069534,
1.51957724434,
1.44122643634,
1.6422507603399998,
1.65980305634,
1.62589723334,
1.45710708634,
1.47651699634,
1.61021891334,
1.55606354734
]
}
]
}Scenario: Isolated linker: fresh install, hot cache + hot store
BENCHMARK_REPORT.json{
"results": [
{
"command": "pacquet@HEAD",
"mean": 0.56222773104,
"stddev": 0.020421005998196774,
"median": 0.5685308989400001,
"user": 0.7290276,
"system": 0.71712968,
"min": 0.5234867189400001,
"max": 0.58574712494,
"times": [
0.57153168594,
0.5829433569400001,
0.58146176794,
0.58574712494,
0.5479583199400001,
0.5234867189400001,
0.5700486749400001,
0.5470240079400001,
0.5670131229400001,
0.54506252994
]
},
{
"command": "pacquet@main",
"mean": 0.65089690264,
"stddev": 0.01469827414409172,
"median": 0.6458189899400001,
"user": 0.8035876,
"system": 0.70642138,
"min": 0.63334790894,
"max": 0.6780230669400001,
"times": [
0.6444117459400001,
0.6703848229400001,
0.6359688439400001,
0.63334790894,
0.6613266859400001,
0.6524645069400001,
0.6470315589400001,
0.6446064209400001,
0.6780230669400001,
0.6414034649400001
]
},
{
"command": "pnpr@HEAD",
"mean": 0.34764361974,
"stddev": 0.025784462739360577,
"median": 0.35114024894,
"user": 0.2337075,
"system": 0.5973638799999998,
"min": 0.29984588294000003,
"max": 0.37987574094000004,
"times": [
0.31925684394000003,
0.34409286794,
0.35095244194,
0.29984588294000003,
0.32537801294,
0.37987574094000004,
0.37069031594,
0.36820697794,
0.35132805594,
0.36680905694
]
},
{
"command": "pnpr@main",
"mean": 0.32563001733999997,
"stddev": 0.0197372583706814,
"median": 0.32015222294,
"user": 0.21599580000000002,
"system": 0.55897318,
"min": 0.30433186494000003,
"max": 0.36396040594,
"times": [
0.36396040594,
0.35685877794000004,
0.32057576694,
0.30433186494000003,
0.32573893994,
0.31972867894,
0.30993538294,
0.32799612194,
0.31191337394,
0.31526085994
]
}
]
}Scenario: Isolated linker: fresh install, cold cache + hot store
BENCHMARK_REPORT.json{
"results": [
{
"command": "pacquet@HEAD",
"mean": 1.8803399920399997,
"stddev": 0.03921164828872728,
"median": 1.87524439474,
"user": 1.0073402599999999,
"system": 0.76971874,
"min": 1.83210955574,
"max": 1.96284321674,
"times": [
1.84760406274,
1.8788730097400002,
1.87886276074,
1.8580403647400001,
1.83210955574,
1.90328635174,
1.87162602874,
1.96284321674,
1.9203222987400002,
1.8498322707400001
]
},
{
"command": "pacquet@main",
"mean": 1.9814574578400002,
"stddev": 0.01498932158302224,
"median": 1.9781747632400002,
"user": 1.1334515599999997,
"system": 0.77162494,
"min": 1.96013116074,
"max": 2.00727862574,
"times": [
2.00727862574,
2.0044219297400003,
1.98660200074,
1.97598821774,
1.98036130874,
1.9686383547400002,
1.97351025974,
1.98491403574,
1.97272868474,
1.96013116074
]
},
{
"command": "pnpr@HEAD",
"mean": 0.33266298924000004,
"stddev": 0.013180462568632445,
"median": 0.33615683074,
"user": 0.22136256000000004,
"system": 0.5590070399999999,
"min": 0.30962102374000006,
"max": 0.35173050074000006,
"times": [
0.35173050074000006,
0.33989834274,
0.33897501174000005,
0.34556263474000004,
0.33839253874,
0.33392112274,
0.30962102374000006,
0.31524302774,
0.32683826074000005,
0.32644742874000005
]
},
{
"command": "pnpr@main",
"mean": 0.3287763845400001,
"stddev": 0.014410528188978942,
"median": 0.32749107074000006,
"user": 0.22935626,
"system": 0.56052934,
"min": 0.30841350874,
"max": 0.34741253374000003,
"times": [
0.32542916874000005,
0.34741253374000003,
0.31380220474000003,
0.31699440074,
0.30841350874,
0.31895691074000004,
0.34456618574000003,
0.32955297274000006,
0.33532440474,
0.34731155474000003
]
}
]
}Scenario: Isolated linker: fresh resolve, hot cache, offline
BENCHMARK_REPORT.json{
"results": [
{
"command": "pacquet@HEAD",
"mean": 0.36376410554000005,
"stddev": 0.020873125182456573,
"median": 0.36199744854000004,
"user": 0.35433966,
"system": 0.07793537999999998,
"min": 0.33749501904,
"max": 0.40401749104,
"times": [
0.33749501904,
0.34888012204,
0.37385172504,
0.37448502304000003,
0.34425670004000003,
0.38421874004,
0.36779847304,
0.40401749104,
0.34644133804000005,
0.35619642404
]
},
{
"command": "pacquet@main",
"mean": 0.51087304444,
"stddev": 0.054391988580523354,
"median": 0.5048129935400001,
"user": 0.5022711599999999,
"system": 0.07709337999999999,
"min": 0.44534259404000004,
"max": 0.5968631160400001,
"times": [
0.48139920704000005,
0.44695232304000004,
0.46921637904,
0.58149118604,
0.47737660204000004,
0.5968631160400001,
0.5282267800400001,
0.44534259404000004,
0.5448654270400001,
0.5369968300400001
]
},
{
"command": "pnpr@HEAD",
"mean": 0.10107652693285714,
"stddev": 0.0126946738009862,
"median": 0.09593073854,
"user": 0.02866771000000001,
"system": 0.013605279999999999,
"min": 0.09067342404,
"max": 0.14127303204,
"times": [
0.09852452804,
0.13745417904,
0.11030975104,
0.09760118704000001,
0.09545036204,
0.09804615104,
0.09467855404,
0.09292331304,
0.10422413704,
0.09291849304000001,
0.09489212504,
0.09086099504,
0.09309974304,
0.09334298004000001,
0.14127303204,
0.11075361404,
0.10000437304,
0.09265403704,
0.09067342404,
0.09251031904,
0.10970273304,
0.10503971604000001,
0.09602127304000001,
0.09452557804,
0.09254167704,
0.09883697404,
0.09584020404,
0.11543930104000001
]
},
{
"command": "pnpr@main",
"mean": 0.10406136665538462,
"stddev": 0.019233717039577006,
"median": 0.09683677304,
"user": 0.031347536923076916,
"system": 0.013546356923076923,
"min": 0.08883034704000001,
"max": 0.15966950304,
"times": [
0.10629489104,
0.08883034704000001,
0.09400850904000001,
0.09522208404,
0.09734605804,
0.10649098804,
0.14955901204,
0.09602287604000001,
0.10022210104,
0.09581664004,
0.09216131404,
0.09452478704,
0.09868388604,
0.09914971004,
0.09881828804000001,
0.09670004704,
0.09294302004,
0.09661787204,
0.10050807804,
0.12379739604000001,
0.14919325504,
0.09195980604000001,
0.09149328004,
0.09258828504000001,
0.09697349904000001,
0.15966950304
]
}
]
}Scenario: Isolated linker: fresh restore, cold cache + cold store + cold pnpr
BENCHMARK_REPORT.json{
"results": [
{
"command": "pacquet@HEAD",
"mean": 4.700944708120001,
"stddev": 0.154054401086469,
"median": 4.69708385702,
"user": 2.5619976,
"system": 1.7813388600000004,
"min": 4.50538950002,
"max": 4.9318777450199995,
"times": [
4.70823665202,
4.9059934390199995,
4.571727303019999,
4.9318777450199995,
4.71558264802,
4.68593106202,
4.61960368902,
4.84912839302,
4.51597665002,
4.50538950002
]
},
{
"command": "pacquet@main",
"mean": 4.5661516107199995,
"stddev": 0.11597365812124254,
"median": 4.52844129752,
"user": 2.0540413,
"system": 1.5165134599999999,
"min": 4.46803383102,
"max": 4.819625450019999,
"times": [
4.53246724102,
4.475508245019999,
4.57025078502,
4.58314636102,
4.49184426002,
4.47934788102,
4.46803383102,
4.524415354019999,
4.716876699019999,
4.819625450019999
]
},
{
"command": "pnpr@HEAD",
"mean": 3.70167975912,
"stddev": 0.12449259457617189,
"median": 3.69128114952,
"user": 1.6449376,
"system": 1.5827577600000002,
"min": 3.49692158202,
"max": 3.8978502770200003,
"times": [
3.77926597102,
3.49692158202,
3.78428503602,
3.5991433170200002,
3.8978502770200003,
3.60901517602,
3.68108001702,
3.8448622450200003,
3.62289168802,
3.70148228202
]
},
{
"command": "pnpr@main",
"mean": 3.589638435220001,
"stddev": 0.037732075576824814,
"median": 3.59177993252,
"user": 1.6879863999999998,
"system": 1.57865216,
"min": 3.52313357502,
"max": 3.64029219702,
"times": [
3.60189239402,
3.63182182302,
3.57786543602,
3.55415685402,
3.58663304602,
3.62665762702,
3.52313357502,
3.59692681902,
3.55700458102,
3.64029219702
]
}
]
} |
|
| Project | pnpm's project |
| Branch | pr/13491 |
| 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,473.37 ms |
| isolated-linker.fresh-install.cold-cache.hot-store | 📈 view plot | 309.62 ms |
| isolated-linker.fresh-install.hot-cache.hot-store | 📈 view plot | 299.85 ms |
| isolated-linker.fresh-resolve.hot-cache.offline | 📈 view plot | 90.67 ms |
| isolated-linker.fresh-restore.cold-cache.cold-store | 📈 view plot | 1,380.61 ms |
| isolated-linker.fresh-restore.cold-cache.cold-store.cold-pnpr | 📈 view plot | 3,496.92 ms |
| isolated-linker.fresh-restore.hot-cache.hot-store | 📈 view plot | 281.30 ms |
miette wraps the report at a point that depends on the temp path length, so a phrase assertion like "contains a symlink" fails whenever the wrap lands inside the phrase — the continuation gutter glyph also lands between the words, so plain whitespace-collapsing is not enough. Strip the box-drawing tokens and collapse the report onto one line before matching, in all four deploy-target assertions. Co-Authored-By: Claude Fable 5 <[email protected]>
The auto-install-peers hoist loop cloned the workspace tree and ran a full peer pass — DependenciesGraph construction included — once per importer per round, making a from-scratch resolve of a large component workspace quadratic in both time and memory. Replace the per-round snapshot + full pass with a PeerHoistDiscovery engine shared by every hoist round of one workspace resolve: - discovery walks share one persistent tree view, incrementally synced from the workspace context (rebuilt from scratch when a children-owner change rewrites recorded children or a peer split); - the walker's purePkgs / peersCache / parent-context maps persist across rounds and importers, so a subtree settled by one importer's pass short-circuits every compatible revisit — the same sharing the final resolve_peers_workspace pass already applies within one call; - discovery skips graph construction entirely: the hoist loop only consumes missing peers and resolved providers, and each peers-cache item now carries its subtree's per-package missing breakdown so the owner-scope report stays exact under cross-round cache hits. Also drop the remaining per-importer O(workspace) costs in the initial barrier: record_first_walk_missing no longer deep-clones the children-owner map, the preferred-versions fold reads an append-only resolved-versions log through a per-importer cursor, and the owner-scope maps are snapshotted once per barrier instead of once per importer. cargo bench -p pacquet-resolving-deps-resolver --bench workspace_full_resolution (331 importers, 5,000 shared packages, peer hoisting, no lockfile): - before: 65.1s resolver time, 3.76 GiB peak RSS - after: 1.55s resolver time, 1.14 GiB peak RSS Co-Authored-By: Claude Fable 5 <[email protected]>
…aining caller Co-Authored-By: Claude Fable 5 <[email protected]>
PR Summary by Qodoperf(resolver): make multi-importer peer-hoist discovery linear
AI Description
Diagram
High-Level Assessment
Files changed (12)
|
Confidence Score: 5/5The PR appears safe to merge. No blocking failure remains. Reviews (2): Last reviewed commit: "style(resolver): apply cargo fmt" | Re-trigger Greptile |
Code Review by Qodo
Context used✅ Compliance rules (platform):
24 rules 1. Rewrite invalidation footgun
|
There was a problem hiding this comment.
Actionable comments posted: 2
🧹 Nitpick comments (3)
pnpm/crates/resolving-deps-resolver/src/resolve_dependency_tree.rs (1)
913-970: 🩺 Stability & Availability | 🔵 Trivial | 💤 Low valueLock acquisition order is the reverse of
snapshot()forpackages/dependencies_tree.
snapshot(Line 888) acquirespackagesbeforedependencies_tree;snapshot_reachable_fromholds thedependencies_treeguard (it is shadowed at Line 932, not dropped) and then takespackagesat Line 955. Today both are only called from the sequential orchestrator, so this cannot deadlock, but the file documents lock order elsewhere (record_first_walk_missing). Consider either dropping thedependencies_treeguard explicitly after Line 937 (mirroring thedrop(all_children)you already do) or recording the single-caller invariant.♻️ Drop the guard once the filtered map is built
- let dependencies_tree: HashMap<_, _> = reachable_node_ids - .iter() - .filter_map(|node_id| { - dependencies_tree.get(node_id).cloned().map(|node| (node_id.clone(), node)) - }) - .collect(); + let reachable_dependencies_tree: HashMap<_, _> = reachable_node_ids + .iter() + .filter_map(|node_id| { + dependencies_tree.get(node_id).cloned().map(|node| (node_id.clone(), node)) + }) + .collect(); + drop(dependencies_tree); + let dependencies_tree = reachable_dependencies_tree;🤖 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_dependency_tree.rs` around lines 913 - 970, Update snapshot_reachable_from so the dependencies_tree lock guard is explicitly dropped immediately after the filtered dependencies_tree map is constructed and before acquiring the packages lock. Preserve the existing reachable-tree collection logic and mirror the explicit drop(all_children) pattern already used in the function.pnpm/crates/resolving-deps-resolver/src/resolve_peers.rs (1)
1575-1582: 📐 Maintainability & Code Quality | 🔵 Trivial | 💤 Low value
Arc::unwrap_or_cloneexpresses this take-or-clone more directly.♻️ Suggested simplification
- let mut merged = match subtree_missing_by_pkg.take() { - Some(arc) => Arc::try_unwrap(arc).unwrap_or_else(|shared| (*shared).clone()), - None => HashMap::new(), - }; + let mut merged = subtree_missing_by_pkg.take().map(Arc::unwrap_or_clone).unwrap_or_default();🤖 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 1575 - 1582, In the subtree_missing_by_pkg merge logic, replace the manual Arc::try_unwrap(...).unwrap_or_else(...) pattern with Arc::unwrap_or_clone while preserving the existing HashMap fallback and subsequent entry extension behavior.pnpm/crates/resolving-deps-resolver/src/resolve_dependency_tree/tests.rs (1)
50-91: 📐 Maintainability & Code Quality | 🔵 Trivial | ⚡ Quick winConsider covering the lazy-edge package closure too.
The fixture has empty
packages/children_by_id, so the second half ofsnapshot_reachable_from(walkingchildren_by_idto include packages only reachable through lazy edges, and excluding a foreign importer's package) is untested — the part most likely to regress.🤖 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_dependency_tree/tests.rs` around lines 50 - 91, Extend importer_snapshot_excludes_other_importers_occurrence_nodes to populate packages and children_by_id with a lazy-edge package reachable from root, plus a package belonging only to the unrelated importer. Assert the snapshot includes the lazily reachable package and excludes the foreign importer's package, covering the second traversal in snapshot_reachable_from while preserving the existing dependency-tree assertions.
🤖 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 @.changeset/workspace-hoist-discovery-linear.md:
- Line 5: Rewrite the changeset entry to describe the user-visible improvement:
large multi-project workspaces now resolve from scratch faster and with lower
resource usage. Remove references to resolver internals, implementation details,
and run-specific benchmark figures.
In `@pnpm/crates/resolving-deps-resolver/src/resolve_dependency_tree.rs`:
- Around line 1121-1135: Update sync_discovery_tree’s occupied dependencies_tree
merge to account for children changes, not only the minimum depth. When an
existing node’s children shape differs from the shared node, either return false
to reject the merge or replace the discovery node’s children with the newer
value, ensuring Realized-to-Lazy transitions from make_non_owner_nodes_lazy are
reflected.
---
Nitpick comments:
In `@pnpm/crates/resolving-deps-resolver/src/resolve_dependency_tree.rs`:
- Around line 913-970: Update snapshot_reachable_from so the dependencies_tree
lock guard is explicitly dropped immediately after the filtered
dependencies_tree map is constructed and before acquiring the packages lock.
Preserve the existing reachable-tree collection logic and mirror the explicit
drop(all_children) pattern already used in the function.
In `@pnpm/crates/resolving-deps-resolver/src/resolve_dependency_tree/tests.rs`:
- Around line 50-91: Extend
importer_snapshot_excludes_other_importers_occurrence_nodes to populate packages
and children_by_id with a lazy-edge package reachable from root, plus a package
belonging only to the unrelated importer. Assert the snapshot includes the
lazily reachable package and excludes the foreign importer's package, covering
the second traversal in snapshot_reachable_from while preserving the existing
dependency-tree assertions.
In `@pnpm/crates/resolving-deps-resolver/src/resolve_peers.rs`:
- Around line 1575-1582: In the subtree_missing_by_pkg merge logic, replace the
manual Arc::try_unwrap(...).unwrap_or_else(...) pattern with
Arc::unwrap_or_clone while preserving the existing HashMap fallback and
subsequent entry extension behavior.
🪄 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: 50a4490a-9dc4-45e7-bec9-ea1f5591286e
📒 Files selected for processing (12)
.changeset/workspace-hoist-discovery-linear.mdpnpm/crates/cli/tests/deploy.rspnpm/crates/resolving-deps-resolver/Cargo.tomlpnpm/crates/resolving-deps-resolver/benches/workspace_full_resolution.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_importer.rspnpm/crates/resolving-deps-resolver/src/resolve_peers.rspnpm/crates/resolving-deps-resolver/src/resolve_peers/tests.rspnpm/crates/resolving-deps-resolver/src/resolve_workspace.rspnpm/crates/resolving-deps-resolver/src/resolved_tree.rs
PR Code Suggestions ✨Warning
|
|||||||||||
…rewrite A children-ownership handover rewrites existing occurrence nodes' children in the shared context (make_non_owner_nodes_lazy), which the discovery engine's incremental sync could not see: an owner re-recording an equal child list re-points the children_by_id Arc without content drift, leaving the engine walking realized children and cache verdicts derived before the rewrite. Track such rewrites with a counter on the workspace context and discard the engine's whole view when it advanced since the last sync. Also apply review nitpicks: release the dependencies_tree guard in snapshot_reachable_from before taking packages so the function never holds two context locks at once, use Arc::unwrap_or_clone for the subtree-missing merge, cover the lazy-edge package closure of snapshot_reachable_from with a test, and reword the changeset to stay user-facing. Co-Authored-By: Claude Fable 5 <[email protected]>
Co-Authored-By: Claude Fable 5 <[email protected]>
|
The review nitpicks are addressed in 14eb7da as well: Written by an agent (Claude Code, claude-fable-5). |
Summary
Fixes the multi-importer full-resolution regression observed when pnpm is used through
@pnpm/napiby Bit.PeerHoistDiscoveryengine shared by every hoist round of one workspace resolve: one persistent tree view incrementally synced from the workspace context, plus persistent walker caches (purePkgs,peersCache, parent contexts) so a subtree settled by one importer's pass short-circuits every compatible revisit — the same sharing the finalresolve_peers_workspacepass already applies within its single callDependenciesGraphconstruction entirely; the hoist loop only consumes missing peers and resolved providers, and each peers-cache item carries its subtree's per-package missing breakdown so the owner-scope report stays exact under cross-round cache hitsrecord_first_walk_missing, the whole-packagesrescan in the preferred-versions fold (now an append-only log read through a per-importer cursor), and the per-importer owner-scope map clones (now snapshotted once per barrier)Benchmark (
cargo bench -p pacquet-resolving-deps-resolver --bench workspace_full_resolution):On the real Bit workspace driven through
@pnpm/napi, a warm repeatbd installdrops from ~4 minutes to ~65 s total, of which the engine accounts for 1.5 s (frozen path); the rest is Bit's own component loading and compilation.This is a pure engine-side performance fix with no user-visible behavior change, so no TypeScript-side port is needed.
Squash Commit Body
Checklist
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-fable-5).
Need help on this PR? Tag
@codesmith-botwith what you need. Autofix is disabled.