Repository navigation
perf(resolving-deps-resolver): compute previously_resolved_children once per node - #13565
Conversation
…nce per node record_walked_node called previously_resolved_children twice with identical arguments — once to seed the graph children, once to seed the record edges. Each call rescans the ancestor pkg-id chain and, on a match, re-realizes every matching occurrence's children, so the second one was pure repeat work in the peer-resolution hot path. Build the record edges first and iterate them by reference for the graph children. The clone count is unchanged — the per-entry clones in the loop replace the ones the second call made while rebuilding the map — while one chain scan and one realize_children pass go away, and the common case (the node's package is not in its own ancestor chain, so the map is empty) now does strictly less work. Raised by CodeRabbit on #13564. Its suggested fix cloned the map into the first loop instead, which trades one cost for another; building the record edges first removes the call without adding a clone.
|
Warning Review limit reached
Next review available in: 6 minutes Enable usage-based reviews in Billing to review now. Otherwise, wait until the next included review is available. How can I continue?After more reviews become available, a review can be triggered using the To avoid repeated limits, reduce automatic review volume by pausing incremental auto-reviews earlier, using label-based review opt-in, excluding WIP or generated PR titles, or requesting reviews manually when the PR is ready. If your team needs uninterrupted high-volume reviews, an organization admin can enable usage-based reviews. How do review limits work?CodeRabbit enforces per-developer PR review limits for each organization. Most developers receive the normal plan review availability. For paid Pro and Pro+ PR reviews, CodeRabbit uses adaptive limits for sustained high-volume activity. When a developer's recent PR review activity reaches the 95th percentile or higher among CodeRabbit users, additional reviews become available more gradually as earlier reviews age out of the rolling window. Please refer docs for additional details. Review details⚙️ Run configurationConfiguration used: Path: .coderabbit.yaml Review profile: CHILL Plan: Pro Plus Run ID: 📒 Files selected for processing (1)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
Confidence Score: 5/5The PR appears safe to merge, with no actionable correctness, security, build, or maintainability issues identified. The cached helper result is identical to the former two results, intervening edge handling does not affect helper state, and all child and peer overlays retain their previous ordering and targets. Reviews (1): Last reviewed commit: "perf(resolving-deps-resolver): compute p..." | Re-trigger Greptile |
Code Review by Qodo🐞 Bugs (0) 📘 Rule violations (0) 📎 Requirement gaps (0)
Great, no issues found!Qodo reviewed your code and found no material issues that require reviewTo customize comments, go to the Qodo configuration screen, or learn more in the docs. |
PR Summary by QodoAvoid duplicate previously_resolved_children scans in peer-walk finalization
AI Description
Diagram
High-Level Assessment
Files changed (1)
|
PR Code Suggestions ✨Warning
No code suggestions found for the PR. |
There was a problem hiding this comment.
Pull request overview
Reduces duplicate work in pacquet’s peer-resolution hot path by computing previously_resolved_children once per visited node in Walker::record_walked_node, then reusing the result to seed both the node’s record edges and its graph children.
Changes:
- Compute
previously_resolved_children(...)once and store it inrecord_edgesearly inrecord_walked_node. - Populate initial
graph_childrenby iteratingrecord_edgesby reference (cloning per entry as required byadd_graph_child_or_pending’s by-value signature). - Reword/relocate the record-edges comment to reflect the new construction order without changing behavior.
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Micro-Benchmark ResultsLinux |
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #13565 +/- ##
==========================================
- Coverage 87.95% 87.95% -0.01%
==========================================
Files 556 556
Lines 97290 97300 +10
==========================================
+ Hits 85576 85583 +7
- Misses 11714 11717 +3 ☔ 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.521266788,
"stddev": 0.1545196585882089,
"median": 2.5135759223,
"user": 1.60803592,
"system": 1.3500868799999997,
"min": 2.3578562602999997,
"max": 2.7779110063,
"times": [
2.3578562602999997,
2.5573782523,
2.7779110063,
2.6131112183,
2.6353876513,
2.3741473503,
2.3683541483,
2.3685245093,
2.6902238913,
2.4697735922999997
]
},
{
"command": "pacquet@main",
"mean": 2.4187185291,
"stddev": 0.09939273943418869,
"median": 2.3868497528,
"user": 1.5273126199999998,
"system": 1.24806448,
"min": 2.3306014433,
"max": 2.6778985483,
"times": [
2.3536781753,
2.3572690172999997,
2.3753268483,
2.3733438503,
2.3983726573,
2.4341240052999997,
2.6778985483,
2.4523687183,
2.4342020273,
2.3306014433
]
},
{
"command": "pnpr@HEAD",
"mean": 1.4853067448999995,
"stddev": 0.12441099095159656,
"median": 1.4438368337999998,
"user": 1.00152732,
"system": 1.17589238,
"min": 1.3642444343,
"max": 1.7456462813,
"times": [
1.5496164943,
1.3642444343,
1.5726514853,
1.3655798262999999,
1.4287573053,
1.7456462813,
1.4031999913,
1.3819382032999998,
1.4589163622999999,
1.5825170652999998
]
},
{
"command": "pnpr@main",
"mean": 1.4455424290999999,
"stddev": 0.09249803312502602,
"median": 1.4608860713,
"user": 1.0102363200000002,
"system": 1.12609878,
"min": 1.3430553033,
"max": 1.6138274563,
"times": [
1.5498080743,
1.3463229163,
1.4603727913,
1.4799441202999999,
1.3430553033,
1.4613993512999999,
1.4785122783,
1.3762191293,
1.3459628703,
1.6138274563
]
}
]
}Scenario: Isolated linker: fresh restore, hot cache + hot store
BENCHMARK_REPORT.json{
"results": [
{
"command": "pacquet@HEAD",
"mean": 0.25683984258000003,
"stddev": 0.007471536571495906,
"median": 0.25773112278,
"user": 0.20711512,
"system": 0.5340391,
"min": 0.24113246678,
"max": 0.26642827078000003,
"times": [
0.26534796878000005,
0.25592937978,
0.25953286578,
0.25240846878,
0.25215217778000004,
0.26006721978,
0.25384109378,
0.26155851378000006,
0.24113246678,
0.26642827078000003
]
},
{
"command": "pacquet@main",
"mean": 0.24554539998,
"stddev": 0.006148523189882438,
"median": 0.24484510678,
"user": 0.20495232,
"system": 0.4941413,
"min": 0.23816118478,
"max": 0.25838404878000004,
"times": [
0.23951167378000002,
0.24308536378,
0.24387029878,
0.24581991478,
0.24647224178000002,
0.25838404878000004,
0.24598714978,
0.25298749278000005,
0.24117463078,
0.23816118478
]
},
{
"command": "pnpr@HEAD",
"mean": 0.26753161218000004,
"stddev": 0.006567256629932788,
"median": 0.26745788078000005,
"user": 0.20706712,
"system": 0.5352428,
"min": 0.25967237178,
"max": 0.27634811678000004,
"times": [
0.27405624778000004,
0.25967237178,
0.27634811678000004,
0.27042815478000004,
0.26012239778,
0.26087798878,
0.27568592078000004,
0.27004110878000004,
0.26487465278000005,
0.26320916178000003
]
},
{
"command": "pnpr@main",
"mean": 0.27007633198000003,
"stddev": 0.004430023621429269,
"median": 0.2709498262800001,
"user": 0.20804331999999998,
"system": 0.5324669,
"min": 0.26383326578000005,
"max": 0.27718932778000005,
"times": [
0.26659241378000004,
0.27337404478000005,
0.27266783578000003,
0.26784539978000005,
0.26407906678000004,
0.26383326578000005,
0.27246283078000005,
0.26943682178000006,
0.27718932778000005,
0.27328231278000004
]
}
]
}Scenario: Isolated linker: fresh install, cold cache + cold store
BENCHMARK_REPORT.json{
"results": [
{
"command": "pacquet@HEAD",
"mean": 2.57325970662,
"stddev": 0.01775495234619004,
"median": 2.56921713592,
"user": 1.4458377199999999,
"system": 1.29809666,
"min": 2.54980264092,
"max": 2.60967738292,
"times": [
2.60967738292,
2.5571736999200003,
2.5904167569200003,
2.57282613192,
2.56337486992,
2.56243980192,
2.5841830049200003,
2.57709463692,
2.54980264092,
2.56560813992
]
},
{
"command": "pacquet@main",
"mean": 2.5768009759200003,
"stddev": 0.012817112222171814,
"median": 2.57274845742,
"user": 1.4468072199999997,
"system": 1.27970836,
"min": 2.55860079592,
"max": 2.59717926092,
"times": [
2.59717926092,
2.56542928392,
2.58282782992,
2.57495443492,
2.57021723792,
2.59153124492,
2.55860079592,
2.56699351592,
2.58973367492,
2.57054247992
]
},
{
"command": "pnpr@HEAD",
"mean": 1.5387176319200002,
"stddev": 0.08798004806437722,
"median": 1.55989940092,
"user": 0.9862734200000001,
"system": 1.1548742600000002,
"min": 1.42120545392,
"max": 1.65850008992,
"times": [
1.58439130292,
1.4520581569200002,
1.6014784529200001,
1.65850008992,
1.5354074989200002,
1.43710162392,
1.61071703392,
1.42120545392,
1.62193797292,
1.4643787329200002
]
},
{
"command": "pnpr@main",
"mean": 1.5914437418200003,
"stddev": 0.14757426982382946,
"median": 1.53929388592,
"user": 0.9923996199999999,
"system": 1.16377326,
"min": 1.4452778669200002,
"max": 1.83742965292,
"times": [
1.4538341159200001,
1.56010905492,
1.46807282892,
1.4452778669200002,
1.50743496192,
1.51847871692,
1.80677999192,
1.83742965292,
1.58352867092,
1.7334915569200002
]
}
]
}Scenario: Isolated linker: fresh install, hot cache + hot store
BENCHMARK_REPORT.json{
"results": [
{
"command": "pacquet@HEAD",
"mean": 0.38454980676000006,
"stddev": 0.006110371439421282,
"median": 0.38615750236,
"user": 0.5070553799999999,
"system": 0.6612995199999998,
"min": 0.37087857286000003,
"max": 0.39317564786000003,
"times": [
0.38585976286,
0.38645524186,
0.38501655686,
0.37976715586,
0.38089227086,
0.38760369986,
0.39317564786000003,
0.3872914538600001,
0.37087857286000003,
0.3885577048600001
]
},
{
"command": "pacquet@main",
"mean": 0.38671968316000005,
"stddev": 0.010717177726453786,
"median": 0.38737784186,
"user": 0.49074098,
"system": 0.6712037200000001,
"min": 0.36855688786000007,
"max": 0.40325516986,
"times": [
0.38540095986,
0.38973552986000004,
0.39047580185999997,
0.38935472386000003,
0.38148035686000004,
0.38441833286000004,
0.40077241286,
0.40325516986,
0.36855688786000007,
0.37374665586
]
},
{
"command": "pnpr@HEAD",
"mean": 0.30169113896,
"stddev": 0.0030736257349052074,
"median": 0.30235506786,
"user": 0.21974948,
"system": 0.4986575200000001,
"min": 0.29742178186,
"max": 0.30557716586000006,
"times": [
0.30267414686000005,
0.29742178186,
0.30234108185999997,
0.29818373385999997,
0.30530789986000006,
0.29761029486,
0.30102156986000006,
0.30557716586000006,
0.30236905386,
0.30440466086000006
]
},
{
"command": "pnpr@main",
"mean": 0.29348623936,
"stddev": 0.006899353854947186,
"median": 0.29330072236000004,
"user": 0.19434387999999997,
"system": 0.49541591999999995,
"min": 0.28367992286,
"max": 0.30505203786,
"times": [
0.29270462186,
0.29754838986,
0.29558381586000004,
0.2938968228600001,
0.30263685786000005,
0.28764850486000004,
0.28809784886,
0.28801357086,
0.28367992286,
0.30505203786
]
}
]
}Scenario: Isolated linker: fresh install, cold cache + hot store
BENCHMARK_REPORT.json{
"results": [
{
"command": "pacquet@HEAD",
"mean": 1.7262008867200003,
"stddev": 0.006137846766867498,
"median": 1.72365812992,
"user": 0.6914372799999999,
"system": 0.7465535400000001,
"min": 1.7177115269200003,
"max": 1.7377025559200001,
"times": [
1.7223257239200003,
1.7237017939200001,
1.7234761659200002,
1.7314429359200003,
1.72524665392,
1.7377025559200001,
1.7177115269200003,
1.7236144659200001,
1.73393066392,
1.7228563809200002
]
},
{
"command": "pacquet@main",
"mean": 1.71468091192,
"stddev": 0.003698350818094427,
"median": 1.71508033892,
"user": 0.6782887799999999,
"system": 0.76042814,
"min": 1.7082379329200001,
"max": 1.72010419592,
"times": [
1.71314950792,
1.7177203839200001,
1.71056648092,
1.7082379329200001,
1.71548844692,
1.71467223092,
1.71194050492,
1.71750283392,
1.71742660092,
1.72010419592
]
},
{
"command": "pnpr@HEAD",
"mean": 0.29635562512,
"stddev": 0.009157126408121793,
"median": 0.29824578442000005,
"user": 0.17617438,
"system": 0.5238114399999999,
"min": 0.28044776792000004,
"max": 0.30855634092,
"times": [
0.29359463892,
0.28044776792000004,
0.28207271292,
0.30092258792,
0.30041722692,
0.30606833392,
0.29778732192,
0.29870424692,
0.29498507292000004,
0.30855634092
]
},
{
"command": "pnpr@main",
"mean": 0.30651035752,
"stddev": 0.005202098253965913,
"median": 0.30616756992,
"user": 0.19008377999999998,
"system": 0.5440103399999999,
"min": 0.29710432792,
"max": 0.31473675292000003,
"times": [
0.31473675292000003,
0.31130034092000003,
0.30022805192,
0.29710432792,
0.30490999492000004,
0.31042948392,
0.30879423892,
0.30636252692,
0.30597261292,
0.30526524392
]
}
]
}Scenario: Isolated linker: fresh resolve, hot cache, offline
BENCHMARK_REPORT.json{
"results": [
{
"command": "pacquet@HEAD",
"mean": 0.17910262538,
"stddev": 0.00291997633161522,
"median": 0.17910672538,
"user": 0.15967946499999996,
"system": 0.0755194825,
"min": 0.17402849038,
"max": 0.18303792138,
"times": [
0.18267047038,
0.17835127938,
0.17428443338,
0.17707497938,
0.17944060838,
0.17814580238,
0.17877284238,
0.18108666338,
0.18163335138,
0.17679214738,
0.18217835538,
0.17402849038,
0.17584260238,
0.18054168838,
0.18303792138,
0.18176037038
]
},
{
"command": "pacquet@main",
"mean": 0.181742813505,
"stddev": 0.005834006039948365,
"median": 0.18064918487999998,
"user": 0.16676046500000005,
"system": 0.06764504499999999,
"min": 0.17654211838,
"max": 0.19583560538,
"times": [
0.18230437238,
0.19461321738,
0.18456595538,
0.18263892137999999,
0.17732268538,
0.17867957638,
0.18155323037999999,
0.18075532938,
0.18298665538,
0.17711385238,
0.18054304038,
0.19583560538,
0.17654211838,
0.17686695938,
0.17721400137999999,
0.17834949538
]
},
{
"command": "pnpr@HEAD",
"mean": 0.08724402982117647,
"stddev": 0.001481928574684645,
"median": 0.08735158438000001,
"user": 0.022140575294117646,
"system": 0.00762714294117647,
"min": 0.08464597238,
"max": 0.09070699938000001,
"times": [
0.08464597238,
0.08486295038000001,
0.08658955838,
0.08712647638000001,
0.08752206038,
0.08592005838000001,
0.09009977738000001,
0.08502309238000001,
0.08779224838000001,
0.08751467738,
0.08771613538,
0.08756920838000001,
0.08778777938000001,
0.08695528538000001,
0.08727094738,
0.08779443338000001,
0.08836316238000001,
0.08596445138,
0.08743222138000001,
0.08716990838000001,
0.08927139038000001,
0.08610470638,
0.08923208538,
0.08879500338,
0.08491310538,
0.08801689138,
0.08691321538,
0.08882786638000001,
0.08514545138,
0.09070699938000001,
0.08555835838,
0.08680942038,
0.08791928638,
0.08696282938000001
]
},
{
"command": "pnpr@main",
"mean": 0.0873449606830303,
"stddev": 0.000676649883443402,
"median": 0.08733145238000001,
"user": 0.021538430909090918,
"system": 0.007962780606060605,
"min": 0.08543315238,
"max": 0.08930482238000001,
"times": [
0.08543315238,
0.08729768838,
0.08750468738,
0.08722092538000001,
0.08743975538000001,
0.08759536838000001,
0.08723172438,
0.08842537938,
0.08689034238000001,
0.08755008438,
0.08730144638000001,
0.08731425038000001,
0.08729809938000001,
0.08677835338,
0.08761925338000001,
0.08796973238000001,
0.08691916638000001,
0.08745636638000001,
0.08731607338000001,
0.08728154838,
0.08752811138000001,
0.08755409138,
0.08680448138,
0.08719594838000001,
0.08765021138000001,
0.08747134538000001,
0.08805052438000001,
0.08733145238000001,
0.08739488138000001,
0.08930482238000001,
0.08545627638,
0.08755259838000001,
0.08724556038
]
}
]
}Scenario: Isolated linker: peer-heavy resolve, hot cache, offline
BENCHMARK_REPORT.json{
"results": [
{
"command": "pacquet@HEAD",
"mean": 1.5944708373288887,
"stddev": 0.5043256678471489,
"median": 1.44191039744,
"user": 1.4980587977777777,
"system": 0.20013074222222219,
"min": 1.0675181564399998,
"max": 2.65349956244,
"times": [
1.0853301494399998,
2.65349956244,
1.42937579844,
1.44191039744,
1.0675181564399998,
2.04282943244,
1.50284674644,
1.32426135744,
1.8026659354399999
]
},
{
"command": "pacquet@main",
"mean": 1.7165501338844444,
"stddev": 0.5291873152282507,
"median": 1.62639002044,
"user": 1.6086832422222224,
"system": 0.20363096444444445,
"min": 1.1355495144399999,
"max": 2.91688555344,
"times": [
1.48612311144,
1.73116639244,
1.1524688164399999,
1.6164547064399999,
2.91688555344,
1.62639002044,
1.96532594744,
1.1355495144399999,
1.81858714244
]
},
{
"command": "pnpm@HEAD",
"mean": 2.8879934596622223,
"stddev": 0.046689313731450736,
"median": 2.87576134544,
"user": 4.421044575555555,
"system": 0.2584617422222222,
"min": 2.80701366944,
"max": 2.96083773844,
"times": [
2.80701366944,
2.96083773844,
2.87576134544,
2.85654534744,
2.93200848144,
2.92956956544,
2.87402551044,
2.86431754444,
2.89186193444
]
}
]
}Scenario: Isolated linker: fresh restore, cold cache + cold store + cold pnpr
BENCHMARK_REPORT.json{
"results": [
{
"command": "pacquet@HEAD",
"mean": 4.45152019058,
"stddev": 0.0847783951391418,
"median": 4.42572029568,
"user": 1.62973288,
"system": 1.3383206199999997,
"min": 4.39255728018,
"max": 4.6875536041800006,
"times": [
4.42341640318,
4.43744333218,
4.6875536041800006,
4.4594670801800005,
4.41188695018,
4.43660290118,
4.39255728018,
4.41798750318,
4.42802418818,
4.42026266318
]
},
{
"command": "pacquet@main",
"mean": 4.52505221778,
"stddev": 0.13880017320064472,
"median": 4.464305062179999,
"user": 1.6523651799999999,
"system": 1.3506281199999999,
"min": 4.4048441481800005,
"max": 4.76184214718,
"times": [
4.49635927818,
4.41254735218,
4.43225084618,
4.4237706471800005,
4.4048441481800005,
4.72212014318,
4.50021944118,
4.4258353471800005,
4.67073282718,
4.76184214718
]
},
{
"command": "pnpr@HEAD",
"mean": 3.5449707643799995,
"stddev": 0.11586916182082242,
"median": 3.50563807318,
"user": 1.17120058,
"system": 1.21066002,
"min": 3.44322033318,
"max": 3.81898459718,
"times": [
3.81898459718,
3.62802941618,
3.44322033318,
3.44753945418,
3.50250464018,
3.4879271541800003,
3.5794279811800003,
3.58680687818,
3.50877150618,
3.44649568318
]
},
{
"command": "pnpr@main",
"mean": 3.5560848112800003,
"stddev": 0.09985062918369657,
"median": 3.52955620668,
"user": 1.15014828,
"system": 1.18315412,
"min": 3.44988802418,
"max": 3.73586975218,
"times": [
3.46235957918,
3.47424215718,
3.57601403018,
3.73586975218,
3.44988802418,
3.60587694318,
3.50998990818,
3.54912250518,
3.70352641418,
3.49395879918
]
}
]
} |
|
| Project | pnpm's project |
| Branch | pr/13565 |
| 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,421.21 ms |
| isolated-linker.fresh-install.cold-cache.hot-store | 📈 view plot | 280.45 ms |
| isolated-linker.fresh-install.hot-cache.hot-store | 📈 view plot | 297.42 ms |
| isolated-linker.fresh-resolve.hot-cache.offline | 📈 view plot | 84.65 ms |
| isolated-linker.fresh-restore.cold-cache.cold-store | 📈 view plot | 1,364.24 ms |
| isolated-linker.fresh-restore.cold-cache.cold-store.cold-pnpr | 📈 view plot | 3,443.22 ms |
| isolated-linker.fresh-restore.hot-cache.hot-store | 📈 view plot | 259.67 ms |
Summary
Follow-up to #13564, which merged before this could be pushed to it.
Walker::record_walked_nodecallspreviously_resolved_childrentwice withidentical arguments — once to seed the node's graph children, once to seed its
record edges. Each call rescans the ancestor pkg-id chain and, on a match,
re-realizes every matching occurrence's children, so the second one is pure
repeat work in the peer-resolution hot path. The duplication predates
#13564; extracting the phase into one function is what made it visible.
Build the record edges first and iterate them by reference for the graph
children. Cost accounting:
helper early-returns an empty map): one chain scan instead of two, no clones
either way — strictly less work.
call made while rebuilding the map, so the clone count is unchanged, and one
chain scan plus one
realize_childrenpass go away.CodeRabbit raised this on #13564 and suggested cloning the map into the
first loop instead; that trades one cost for another and adds a clone to the hot
path, which #13553 explicitly ruled out. Building the record edges first
removes the call without adding one.
just readygreen — 7541 tests passed, 0 failures.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[1m]).
Need help on this PR? Tag
@codesmith-botwith what you need. Autofix is disabled.