Repository navigation
fix(deps-resolver): reduce peer walker memory on large graphs - #13538
davidfirst wants to merge 2 commits into
Conversation
|
💖 Thanks for opening this pull request! 💖 |
|
Important Review skippedDraft detected. Please check the settings in the CodeRabbit UI or the ⚙️ Run configurationConfiguration used: Path: .coderabbit.yaml Review profile: CHILL Plan: Pro Plus Run ID: You can disable this status message by setting the Use the checkbox below for a quick retry:
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 |
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## main #13538 +/- ##
==========================================
- Coverage 87.92% 87.92% -0.01%
==========================================
Files 550 550
Lines 96449 96479 +30
==========================================
+ Hits 84800 84826 +26
- Misses 11649 11653 +4 ☔ 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.5509996834799997,
"stddev": 0.13157250647669824,
"median": 2.4906781000800002,
"user": 1.9582274199999996,
"system": 1.58322008,
"min": 2.4276536110799998,
"max": 2.77574677908,
"times": [
2.77574677908,
2.45635307808,
2.4591041800799998,
2.6966592760799997,
2.73283679608,
2.53241120508,
2.48247074908,
2.4276536110799998,
2.44787570908,
2.49888545108
]
},
{
"command": "pacquet@main",
"mean": 2.6206122813799997,
"stddev": 0.12518507115357028,
"median": 2.61562854608,
"user": 2.02374942,
"system": 1.4845094800000003,
"min": 2.4675402800799997,
"max": 2.79450867508,
"times": [
2.49792280408,
2.6333104870799997,
2.79450867508,
2.7679690520799998,
2.73383466708,
2.49586110508,
2.4675402800799997,
2.71171395608,
2.50551518208,
2.5979466050799997
]
},
{
"command": "pnpr@HEAD",
"mean": 1.5588000667800002,
"stddev": 0.16702828193413036,
"median": 1.5159595730800002,
"user": 1.3746452200000001,
"system": 1.4051845799999998,
"min": 1.40068101608,
"max": 1.79549935708,
"times": [
1.41104545608,
1.7219516480800001,
1.40877787008,
1.6148834200800002,
1.40068101608,
1.40353279708,
1.64545648208,
1.7691368950800002,
1.4170357260800002,
1.79549935708
]
},
{
"command": "pnpr@main",
"mean": 1.51233923298,
"stddev": 0.13740423035315077,
"median": 1.45021323358,
"user": 1.19487942,
"system": 1.32418798,
"min": 1.36027548208,
"max": 1.77087960608,
"times": [
1.41288872508,
1.45178245308,
1.39860267608,
1.36027548208,
1.6387014430800002,
1.77087960608,
1.4376168710800001,
1.44864401408,
1.52527685108,
1.67872420808
]
}
]
}Scenario: Isolated linker: fresh restore, hot cache + hot store
BENCHMARK_REPORT.json{
"results": [
{
"command": "pacquet@HEAD",
"mean": 0.26390635906000004,
"stddev": 0.006110057776934382,
"median": 0.26333081986000006,
"user": 0.22165929999999995,
"system": 0.5190945199999999,
"min": 0.25323837086000006,
"max": 0.27669722286000004,
"times": [
0.26602713986000004,
0.26627705886,
0.27669722286000004,
0.26267959786000006,
0.26761571086,
0.26369572486000004,
0.25934025186000004,
0.26296591486000004,
0.25323837086000006,
0.26052659786000004
]
},
{
"command": "pacquet@main",
"mean": 0.35571244526000007,
"stddev": 0.10922988656700074,
"median": 0.33164295386000003,
"user": 0.2778114,
"system": 0.6850405199999999,
"min": 0.25052257486000007,
"max": 0.58350041586,
"times": [
0.25052257486000007,
0.26271350086000006,
0.25868460186000003,
0.26252737186,
0.30519842886000004,
0.35808747886000003,
0.43290966986000007,
0.40549903086000005,
0.43748137886000005,
0.58350041586
]
},
{
"command": "pnpr@HEAD",
"mean": 0.31086173016,
"stddev": 0.05018966496102344,
"median": 0.29716615036000005,
"user": 0.2552482,
"system": 0.58842462,
"min": 0.26034474686000003,
"max": 0.43143521386000006,
"times": [
0.28948257686000006,
0.26179684086000005,
0.26034474686000003,
0.34255866786000005,
0.29536220086000003,
0.29897009986000006,
0.30014788986000007,
0.28984190086000006,
0.3386771638600001,
0.43143521386000006
]
},
{
"command": "pnpr@main",
"mean": 0.46929143566000003,
"stddev": 0.037322767839933296,
"median": 0.47351448386000006,
"user": 0.4116588,
"system": 0.79656862,
"min": 0.41539417186000005,
"max": 0.51267212086,
"times": [
0.50203887686,
0.44005513886000003,
0.50492892986,
0.43529251186000006,
0.45126054686000006,
0.50214734086,
0.51267212086,
0.49576842086000006,
0.4333562978600001,
0.41539417186000005
]
}
]
}Scenario: Isolated linker: fresh install, cold cache + cold store
BENCHMARK_REPORT.json{
"results": [
{
"command": "pacquet@HEAD",
"mean": 3.4294786145400002,
"stddev": 0.08235369522591424,
"median": 3.41982002174,
"user": 3.2540967000000003,
"system": 2.6296692399999992,
"min": 3.32406594974,
"max": 3.59432733874,
"times": [
3.59432733874,
3.44176061474,
3.44340987874,
3.49982196174,
3.35526117174,
3.39787942874,
3.36751046774,
3.37603320274,
3.49471613074,
3.32406594974
]
},
{
"command": "pacquet@main",
"mean": 3.3828935700399994,
"stddev": 0.08031970542851856,
"median": 3.39261213424,
"user": 3.2533283999999996,
"system": 2.50415844,
"min": 3.21486206474,
"max": 3.48917491874,
"times": [
3.45214334774,
3.21486206474,
3.3536350707400002,
3.39705026774,
3.29420928974,
3.38817400074,
3.38372614574,
3.40900825674,
3.48917491874,
3.44695233774
]
},
{
"command": "pnpr@HEAD",
"mean": 1.9615931799400002,
"stddev": 0.1602639854320258,
"median": 1.92042094674,
"user": 2.0575493,
"system": 2.32420084,
"min": 1.7648488547399999,
"max": 2.24205155474,
"times": [
1.83941351274,
1.95901877074,
1.8400378447399999,
2.13833375074,
2.1311560527399998,
1.83110072574,
1.98814760974,
1.88182312274,
1.7648488547399999,
2.24205155474
]
},
{
"command": "pnpr@main",
"mean": 1.9820982636400004,
"stddev": 0.1616974690180298,
"median": 1.9305797197399999,
"user": 1.9472852,
"system": 2.13231754,
"min": 1.78605510774,
"max": 2.21611432474,
"times": [
1.92571381374,
2.16841759274,
1.88410215174,
2.06681943574,
2.21611432474,
1.8677219147400002,
2.17524938274,
1.79534328674,
1.78605510774,
1.93544562574
]
}
]
}Scenario: Isolated linker: fresh install, hot cache + hot store
BENCHMARK_REPORT.json{
"results": [
{
"command": "pacquet@HEAD",
"mean": 0.47579396892,
"stddev": 0.01775409655340889,
"median": 0.47743619032,
"user": 0.63304114,
"system": 0.7501562199999999,
"min": 0.43184914232000005,
"max": 0.49186821732,
"times": [
0.43184914232000005,
0.47297400132,
0.47689973932,
0.46641941232,
0.49186821732,
0.49068208132,
0.48526016732000005,
0.47314524432000005,
0.47797264132,
0.49086904232
]
},
{
"command": "pacquet@main",
"mean": 0.43183188442000003,
"stddev": 0.010891215541888325,
"median": 0.43156952032,
"user": 0.57643234,
"system": 0.6979600199999999,
"min": 0.41131892532000003,
"max": 0.45224243732,
"times": [
0.43698181132,
0.42951492932,
0.42845736532,
0.42907588532,
0.41131892532000003,
0.43362411132,
0.43534809532,
0.43987556132,
0.45224243732,
0.42187972232000004
]
},
{
"command": "pnpr@HEAD",
"mean": 0.30840306722000005,
"stddev": 0.006267558800825342,
"median": 0.30719034232,
"user": 0.19123504,
"system": 0.5285190200000001,
"min": 0.30029445732,
"max": 0.32047822232,
"times": [
0.31277652032000003,
0.32047822232,
0.30358948132,
0.30706462132,
0.30479496232000003,
0.30312978832000004,
0.30731606332,
0.31587221832,
0.30871433732000003,
0.30029445732
]
},
{
"command": "pnpr@main",
"mean": 0.29863657682000005,
"stddev": 0.01170123949092047,
"median": 0.29669753332000004,
"user": 0.19903493999999994,
"system": 0.48678431999999994,
"min": 0.28637261332,
"max": 0.32449567132,
"times": [
0.29987999932000003,
0.30710619032,
0.32449567132,
0.29005335132,
0.29793132332,
0.28707059332,
0.28637261332,
0.30679442532,
0.29546374332,
0.29119785732000003
]
}
]
}Scenario: Isolated linker: fresh install, cold cache + hot store
BENCHMARK_REPORT.json{
"results": [
{
"command": "pacquet@HEAD",
"mean": 1.73347789854,
"stddev": 0.00852028165377155,
"median": 1.73248433374,
"user": 0.726551,
"system": 0.7701888999999998,
"min": 1.72395145624,
"max": 1.74514939424,
"times": [
1.7272314612400002,
1.7450016162400002,
1.74514939424,
1.72461984024,
1.74133469524,
1.72422687224,
1.73382807024,
1.73829498224,
1.72395145624,
1.73114059724
]
},
{
"command": "pacquet@main",
"mean": 1.7296126520400001,
"stddev": 0.008912741017586621,
"median": 1.73214446024,
"user": 0.7273693,
"system": 0.7449385999999999,
"min": 1.71055359524,
"max": 1.73909044324,
"times": [
1.73618732624,
1.7371145562399999,
1.72540284924,
1.73677586124,
1.7331748842399999,
1.73909044324,
1.71055359524,
1.72313904124,
1.7311140362400002,
1.72357392724
]
},
{
"command": "pnpr@HEAD",
"mean": 0.30227107704,
"stddev": 0.008602257372228653,
"median": 0.30268526924,
"user": 0.1831347,
"system": 0.5413910999999999,
"min": 0.29141652924,
"max": 0.32102002924,
"times": [
0.29599304624,
0.30770138724,
0.29713706324,
0.29141652924,
0.32102002924,
0.29334451624,
0.30570771524,
0.30168735224,
0.30368318624,
0.30501994524000003
]
},
{
"command": "pnpr@main",
"mean": 0.30194814814000004,
"stddev": 0.006070861373875918,
"median": 0.30201083823999997,
"user": 0.1931559,
"system": 0.5209222,
"min": 0.29408492624,
"max": 0.31165865324,
"times": [
0.30157269624,
0.29408492624,
0.30718015924000003,
0.29677606624,
0.31165865324,
0.30793794224,
0.30244898024,
0.29760995024000003,
0.30556378524,
0.29464832224
]
}
]
}Scenario: Isolated linker: fresh resolve, hot cache, offline
BENCHMARK_REPORT.json{
"results": [
{
"command": "pacquet@HEAD",
"mean": 0.18164316593250002,
"stddev": 0.004772578717471945,
"median": 0.18146130312000003,
"user": 0.18290568750000002,
"system": 0.055156710000000005,
"min": 0.17307657012000002,
"max": 0.19076816812000003,
"times": [
0.17307657012000002,
0.18447274412,
0.17925399212,
0.19057123812,
0.17910071412,
0.19076816812000003,
0.17703356412000001,
0.18142382312000002,
0.18338468312,
0.17512745812000002,
0.18336680912,
0.18028046712,
0.18377959412,
0.18368733012000002,
0.18149878312,
0.17946471612
]
},
{
"command": "pacquet@main",
"mean": 0.18035884205333327,
"stddev": 0.0031064645440611284,
"median": 0.17963050712,
"user": 0.17999330000000002,
"system": 0.05172719333333332,
"min": 0.17749040212,
"max": 0.19015653012,
"times": [
0.19015653012,
0.17936799512,
0.17970411712,
0.17915686912,
0.18030207812000001,
0.17963050712,
0.17749040212,
0.17771555412,
0.17783709312,
0.18011347412,
0.18235726512,
0.17953843512,
0.18129277712000003,
0.18242674512,
0.17829278812000002
]
},
{
"command": "pnpr@HEAD",
"mean": 0.08720691699878788,
"stddev": 0.001171703567222789,
"median": 0.08739928612,
"user": 0.019299833333333332,
"system": 0.010222101212121214,
"min": 0.08497004812,
"max": 0.08928117712000001,
"times": [
0.08597668612,
0.08654608512,
0.08831887212,
0.08546355412000001,
0.08836216312,
0.08812811412,
0.08837304412000001,
0.08613954212000001,
0.08739928612,
0.08767370112,
0.08749354312,
0.08803524912,
0.08497004812,
0.08682792412000001,
0.08506166012000001,
0.08546939512000001,
0.08826769612,
0.08842322812,
0.08610932512000001,
0.08928117712000001,
0.08683200212,
0.08785317712,
0.08746877612000001,
0.08820087012000001,
0.08688645412000001,
0.08651681112000001,
0.08804740212,
0.08607637412000001,
0.08635930412000001,
0.08885951612000001,
0.08644305112,
0.08705808512,
0.08890614312
]
},
{
"command": "pnpr@main",
"mean": 0.08673927560484851,
"stddev": 0.001992498875616152,
"median": 0.08722722312,
"user": 0.02033462121212121,
"system": 0.009033853939393937,
"min": 0.08197957612000001,
"max": 0.09003781712,
"times": [
0.08497457612,
0.08722722312,
0.08747345512,
0.08651742112000001,
0.08197957612000001,
0.08901062912,
0.08624256612,
0.08966908512,
0.08790728912000001,
0.08697113312,
0.08738210412000001,
0.08802735412000001,
0.08529833412000001,
0.08725315212000001,
0.08232081612,
0.08698627212000001,
0.08363257812000001,
0.08667301312,
0.08747820512000001,
0.08883831712000001,
0.08820020912000001,
0.08571515612000001,
0.09003781712,
0.08524524412000001,
0.08641851612000001,
0.08881382112000001,
0.08768488212,
0.08475020512,
0.08414417712000001,
0.08970350012,
0.08726146712,
0.08475191912,
0.08780608012
]
}
]
}Scenario: Isolated linker: fresh restore, cold cache + cold store + cold pnpr
BENCHMARK_REPORT.json{
"results": [
{
"command": "pacquet@HEAD",
"mean": 4.565086718000001,
"stddev": 0.16322751219369616,
"median": 4.4745814977,
"user": 1.6640437599999998,
"system": 1.32511098,
"min": 4.4524726547,
"max": 4.8806698227,
"times": [
4.4749462137,
4.4742167817,
4.4978468387,
4.4540222027,
4.4524726547,
4.8166773387,
4.6695945477,
4.4724523107,
4.4579684687,
4.8806698227
]
},
{
"command": "pacquet@main",
"mean": 4.5456029967,
"stddev": 0.13088499945967683,
"median": 4.477175044199999,
"user": 1.82970696,
"system": 1.4095921799999998,
"min": 4.4388967267,
"max": 4.8244631197,
"times": [
4.6750037897,
4.8244631197,
4.4587342667,
4.4522704957,
4.5802347157,
4.4538584857,
4.4956158216999995,
4.4389515397,
4.6380010057,
4.4388967267
]
},
{
"command": "pnpr@HEAD",
"mean": 3.5669422147,
"stddev": 0.1157155738978894,
"median": 3.5425661672,
"user": 1.3333940599999998,
"system": 1.33175338,
"min": 3.4533438397,
"max": 3.8562593867,
"times": [
3.4533438397,
3.6311392887,
3.5910694497,
3.5280059527,
3.4886167657,
3.4921423247,
3.5801531357,
3.4915656217,
3.5571263817,
3.8562593867
]
},
{
"command": "pnpr@main",
"mean": 3.5547357892999996,
"stddev": 0.1036019602440429,
"median": 3.5312299687,
"user": 1.2851569599999997,
"system": 1.33459898,
"min": 3.4590601427,
"max": 3.7230705666999997,
"times": [
3.4655863037,
3.5589085557,
3.5035513817,
3.5671595047,
3.7146446497,
3.7230705666999997,
3.6305482767,
3.4590601427,
3.4607222447,
3.4641062667
]
}
]
} |
|
Not needed anymore. See #13540. |
Two allocation hot spots in the peer-resolution
Walker, found while investigating installs of a large single-importer graph (~3.5k packages) that peak at >30 GB RSS through@pnpm/napi(repro and full investigation: #13540).Children were realized before the peers-cache check. ~97% of
resolve_nodevisits short-circuit throughpurePkgs/peersCache, but every visit had already materialized all of its children into the persistent tree — ~5M occurrence nodes on the graph above, ~4M of them belonging to visits that were then served from the cache and never walked.realize_childrennow reports which tree nodes it freshly inserted, and a cache-served visit removes them again and restores the node'sLazystate.Each realized child cloned the full ancestor chain.
TreeChildren::Lazy { parent_ids }stored the chain including the node itself, so siblings could never share it and every child got its ownVec<String>copy of the whole chain — 6.5M clones / ~20.5 GB cumulative allocation on the same graph. The chain now excludes the node itself (readers append it fromresolved_package_id), so oneArcperrealize_childrencall is shared by all siblings: 6.5M → 618k chain allocations, ~20.5 GB → ~2 GB.Measured on the repro graph: retained tree nodes after the first discovery pass drop 4.95M → 966k, and peak RSS of a
lockfileOnlyinstall drops 32.8 GB → 27.5 GB. The resultingpnpm-lock.yamlis byte-identical to the one the unpatched engine produces. This intentionally does not address the two larger remaining costs (per-visit retained walk state, and the hoisted linker'swalk_depsgraph) — those need design decisions and are described in #13540.cargo test -p pacquet-resolving-deps-resolver: 278 passed.