Repository navigation
perf(resolving-deps-resolver): amortize the per-importer workspace scans in the hoist loop - #13579
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 (9)
🚧 Files skipped from review as they are similar to previous changes (9)
📝 WalkthroughWalkthroughPeer discovery now retains shared missing summaries and indexes names without eagerly cloning maps. Workspace ownership and missing-peer data use cached ChangesWorkspace peer-resolution optimization
Estimated code review effort: 4 (Complex) | ~45 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 |
PR Summary by QodoPerf: amortize peer-hoist workspace scans via shared snapshots and missing-peer indexing
AI Description
Diagram
High-Level Assessment
Files changed (9)
|
Confidence Score: 5/5The PR appears safe to merge. No blocking failure remains. Reviews (2): Last reviewed commit: "test(resolving-deps-resolver): cover the..." | Re-trigger Greptile |
Code Review by Qodo
Context used✅ Compliance rules (platform):
24 rules 1. Quadratic summary dedupe
|
PR Code Suggestions ✨Warning
No code suggestions found for the PR. |
Micro-Benchmark ResultsLinux |
|
The one flagged rule violation — "Changeset missing pnpm entry" — is expected here. Written by an agent (Claude Code, claude-opus-5). |
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main pnpm/pnpm#13579 +/- ##
==========================================
- Coverage 87.99% 87.99% -0.01%
==========================================
Files 563 563
Lines 97561 97596 +35
==========================================
+ Hits 85853 85877 +24
- Misses 11708 11719 +11 ☔ 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.4965431648,
"stddev": 0.16139021369699835,
"median": 2.435066331,
"user": 1.53237892,
"system": 1.3166689000000003,
"min": 2.3581421175,
"max": 2.7911002555,
"times": [
2.7911002555,
2.3768145124999998,
2.5495614014999997,
2.3776473234999997,
2.5081076884999995,
2.3693566534999997,
2.3581421175,
2.7645690335,
2.4075566955,
2.4625759664999998
]
},
{
"command": "pacquet@main",
"mean": 2.5547045332,
"stddev": 0.1570805154650583,
"median": 2.5569458435,
"user": 1.51081772,
"system": 1.3087678999999999,
"min": 2.3613116885,
"max": 2.8073625205,
"times": [
2.8073625205,
2.7829215554999998,
2.5516008665,
2.6084344785,
2.3838087385,
2.4289640095,
2.3613116885,
2.6291076964999998,
2.4312429575,
2.5622908205
]
},
{
"command": "pnpr@HEAD",
"mean": 1.4578140936,
"stddev": 0.10099576296681619,
"median": 1.432282279,
"user": 1.06436592,
"system": 1.1432426999999998,
"min": 1.3414031745000001,
"max": 1.6223735705,
"times": [
1.3581301775,
1.5211270295,
1.5976781355,
1.6223735705,
1.3414031745000001,
1.4133746875,
1.4446778865,
1.4198866715,
1.5088046905,
1.3506849125
]
},
{
"command": "pnpr@main",
"mean": 1.5373880469,
"stddev": 0.14442125123452096,
"median": 1.5137679130000001,
"user": 1.0695690199999999,
"system": 1.1607421,
"min": 1.3780521365,
"max": 1.7961039655000002,
"times": [
1.3877047565,
1.6944624155,
1.4166776775,
1.3780521365,
1.4731711035000001,
1.5580543525,
1.6761507925,
1.5543647225000001,
1.4391385465,
1.7961039655000002
]
}
]
}Scenario: Isolated linker: fresh restore, hot cache + hot store
BENCHMARK_REPORT.json{
"results": [
{
"command": "pacquet@HEAD",
"mean": 0.26270382715999996,
"stddev": 0.006735412699711098,
"median": 0.26193343585999995,
"user": 0.22104986000000001,
"system": 0.5403819000000001,
"min": 0.25145042086,
"max": 0.27565514986,
"times": [
0.26868588386,
0.25816398586,
0.26611608586,
0.26280282586,
0.25776205686,
0.26573119986,
0.26106404586,
0.25960661686,
0.25145042086,
0.27565514986
]
},
{
"command": "pacquet@main",
"mean": 0.26109766136,
"stddev": 0.004013026471223654,
"median": 0.26003672836,
"user": 0.20410925999999993,
"system": 0.5496287,
"min": 0.25640836386,
"max": 0.26959846385999997,
"times": [
0.25844882286,
0.26025980886,
0.26667346686,
0.25981364786,
0.26067559386,
0.25640836386,
0.26959846385999997,
0.26136077586,
0.25902202386,
0.25871564586
]
},
{
"command": "pnpr@HEAD",
"mean": 0.27592200075999995,
"stddev": 0.007005341798693177,
"median": 0.27362727486,
"user": 0.22758656,
"system": 0.5407816999999999,
"min": 0.26990897086,
"max": 0.29414344786,
"times": [
0.27242581786,
0.29414344786,
0.27645709286,
0.27446533586,
0.26990897086,
0.27170894586,
0.27121111786,
0.27799210886,
0.27278921386,
0.27811795586
]
},
{
"command": "pnpr@main",
"mean": 0.26246033256,
"stddev": 0.006125257802842475,
"median": 0.26283468086,
"user": 0.22133066,
"system": 0.49837680000000006,
"min": 0.25120334486,
"max": 0.26993072186,
"times": [
0.26152049686,
0.25533379586,
0.25971594186,
0.25120334486,
0.26922706486,
0.26414886486,
0.26793451586,
0.25986935186,
0.26571922686,
0.26993072186
]
}
]
}Scenario: Isolated linker: fresh install, cold cache + cold store
BENCHMARK_REPORT.json{
"results": [
{
"command": "pacquet@HEAD",
"mean": 2.59781849832,
"stddev": 0.014016331937447264,
"median": 2.59511599212,
"user": 1.4452640799999998,
"system": 1.32003514,
"min": 2.57313546712,
"max": 2.61618023912,
"times": [
2.5936074761200003,
2.61618023912,
2.59028319512,
2.6022214861200004,
2.6160540401200003,
2.57313546712,
2.5926614121200005,
2.61223026712,
2.5851868921200003,
2.59662450812
]
},
{
"command": "pacquet@main",
"mean": 2.6005519245200004,
"stddev": 0.027608663020798813,
"median": 2.6023163101200004,
"user": 1.4798572799999998,
"system": 1.32372304,
"min": 2.5620919261200004,
"max": 2.6365011511200005,
"times": [
2.5743298401200003,
2.57948754012,
2.63332299712,
2.6271563431200002,
2.5941128901200003,
2.5620919261200004,
2.57221692512,
2.6105197301200005,
2.6157799021200003,
2.6365011511200005
]
},
{
"command": "pnpr@HEAD",
"mean": 1.5738761367200003,
"stddev": 0.13300233305025005,
"median": 1.5583195541200001,
"user": 1.0400388799999998,
"system": 1.16497054,
"min": 1.4268857961199999,
"max": 1.76582938312,
"times": [
1.43248518812,
1.66363748012,
1.72526242812,
1.76582938312,
1.6823998021200002,
1.47815857712,
1.46426266312,
1.4613595181199999,
1.6384805311200001,
1.4268857961199999
]
},
{
"command": "pnpr@main",
"mean": 1.56607689382,
"stddev": 0.15330636769649264,
"median": 1.52861033062,
"user": 1.06197958,
"system": 1.14972194,
"min": 1.43576145912,
"max": 1.88641466812,
"times": [
1.45577402212,
1.43576145912,
1.52110906112,
1.77733900612,
1.53687622312,
1.88641466812,
1.6180151061199999,
1.45531865012,
1.5361116001200001,
1.43804914212
]
}
]
}Scenario: Isolated linker: fresh install, hot cache + hot store
BENCHMARK_REPORT.json{
"results": [
{
"command": "pacquet@HEAD",
"mean": 0.40762030958000006,
"stddev": 0.006678866024985746,
"median": 0.41068535948000007,
"user": 0.5483776799999999,
"system": 0.6916440399999999,
"min": 0.39464865248000003,
"max": 0.41465390148000003,
"times": [
0.41115282748000004,
0.40990940048,
0.41031073848000005,
0.41105998048000003,
0.40151982448000006,
0.41263660548000003,
0.41465390148000003,
0.41117275348000004,
0.39464865248000003,
0.39913841148000007
]
},
{
"command": "pacquet@main",
"mean": 0.39065975758000004,
"stddev": 0.01310322943670313,
"median": 0.38902471798000005,
"user": 0.5338983799999999,
"system": 0.66446494,
"min": 0.37627931048,
"max": 0.41702694748,
"times": [
0.40244012048000005,
0.39330634048,
0.37690270548000004,
0.38069089248000004,
0.37627931048,
0.39909547048000005,
0.41702694748,
0.39473039648,
0.38474309548,
0.38138229648000005
]
},
{
"command": "pnpr@HEAD",
"mean": 0.30137409628000006,
"stddev": 0.006165381463247491,
"median": 0.29982699748,
"user": 0.19220107999999997,
"system": 0.5244061399999999,
"min": 0.29369542048,
"max": 0.31223665848000004,
"times": [
0.30786119448000004,
0.31223665848000004,
0.29702583348000006,
0.30032378448,
0.29543422148000004,
0.29369542048,
0.30188907848,
0.30836782848000005,
0.29933021048,
0.29757673248000005
]
},
{
"command": "pnpr@main",
"mean": 0.30705901318,
"stddev": 0.005237413034836292,
"median": 0.30642478398000006,
"user": 0.21725877999999996,
"system": 0.52344624,
"min": 0.30039037048000006,
"max": 0.31760988448000005,
"times": [
0.31183109248,
0.30039037048000006,
0.30275597248,
0.30561227148000003,
0.30264232848000006,
0.30723729648000003,
0.30321654148000005,
0.31760988448000005,
0.30965222148000004,
0.30964215248000004
]
}
]
}Scenario: Isolated linker: fresh install, cold cache + hot store
BENCHMARK_REPORT.json{
"results": [
{
"command": "pacquet@HEAD",
"mean": 1.7395687649000002,
"stddev": 0.008618574247880198,
"median": 1.7438615645000002,
"user": 0.7295145,
"system": 0.7703501600000001,
"min": 1.7252075910000002,
"max": 1.749736423,
"times": [
1.7444893440000002,
1.7331913110000001,
1.7432337850000001,
1.747719037,
1.749736423,
1.73217283,
1.729689075,
1.7453673100000002,
1.744880943,
1.7252075910000002
]
},
{
"command": "pacquet@main",
"mean": 1.7361345775,
"stddev": 0.006412377580220394,
"median": 1.735542437,
"user": 0.6995955999999999,
"system": 0.79375416,
"min": 1.7251948870000002,
"max": 1.750202432,
"times": [
1.7343041000000001,
1.750202432,
1.7251948870000002,
1.734130102,
1.7313742530000003,
1.737886729,
1.740397004,
1.7367713940000002,
1.7357786020000001,
1.735306272
]
},
{
"command": "pnpr@HEAD",
"mean": 0.2990953027,
"stddev": 0.009632996836848672,
"median": 0.299652691,
"user": 0.18978840000000002,
"system": 0.52457956,
"min": 0.285655802,
"max": 0.31197608400000004,
"times": [
0.309231545,
0.309301107,
0.304624165,
0.301468401,
0.31197608400000004,
0.290120484,
0.292724618,
0.285655802,
0.28801384,
0.297836981
]
},
{
"command": "pnpr@main",
"mean": 0.3058006993,
"stddev": 0.006519588511064273,
"median": 0.3048363645,
"user": 0.2123881,
"system": 0.51042966,
"min": 0.297112104,
"max": 0.316292316,
"times": [
0.303182355,
0.316292316,
0.301898844,
0.30409723,
0.298076874,
0.297112104,
0.30668564400000004,
0.315751437,
0.30933469,
0.30557549900000003
]
}
]
}Scenario: Isolated linker: fresh resolve, hot cache, offline
BENCHMARK_REPORT.json{
"results": [
{
"command": "pacquet@HEAD",
"mean": 0.1813871814,
"stddev": 0.0031727088427296398,
"median": 0.18235317780000002,
"user": 0.1621076,
"system": 0.07716448666666667,
"min": 0.17516933680000002,
"max": 0.18466375580000002,
"times": [
0.18362378480000002,
0.1799196998,
0.18466375580000002,
0.1822885858,
0.1755600138,
0.18411018080000002,
0.1841554078,
0.18349802680000002,
0.1819862848,
0.17516933680000002,
0.1840849638,
0.1826920368,
0.1791767958,
0.1775256698,
0.18235317780000002
]
},
{
"command": "pacquet@main",
"mean": 0.18131860955,
"stddev": 0.005114701065986759,
"median": 0.1807077633,
"user": 0.1641177375,
"system": 0.069769045,
"min": 0.17588131880000002,
"max": 0.19794848480000002,
"times": [
0.1762568878,
0.19794848480000002,
0.18311397280000002,
0.1811801748,
0.18207242880000002,
0.18559321880000001,
0.18170472380000002,
0.1801475468,
0.17588131880000002,
0.17994224080000001,
0.17723731680000002,
0.1773109968,
0.1800883338,
0.18120458080000001,
0.1810043728,
0.1804111538
]
},
{
"command": "pnpr@HEAD",
"mean": 0.08719655474117648,
"stddev": 0.0014124059139702207,
"median": 0.08709209980000002,
"user": 0.02030571176470588,
"system": 0.009986924705882349,
"min": 0.0842903398,
"max": 0.0910451708,
"times": [
0.0842903398,
0.0887436308,
0.08780043080000001,
0.0867193208,
0.0879643798,
0.0875799148,
0.08586960880000001,
0.0883102728,
0.0866514438,
0.08823910780000001,
0.0860386778,
0.08669939380000001,
0.08671972280000001,
0.0866658498,
0.0866138728,
0.0878642018,
0.0879369888,
0.08701335580000001,
0.0861888008,
0.08682863780000001,
0.0872300248,
0.08828379180000001,
0.08717084380000001,
0.08629333880000001,
0.0876160738,
0.0910451708,
0.08653112680000001,
0.0875928898,
0.08510610880000001,
0.08950725080000001,
0.08441015580000001,
0.0899293468,
0.08576111380000001,
0.08746767280000001
]
},
{
"command": "pnpr@main",
"mean": 0.08788658404242422,
"stddev": 0.0019081054478482726,
"median": 0.0874667818,
"user": 0.020624315151515155,
"system": 0.00910572,
"min": 0.0842574878,
"max": 0.09286218880000001,
"times": [
0.0865750898,
0.0909825018,
0.08971785780000001,
0.0888869708,
0.09286218880000001,
0.0906499568,
0.0851087028,
0.0871044678,
0.08743178580000001,
0.0870548148,
0.0887772938,
0.0866320768,
0.0874667818,
0.0878763748,
0.08915555780000001,
0.0857030238,
0.0871665758,
0.0865334818,
0.0872159888,
0.0907004708,
0.0889350108,
0.0884130058,
0.0858301238,
0.0869567098,
0.08804275780000001,
0.0867171478,
0.0876202098,
0.08748823280000001,
0.0893481108,
0.0871070828,
0.0842574878,
0.09075993380000001,
0.0851794968
]
}
]
}Scenario: Isolated linker: peer-heavy resolve, hot cache, offline
BENCHMARK_REPORT.json{
"results": [
{
"command": "pacquet@HEAD",
"mean": 0.9858679976577778,
"stddev": 0.15600505276073715,
"median": 0.93405852188,
"user": 0.9214268599999998,
"system": 0.1943255044444444,
"min": 0.84540292888,
"max": 1.29941742588,
"times": [
0.93405852188,
0.92545155688,
1.15275202688,
0.84540292888,
1.29941742588,
0.97771570288,
0.84636611588,
1.04516664688,
0.84648105288
]
},
{
"command": "pacquet@main",
"mean": 0.9240295148800001,
"stddev": 0.24111857203010817,
"median": 0.93571051788,
"user": 0.8459397488888887,
"system": 0.18948972666666666,
"min": 0.56495322188,
"max": 1.22632487888,
"times": [
0.67082877688,
0.8451055468800001,
1.22632487888,
0.56495322188,
1.1660851778799999,
0.73503966988,
1.20329131988,
0.96892652388,
0.93571051788
]
},
{
"command": "pnpm@HEAD",
"mean": 3.007976297324445,
"stddev": 0.09541791008869047,
"median": 2.98464048288,
"user": 4.60802086,
"system": 0.2683477266666666,
"min": 2.8689351758800004,
"max": 3.14765938788,
"times": [
3.03172852588,
2.8689351758800004,
3.06261416688,
2.9106582488800004,
2.98464048288,
3.13635032688,
2.97422116888,
2.95497919188,
3.14765938788
]
}
]
}Scenario: Isolated linker: fresh restore, cold cache + cold store + cold pnpr
BENCHMARK_REPORT.json{
"results": [
{
"command": "pacquet@HEAD",
"mean": 4.58631400522,
"stddev": 0.16605783795997442,
"median": 4.55038699302,
"user": 1.7084091000000001,
"system": 1.3841574400000003,
"min": 4.42385068452,
"max": 4.90250489052,
"times": [
4.47397493552,
4.90250489052,
4.58543018552,
4.51888036152,
4.58189362452,
4.42385068452,
4.45235730752,
4.65470636852,
4.43817466652,
4.83136702752
]
},
{
"command": "pacquet@main",
"mean": 4.45475845362,
"stddev": 0.024146109694428455,
"median": 4.45233910752,
"user": 1.7316554,
"system": 1.3642912400000002,
"min": 4.43173469952,
"max": 4.51283970552,
"times": [
4.45202456952,
4.47508658752,
4.43850107152,
4.43416495252,
4.43963015152,
4.45590068052,
4.45265364552,
4.43173469952,
4.51283970552,
4.45504847252
]
},
{
"command": "pnpr@HEAD",
"mean": 3.520882378219999,
"stddev": 0.05657632027874141,
"median": 3.50998104302,
"user": 1.1784403,
"system": 1.2333790400000002,
"min": 3.45215696252,
"max": 3.61976057952,
"times": [
3.52799300152,
3.57819853652,
3.61976057952,
3.48454548152,
3.48657633252,
3.52683951652,
3.45215696252,
3.58172860452,
3.45790219752,
3.49312256952
]
},
{
"command": "pnpr@main",
"mean": 3.56887865052,
"stddev": 0.13522080132369768,
"median": 3.52399013252,
"user": 1.1940293,
"system": 1.24269914,
"min": 3.43841197752,
"max": 3.81014452752,
"times": [
3.43841197752,
3.54176579452,
3.54265163452,
3.81014452752,
3.46753384552,
3.47374841652,
3.49418589352,
3.60486177052,
3.80926817452,
3.50621447052
]
}
]
} |
|
| Project | pnpm's project |
| Branch | pr/13579 |
| 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,426.89 ms |
| isolated-linker.fresh-install.cold-cache.hot-store | 📈 view plot | 285.66 ms |
| isolated-linker.fresh-install.hot-cache.hot-store | 📈 view plot | 293.70 ms |
| isolated-linker.fresh-resolve.hot-cache.offline | 📈 view plot | 84.29 ms |
| isolated-linker.fresh-restore.cold-cache.cold-store | 📈 view plot | 1,341.40 ms |
| isolated-linker.fresh-restore.cold-cache.cold-store.cold-pnpr | 📈 view plot | 3,452.16 ms |
| isolated-linker.fresh-restore.hot-cache.hot-store | 📈 view plot | 269.91 ms |
…-scope maps Every hoist round of every importer takes a whole-map snapshot of `first_importer_by_pkg` and `first_walk_missing_by_pkg` to build its `HoistMissingScope`, so the cost of a round was linear in workspace size and the cost of a wave quadratic. On the hoist-heavy resolution benchmark (331 importers, 5,030 packages) that was 1.5s of a 6.7s resolve, spent cloning two maps 331 times over and freeing them again. Pair each map with the `Arc` snapshot last projected from it and hand that out until a write invalidates it. Writers reach the map through `map_mut`, which drops the snapshot; the two writers that usually find nothing to change — an ownership claim re-recording the importer that already owns the package, and a later round re-recording a missing-peer report the same owner generation already wrote — now test first and keep to the shared reader, so a round that changes nothing reuses the projection instead of rebuilding it. The snapshots hold the same contents as before, and already-issued `Arc`s keep theirs when a write invalidates the cache, so the emitted graph is unchanged. Hoist-heavy resolution drops from ~6.7s to ~4.4s; peak memory falls too, since one shared copy replaces the per-importer ones.
…ithout flattening them Each discovery pass folded its subtree summaries into an owned `pkg id -> missing peer names` map, cloning every descendant's package id and name set into it, and its one consumer — the per-package owner-context record — read that map and dropped it. Both halves cost the whole workspace per importer per hoist round: on the hoist-heavy resolution benchmark (331 importers, 5,030 packages) the discovery passes built 1.6M entries and spent 1.1s freeing them again. The summaries are already shared bottom-up by `Arc`, so the pass can report its roots instead and let the reader index them. The index borrows the names in place, which makes it free to drop, and the union a package's several occurrences require is only materialized when a second summary reports the same package. Hoist-heavy resolution drops from ~4.4s to ~1.5s, and peak memory with it: the flattened copies are never built.
…ot and missing-peer index Both amortizations rest on a contract a passing resolve does not demonstrate on its own: that a shared snapshot is invalidated by every write that changes its map and reused by every write that does not, and that indexing a walk's summaries in place still visits every descendant and unions what several occurrences of one package reported. Each test fails against the corresponding break: dropping the invalidation in `map_mut`, dropping the descent into a summary's children, and letting the last occurrence of a package overwrite the earlier ones instead of unioning with them. Also settle the lints the new code tripped: an elidable lifetime on the index, the type complexity of the snapshot cell, which gets a name, and the snapshot cell's single-letter type parameters.
032c6d3 to
41d3f4a
Compare
|
Code review by qodo was updated up to the latest commit 41d3f4a |
PR Code Suggestions ✨Warning
No code suggestions found for the PR. |
|
On "Quadratic summary dedupe": I tested the alternative rather than reasoning about it, and it is slower. Swapping the linear 9.9% slower. Keeping the linear scan. On "Changeset missing": For the record, the CI micro-benchmark now measures this PR directly, via the gate added in #13581: Written by an agent (Claude Code, claude-opus-5). |
Summary
Two amortizations in the peer-hoist loop, for
pnpm/tasks#16. Together they take the
hoist-heavy resolution benchmark (331 importers, 5,030 packages) from
6.7s to 1.50s.
I profiled
mainfirst, because the budget in the issue predates#13571 and #13575 and no longer holds:
The final peer pass — one of the two parallelization targets the issue
names — is 6% of the resolve today. The two items above it are both
per-importer rescans of the whole workspace, and both come out without
touching what resolves or adding a thread.
Shared snapshots of the owner-scope maps
Every hoist round of every importer cloned
first_importer_by_pkgandfirst_walk_missing_by_pkgwhole to build itsHoistMissingScope, so around cost the workspace and a wave cost its square.
Each map now carries the
Arcsnapshot last projected from it, handedout until a write invalidates it. The two writers that usually find
nothing to change — an ownership claim re-recording the importer that
already owns the package, and a later round re-recording a missing-peer
report the same owner generation already wrote — test before writing, so
a round that changes nothing reuses the projection. Snapshots already
issued keep what they were built from when a later write invalidates the
cache.
6.7s → 4.4s.
No flattened missing-peer map per round
Each discovery pass folded its subtree summaries into an owned
pkg id → missing peer namesmap, cloning every descendant's package id and nameset into it. Its one consumer — the per-package owner-context record —
read that map and dropped it. On the benchmark the passes built 1.6M
entries and spent 1.1s freeing them again.
The summaries are already shared bottom-up by
Arc, so a pass reportsits roots and the reader indexes them. The index borrows the names in
place, which makes it free to drop; the union that a package's several
occurrences require is materialized only when a second summary reports
the same package.
4.4s → 1.5s.
Results
In-repo
workspace_full_resolution, three runs each:The two scenarios that never enter the hoist loop are unchanged, as
expected — see the note on pnpm/tasks#16 about which scenario
discriminates hoist-round work.
On the 114-importer bit.cloud workspace from the issue the gain is small,
because only ~0.2s of its resolve is the work this removes (its importers
mostly have their peers provided, so the per-round maps are small):
Peak memory falls as well: one shared snapshot replaces the per-importer
copies, and the flattened maps are never built (6.24 GB → 6.33 GB peak
RSS on that workspace, i.e. unchanged within noise, since its maps were
small to begin with).
On proving the output is unchanged
Both changes are meant to be output-preserving, and the 7,557 workspace
tests — which include the lockfile-shape and peer-resolution suites —
pass.
I could not gate that with lockfile byte-identity on the bit.cloud
workspace, because
mainitself is not run-to-run deterministic there:two consecutive replays of the same
mainbinary over the same restoredinput differ by 10,390 lines, and main-vs-this-branch (5,336 lines) is
smaller than either build's own run-to-run noise. I have reopened
#13567 with the measurement.
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