Repository navigation
perf(resolver): build the children SCC table once per hoist round - #16348
Conversation
Profiling a 331-importer, 5,000-package workspace resolution (perf and heaptrack on the micro-benchmark's --full-workspace-resolution runner) put 35 percent of the CPU time in the allocator and 13 percent in memcmp. Almost all of it came from copying immutable identity strings: the dependency walk cloned the whole ancestor-id Vec<String> for every node it seeded (7.5 million of the run's 42 million allocations), copied the package id into every DirectDep, tree node and children-owner claim, and the peer walk re-rendered each package's name and version on every visit and pushed a fresh String onto its ancestor chain per node. Every holder of a pkgIdWithPatchHash now shares the package table's own Arc<str>: ancestor chains are Arc<Vec<Arc<str>>>, DirectDep::id, PendingNodeIdentity::id and the provider index carry the shared id, register_seeded_package and register_reused_package hand it back, and the tree, children and owner maps clone the pointer where they used to re-allocate. ResolvedPackage gains name and version, rendered once by ResolvedPackage::new, and the peer walk reads them instead of calling pkg_name_version per visit; its chains and caches are keyed by the same Arc<str>. Content-based hashing and ordering are unchanged, so lockfile output is identical. Measured on the same machine, idle, three runs each: the plain shape of the full-size scenario (the dependency walk alone) drops from 0.88 s to 0.45 s, the peer-heavy and hoist-heavy shapes by 12 percent, and the CI group workspace_resolution/hoist_heavy from 596 ms to 549 ms. A representation study on the fixture lockfile's keys (String, Arc<str>, string_cache atoms, smol_str) showed that a global interner would cost 2 to 3 times more on construction, 2 to 3 times more under concurrent construction and 5 to 6 times more on borrowed-text lookups, for an equality speedup the resolver does not need once its comparisons hit Arc's pointer-equality fast path. No new dependency is introduced. Co-Authored-By: Claude Fable 5.1 <[email protected]> Claude-Session: https://claude.ai/code/session_01QYTBQo8HY7xD2iz6hjo1CW
…view Every peer-hoist discovery pass created a Walker, and every Walker built the children-graph SCC table behind the canonical cycle gate from scratch on first use. With one pass per importer per hoist round, the same table was recomputed hundreds of times per round: 19 percent of the CPU time and 3.3 million of the allocations of the peer-heavy full-workspace resolution profiled for #16345. The table is a pure function of the tree view's children_by_id, which only changes when the discovery engine refreshes its view between rounds. It now lives on PeerDiscoveryCaches, next to the canonical back-edge occurrences that belong to the same gate, so every walker of one round shares it, and the engine drops it whenever it re-syncs or rebuilds the view. A walker over fresh caches (the final peer pass) still builds it once, as before. Co-Authored-By: Claude Fable 5.1 <[email protected]> Claude-Session: https://claude.ai/code/session_01QYTBQo8HY7xD2iz6hjo1CW
TreeChildren::Lazy carried an AncestorIds chain, documented as the input of a per-occurrence cycle break the peer walk would apply when it expanded the node's children. That cycle break lives in the canonical SCC gate (Walker::cuts_cycle_edge), which cuts the same edges at every occurrence, and nothing reads the chain: AncestorIds::base_ids and appended_ids have no callers. The walk still built the chain for every lazy node it inserted, kept a copy per node in node_parent_ids_by_id so an ownership handover could rebuild it, and the peer walk pushed a new one per lazy realization and per previewed provider child. Lazy is now a unit variant, the per-node chain map and the realization undo state that restored the chain are gone, and the ownership handover flips non-owner occurrences to lazy directly. Behavior is unchanged: the gate decided the edges before and decides them now. Co-Authored-By: Claude Fable 5.1 <[email protected]> Claude-Session: https://claude.ai/code/session_01QYTBQo8HY7xD2iz6hjo1CW
The release note for the cached children SCC table, which lands with the same pull request as the cache itself. Co-Authored-By: Claude Fable 5.1 <[email protected]> Claude-Session: https://claude.ai/code/session_01QYTBQo8HY7xD2iz6hjo1CW
With its ancestor chain gone, LazyProviders is no longer consumed by lazy_provider_children, which clippy's needless_pass_by_value reports. Co-Authored-By: Claude Fable 5.1 <[email protected]> Claude-Session: https://claude.ai/code/session_01QYTBQo8HY7xD2iz6hjo1CW
|
Navigate logical layers of code changes, visualize relationships, and explore their blast radius. Important Review skippedReview was skipped as selected files did not have any reviewable changes. ⚙️ Run configurationConfiguration used: Repository: pnpm/pnpm/.coderabbit.yaml Review profile: CHILL Plan: Advanced Run ID: You can disable this status message by setting the Use the checkbox below for a quick retry:
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: Repository: pnpm/pnpm/.coderabbit.yaml Review profile: CHILL Plan: Advanced Run ID: 📒 Files selected for processing (4)
💤 Files with no reviewable changes (1)
Included review availability: This review used your included allowance. Your plan provides up to 10 included reviews per hour; 9 remain after this review. 📝 WalkthroughWalkthroughThe resolver removes ancestor IDs from lazy dependency-tree nodes and deferred peer-walk data. Peer discovery now shares a cached SCC table and canonical back-edge nodes across peer-hoisting rounds. ChangesPeer cycle resolution
Priority: ➖ Normal Estimated code review effort: 3 (Moderate) | ~25 minutes Change: Refactor Sequence Diagram(s)sequenceDiagram
participant PeerHoistDiscovery
participant CanonicalCycleGate
participant Walker
PeerHoistDiscovery->>CanonicalCycleGate: Advance view generation after tree refresh
Walker->>CanonicalCycleGate: Read or rebuild SCC table for current generation
Walker->>CanonicalCycleGate: Read or store canonical back-edge node
Suggested labels: Merge Risk: ⚪ Minimal · up to The change reduces repeated cycle-table computation and removes unused ancestry metadata. No concrete merge-blocking issue is established; merge after normal checks pass. Security Architecture ReviewSecurity architecture risk: 🔵 Low · up to The reviewed paths preserve protections against cyclic dependency inputs and refresh cached decisions when inputs change. No introduced security issue was identified, but compatibility with external consumers and broader security coverage remain unverified. Retained concerns Security review detailsSecurity Blast Radius
Trust Boundaries and Controls
Resilience and Maintainability Implications
✨ 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 #16348 +/- ##
==========================================
- Coverage 92.20% 92.19% -0.01%
==========================================
Files 1526 1526
Lines 205424 205390 -34
==========================================
- Hits 189409 189369 -40
- Misses 16015 16021 +6 ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
Same-run regression checkHEAD and main are measured on the same runner. The tolerance is 5% of the main median or 2 ms, whichever is larger. A regression requires both the median slowdown and the gap between the fastest retained HEAD sample and slowest retained main sample to exceed this tolerance, after trimming up to 10% from each tail. Suspected regressions are rerun once with target order reversed and only fail if reproduced. This conservative noise guard is not a statistical confidence interval. Inconclusive rows do not fail the check. They remain visible for performance review. Bencher retains absolute minimum timings for historical tracking; historical alerts do not gate this PR. Sequential measurements can still be affected by runner drift.
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; the linked-workspace scenario compares current Rust against main Rust. Bencher consumes pacquet@HEAD and pnpr@HEAD. The tables below show mean ± σ. Bencher tracks absolute minimum latency; PR regression checks compare HEAD and main samples from the same runner. Historical timing alerts do not gate PRs. Scenario: Isolated linker: fresh restore, cold cache + cold store
BENCHMARK_REPORT.json{
"results": [
{
"command": "pacquet@HEAD",
"mean": 2.45651057006,
"stddev": 0.18806967451729864,
"median": 2.39692307006,
"user": 1.56568688,
"system": 1.5125753599999998,
"min": 2.2656074035600002,
"max": 2.81498880956
},
{
"command": "pacquet@main",
"mean": 2.3904360067600003,
"stddev": 0.10572093124949684,
"median": 2.38635587006,
"user": 1.44205388,
"system": 1.43297476,
"min": 2.27098795656,
"max": 2.59527126156
},
{
"command": "pnpr@HEAD",
"mean": 1.51393733546,
"stddev": 0.1335456708006067,
"median": 1.48337899656,
"user": 1.4396016799999998,
"system": 1.5293484600000002,
"min": 1.3188095415599999,
"max": 1.73660777456
},
{
"command": "pnpr@main",
"mean": 1.4895392044599998,
"stddev": 0.13129906065862051,
"median": 1.48854981606,
"user": 1.5062842799999996,
"system": 1.43245336,
"min": 1.3199216915599998,
"max": 1.70437642256
}
]
}Scenario: Isolated linker: fresh restore, hot cache + hot store
BENCHMARK_REPORT.json{
"results": [
{
"command": "pacquet@HEAD",
"mean": 0.32011679032,
"stddev": 0.015387460160098615,
"median": 0.32016347372,
"user": 0.38405249999999996,
"system": 0.79276988,
"min": 0.28933992822,
"max": 0.34343195922
},
{
"command": "pacquet@main",
"mean": 0.32142630542000006,
"stddev": 0.014392210270111509,
"median": 0.31735271672,
"user": 0.3643640999999999,
"system": 0.82638688,
"min": 0.30727795522,
"max": 0.34952039222
},
{
"command": "pnpr@HEAD",
"mean": 0.38617124862,
"stddev": 0.04021244235171656,
"median": 0.38043348522,
"user": 0.4283118999999999,
"system": 0.9437237799999998,
"min": 0.33607782622,
"max": 0.43094168922000003
},
{
"command": "pnpr@main",
"mean": 0.36483858051999996,
"stddev": 0.017374520194790067,
"median": 0.37091124622,
"user": 0.4038653,
"system": 0.8638785800000001,
"min": 0.33612295822,
"max": 0.38360121322
}
]
}Scenario: Isolated linker: repeat install, hot cache + hot store
BENCHMARK_REPORT.json{
"results": [
{
"command": "pacquet@HEAD",
"mean": 0.012880828288421053,
"stddev": 0.0021325355782682892,
"median": 0.01229249502,
"user": 0.006996229473684208,
"system": 0.007047030526315791,
"min": 0.01048757252,
"max": 0.022361614520000003
},
{
"command": "pacquet@main",
"mean": 0.01107322846146342,
"stddev": 0.0017198031419848575,
"median": 0.010833071520000001,
"user": 0.006390893658536586,
"system": 0.005549599999999998,
"min": 0.00786630152,
"max": 0.017702702520000002
},
{
"command": "pnpr@HEAD",
"mean": 0.0119402027442647,
"stddev": 0.0022512113298440634,
"median": 0.011865520519999999,
"user": 0.006815560588235291,
"system": 0.006125795588235299,
"min": 0.00804471752,
"max": 0.021927053520000003
},
{
"command": "pnpr@main",
"mean": 0.011530764200272109,
"stddev": 0.001553677099772894,
"median": 0.011248438520000001,
"user": 0.007096642721088432,
"system": 0.005427994557823129,
"min": 0.00913421052,
"max": 0.01882103552
}
]
}Scenario: Isolated linker: repeat install, cold cache + hot store
BENCHMARK_REPORT.json{
"results": [
{
"command": "pacquet@HEAD",
"mean": 0.015471475480740744,
"stddev": 0.004100628514452825,
"median": 0.01593802214,
"user": 0.008055927999999999,
"system": 0.00890698444444444,
"min": 0.007627861140000001,
"max": 0.02575985214
},
{
"command": "pacquet@main",
"mean": 0.008609418846349212,
"stddev": 0.0011257672838272865,
"median": 0.008270972640000002,
"user": 0.004836237619047619,
"system": 0.004768256746031745,
"min": 0.007322192140000001,
"max": 0.014762994140000003
},
{
"command": "pnpr@HEAD",
"mean": 0.008536631947843144,
"stddev": 0.0011600661023688954,
"median": 0.00815890214,
"user": 0.0044340170980392175,
"system": 0.005050336862745098,
"min": 0.007448138140000001,
"max": 0.01435005014
},
{
"command": "pnpr@main",
"mean": 0.008809582542010055,
"stddev": 0.0014691551627135572,
"median": 0.008341901140000002,
"user": 0.004792502110552765,
"system": 0.005030227135678394,
"min": 0.0072636461400000015,
"max": 0.015371070140000002
}
]
}Scenario: Isolated linker: fresh install, cold cache + cold store
BENCHMARK_REPORT.json{
"results": [
{
"command": "pacquet@HEAD",
"mean": 2.6984192924999997,
"stddev": 0.11597319605479951,
"median": 2.6722254053,
"user": 2.4858232599999996,
"system": 1.9115951,
"min": 2.6338221268,
"max": 3.0209292698
},
{
"command": "pacquet@main",
"mean": 2.6642691415999997,
"stddev": 0.03100468947780665,
"median": 2.6719777118000003,
"user": 2.37868266,
"system": 1.8483011999999994,
"min": 2.6187810538,
"max": 2.7082473568
},
{
"command": "pnpr@HEAD",
"mean": 1.5638149359,
"stddev": 0.10029698690564627,
"median": 1.5301690632999998,
"user": 1.4549001599999998,
"system": 1.5722300999999999,
"min": 1.4301760527999998,
"max": 1.8051966477999999
},
{
"command": "pnpr@main",
"mean": 1.6082356498,
"stddev": 0.09080477490761915,
"median": 1.5947134938,
"user": 1.5102761599999999,
"system": 1.5834350999999998,
"min": 1.4909189658,
"max": 1.7491498887999999
}
]
}Scenario: Isolated linker: fresh install, hot cache + hot store
BENCHMARK_REPORT.json{
"results": [
{
"command": "pacquet@HEAD",
"mean": 0.5010280669800001,
"stddev": 0.07374359406835468,
"median": 0.47758189058000006,
"user": 0.7035124799999999,
"system": 0.77532344,
"min": 0.43710744058000006,
"max": 0.65846286258
},
{
"command": "pacquet@main",
"mean": 0.5406980511799999,
"stddev": 0.10469042761496815,
"median": 0.49225124708,
"user": 0.7545178799999999,
"system": 0.8633071400000001,
"min": 0.43137577458000004,
"max": 0.67237842958
},
{
"command": "pnpr@HEAD",
"mean": 0.30360506357999995,
"stddev": 0.014362833142672907,
"median": 0.30957915308000006,
"user": 0.24632237999999998,
"system": 0.61473224,
"min": 0.27065186058,
"max": 0.31867727558000003
},
{
"command": "pnpr@main",
"mean": 0.32827582898,
"stddev": 0.019511263063029187,
"median": 0.32993373758000005,
"user": 0.27710808,
"system": 0.6298973400000001,
"min": 0.29485884858000005,
"max": 0.36895202158000007
}
]
}Scenario: Isolated linker: fresh install, cold cache + hot store
BENCHMARK_REPORT.json{
"results": [
{
"command": "pacquet@HEAD",
"mean": 1.8190344982000002,
"stddev": 0.0458967117937587,
"median": 1.8256106420000002,
"user": 1.2599269199999998,
"system": 1.0355917,
"min": 1.7618161715000002,
"max": 1.9060020885
},
{
"command": "pacquet@main",
"mean": 1.6567643190999999,
"stddev": 0.032397338235940785,
"median": 1.646931197,
"user": 0.97931802,
"system": 0.8893375999999998,
"min": 1.6063156655000002,
"max": 1.7124880775
},
{
"command": "pnpr@HEAD",
"mean": 0.29760061280000005,
"stddev": 0.017771798552476393,
"median": 0.294580253,
"user": 0.26090062,
"system": 0.5885135999999999,
"min": 0.2781526245,
"max": 0.3397450705
},
{
"command": "pnpr@main",
"mean": 0.32241809320000003,
"stddev": 0.0180611337705798,
"median": 0.319184177,
"user": 0.27867632000000003,
"system": 0.6218351999999999,
"min": 0.3013422155,
"max": 0.3481459335
}
]
}Scenario: Isolated linker: fresh resolve, hot cache, offline
BENCHMARK_REPORT.json{
"results": [
{
"command": "pacquet@HEAD",
"mean": 0.24668180564666672,
"stddev": 0.01243195358606403,
"median": 0.24646594198,
"user": 0.2256045833333333,
"system": 0.09312710333333334,
"min": 0.23109997598,
"max": 0.27901726798000004
},
{
"command": "pacquet@main",
"mean": 0.25281630564666663,
"stddev": 0.015261126305195386,
"median": 0.24840448898,
"user": 0.22350258333333337,
"system": 0.09359960333333332,
"min": 0.23285128798000002,
"max": 0.28386238598
},
{
"command": "pnpr@HEAD",
"mean": 0.09691928535931035,
"stddev": 0.002739662964342763,
"median": 0.09689374498,
"user": 0.03813706896551723,
"system": 0.014595053793103451,
"min": 0.09168419298000001,
"max": 0.10353866398
},
{
"command": "pnpr@main",
"mean": 0.11518499038000005,
"stddev": 0.019177412705017282,
"median": 0.11371594348,
"user": 0.05069286666666666,
"system": 0.024365053333333338,
"min": 0.09285571698,
"max": 0.14701378198
}
]
}Scenario: Isolated linker: peer-heavy resolve, hot cache, offline
BENCHMARK_REPORT.json{
"results": [
{
"command": "pacquet@HEAD",
"mean": 0.2390739751533334,
"stddev": 0.010785941219068597,
"median": 0.24355929782000002,
"user": 0.2398257755555555,
"system": 0.06942744666666666,
"min": 0.22144346382000002,
"max": 0.25178644082
},
{
"command": "pacquet@main",
"mean": 0.24148365226444446,
"stddev": 0.012090270218552877,
"median": 0.23638963782000003,
"user": 0.24448966444444442,
"system": 0.06638066888888888,
"min": 0.23021180882000003,
"max": 0.26500468982
},
{
"command": "pnpm@HEAD",
"mean": 4.228762255042223,
"stddev": 0.16335255995018885,
"median": 4.20928809082,
"user": 6.280630997777778,
"system": 0.5727426688888888,
"min": 4.03172281482,
"max": 4.54471650282
}
]
}Scenario: Isolated linker: linked-workspace resolve, hot cache, offline
BENCHMARK_REPORT.json{
"results": [
{
"command": "pacquet@HEAD",
"mean": 0.21026629699846155,
"stddev": 0.0034041114066480378,
"median": 0.21020348046,
"user": 0.16587962615384616,
"system": 0.07964972000000001,
"min": 0.20610507446,
"max": 0.21739537346
},
{
"command": "pacquet@main",
"mean": 0.20577795274571434,
"stddev": 0.0015858345036541212,
"median": 0.20599608896,
"user": 0.15840663714285716,
"system": 0.08184679142857143,
"min": 0.20329311746,
"max": 0.20976152946
}
]
}Scenario: Isolated linker: fresh restore, cold cache + cold store + cold pnpr
BENCHMARK_REPORT.json{
"results": [
{
"command": "pacquet@HEAD",
"mean": 4.57432383854,
"stddev": 0.1657670648145571,
"median": 4.512850394539999,
"user": 1.9079318399999998,
"system": 2.1055204800000005,
"min": 4.43799502504,
"max": 4.9099699680399995
},
{
"command": "pacquet@main",
"mean": 4.7050643477400005,
"stddev": 0.16108308047478517,
"median": 4.65877856704,
"user": 1.9687197399999998,
"system": 2.07214088,
"min": 4.47710536704,
"max": 5.01325781904
},
{
"command": "pnpr@HEAD",
"mean": 3.62241050364,
"stddev": 0.1133899839046266,
"median": 3.57267804704,
"user": 1.7855764399999998,
"system": 1.9293135799999999,
"min": 3.5232640640399997,
"max": 3.87373813004
},
{
"command": "pnpr@main",
"mean": 3.644146929339999,
"stddev": 0.056786653718453796,
"median": 3.65019612554,
"user": 1.91928084,
"system": 1.95680138,
"min": 3.53895031704,
"max": 3.73498052204
}
]
}Scenario: GVS linker: fresh restore, hot cache + hot storeSame install as the isolated fresh-restore hot/hot scenario, into the shared virtual store, the layout pnpm 12 installs into by default. Scenarios run on separate machines, so compare main and branch within each table.
BENCHMARK_REPORT.json{
"results": [
{
"command": "pacquet@HEAD",
"mean": 0.14459077839999995,
"stddev": 0.011454169824766576,
"median": 0.1439499524,
"user": 0.18530584315789472,
"system": 0.14737678105263158,
"min": 0.12752097340000002,
"max": 0.1816080504
},
{
"command": "pacquet@main",
"mean": 0.1357932969,
"stddev": 0.004637861250031063,
"median": 0.13464998290000002,
"user": 0.17299646888888887,
"system": 0.13854147111111115,
"min": 0.1285859184,
"max": 0.1456811174
},
{
"command": "pnpr@HEAD",
"mean": 0.14702580534736845,
"stddev": 0.008214767420587613,
"median": 0.1437458604,
"user": 0.1758641063157895,
"system": 0.14671630736842103,
"min": 0.1348169404,
"max": 0.16983378740000002
},
{
"command": "pnpr@main",
"mean": 0.1762628295666667,
"stddev": 0.04510164773349919,
"median": 0.1544062394,
"user": 0.20472616333333335,
"system": 0.17933385999999998,
"min": 0.1288823044,
"max": 0.2437798844
}
]
} |
…entity private ResolvedPackage::name and ::version are rendered from ::result once, in ResolvedPackage::new, and nothing else may set them. With the three fields public that was a convention, not a guarantee: a caller holding a &mut ResolvedPackage (the package table hands them out for the optional AND-fold) could assign a new result or Arc::make_mut the existing one and leave the rendered pair stale, and two peer tests did exactly that to turn a registry fixture into a tarball provider. The three fields are private now and read through result(), name() and version(). name() and version() return the &Arc<str> so the peer walk keeps sharing them into ParentRef and NodeEntry by Arc::clone and derefs to the &str everywhere else. The tarball tests build the mutated ResolveResult first and wrap it with ResolvedPackage::new, and the one struct-update fixture sets its peer dependencies after construction instead. Co-Authored-By: Claude Fable 5.1 <[email protected]> Claude-Session: https://claude.ai/code/session_01QYTBQo8HY7xD2iz6hjo1CW
ResolvedPackage::new took five positional arguments ending in two bools, so a construction site read `false, false` or `true, true` without saying which value was `optional` and which `is_leaf`. It now takes a ResolvedPackageInput carrying the same values as named fields, which every construction site spells out. The constructor still renders name and version from the input's result once. The type follows the crate's existing input structs (ImporterPeerInput, ImporterResolutionInputs) in name. Co-Authored-By: Claude Fable 5.1 <[email protected]> Claude-Session: https://claude.ai/code/session_01QYTBQo8HY7xD2iz6hjo1CW
…group
The workspace-context tests imported ResolvedPackageInput through a
second `use crate::...` item next to the file's existing
`use crate::{..}` group, which perfectionist's
import_granularity_mismatch lint rejects in the pre-push hook. The name
now sits in that group.
Co-Authored-By: Claude Fable 5.1 <[email protected]>
Claude-Session: https://claude.ai/code/session_01QYTBQo8HY7xD2iz6hjo1CW
…allen-wjiv3n-followups # Conflicts: # pnpm/crates/resolving-deps-resolver/src/lib.rs
Brings in the 16 commits main gained since this branch was started, up to d162953 (#16362). Four of them touch files this branch also changes (resolve_peers.rs, resolve_peers/finalize.rs, finalize/final_paths.rs and resolve_peers/walker.rs, from the peer-dependent dedupe work in #16359 and #16361); git merged them without conflicts, and none of main's new code reads the ResolvedPackage fields this branch made private. Co-Authored-By: Claude Fable 5.1 <[email protected]> Claude-Session: https://claude.ai/code/session_01QYTBQo8HY7xD2iz6hjo1CW
Drop the prose that restated the code or recorded the reasons for a change: the paragraph on ResolvedPackage repeating that its fields are private, the field notes on ParentRef::version and ChildrenOwner::parent_path, the allocation-sharing clauses on AncestorPkgIds, DirectDep::id and the two package-table registrations, the module doc and the rationale in package_identity.rs, and the doc on the tarball test helper. What stays states a contract: which Arc a registration answers with, and which name and version the accessors yield. Co-Authored-By: Claude Fable 5.1 <[email protected]> Claude-Session: https://claude.ai/code/session_01QYTBQo8HY7xD2iz6hjo1CW
…branch Brings the base branch's merge of main (up to d162953, #16362) and its comment trim into the follow-ups. The trial merge was clean: main's resolver changes and the SCC-cache and lazy-ancestor commits touch different code. Co-Authored-By: Claude Fable 5.1 <[email protected]> Claude-Session: https://claude.ai/code/session_01QYTBQo8HY7xD2iz6hjo1CW
Brings in main up to 417ab35, which carries the squash merge of #16345 (a949da4), the base this branch was stacked on. The squash re-applies that PR's changes on top of main, so every resolver file this branch modified further conflicted against content it already holds; each is resolved to this branch's version, and the base PR's changeset takes main's wording. Check: the resolver crate's diff against main after the merge equals the diff this branch had against 747ef0b. Co-Authored-By: Claude Fable 5.1 <[email protected]> Claude-Session: https://claude.ai/code/session_01QYTBQo8HY7xD2iz6hjo1CW
The release note reported benchmark timings, which vary by machine and by workspace shape; it now says what the resolver does differently, as asked in the review of #16345. Co-Authored-By: Claude Fable 5.1 <[email protected]> Claude-Session: https://claude.ai/code/session_01QYTBQo8HY7xD2iz6hjo1CW
Review Summary
Reviewed by Antigravity Agent per pnpm review guide. |
Brings in main up to 28814c6 before the cycle-gate encapsulation commits; none of the new commits touches a file this branch changes. Co-Authored-By: Claude Fable 5.1 <[email protected]> Claude-Session: https://claude.ai/code/session_01QYTBQo8HY7xD2iz6hjo1CW
CanonicalCycleGate::sccs is private. CanonicalCycleGate::table builds the table from the tree it is given and shares it until CanonicalCycleGate::invalidate, which the discovery engine calls when it refreshes or rebuilds its view. Before, the cell was pub(super), any code under resolve_peers could fill or clear it, and the walker filled it in place, so the invariant that the table matches the view rested on convention. The builder stays in walker/missing_names.rs and is re-exported to the gate. Co-Authored-By: Claude Fable 5.1 <[email protected]> Claude-Session: https://claude.ai/code/session_01QYTBQo8HY7xD2iz6hjo1CW
…neration The discovery engine counts its view refreshes and rebuilds in PeerDiscoveryCaches::view_generation. CanonicalCycleGate::table records the generation it built the table under and rebuilds when read under a newer one, so a stale table cannot be served even if a future refresh path forgets to drop it; CanonicalCycleGate::invalidate is gone. The generation belongs to the view, so any other cache derived from the view can validate against it the same way. Co-Authored-By: Claude Fable 5.1 <[email protected]> Claude-Session: https://claude.ai/code/session_01QYTBQo8HY7xD2iz6hjo1CW
…e-exports The ordering lint wants every re-export above the module declarations; the one added for the cycle gate sat below them. It joins the walker's existing missing_names re-export, so the builder is pub(crate) like its neighbours. Co-Authored-By: Claude Fable 5.1 <[email protected]> Claude-Session: https://claude.ai/code/session_01QYTBQo8HY7xD2iz6hjo1CW
The provider-children index and the peer names it was built under were two fields refreshed together by a free function in the walker. They are one PeerProviderIndex now, refreshed by its own method, and the peer names, the index's validity key, are private to it. This also keeps PeerDiscoveryCaches within the field limit after view_generation. Co-Authored-By: Claude Fable 5.1 <[email protected]> Claude-Session: https://claude.ai/code/session_01QYTBQo8HY7xD2iz6hjo1CW
The dependency-tree modules and the peer-resolution tests spelled the type out as crate::resolved_tree::TreeChildren at every use, while the peer-resolution modules import it. The files this PR touches now import it through the same use-super chains their other names come through, and the Arc::new calls on those lines drop their std::sync:: prefix. Co-Authored-By: Claude Fable 5.1 <[email protected]> Claude-Session: https://claude.ai/code/session_01QYTBQo8HY7xD2iz6hjo1CW
Brings main up to 17e8a01 (#16460). None of the merged commits touch the resolver crate; the merge is conflict-free. Co-Authored-By: Claude Fable 5.1 <[email protected]> Claude-Session: https://claude.ai/code/session_01QYTBQo8HY7xD2iz6hjo1CW
The two tests added for the cycle gate's view-generation stamp ran on empty trees, so they only pinned pointer identity and a counter. They now run on a mutual dependency: one test checks that the gate groups the cycle and cuts exactly its back-edge, one checks that reads under one view generation share the table and a newer generation rebuilds it from the current view, and one drives the discovery engine through a hoist round that installs a dependency cycle and checks that the refreshed gate knows the cycle and the walk over it completes. Each test was checked against a broken implementation (a gate that ignores the generation, a gate that never caches, an engine that keeps its generation, a gate that cuts the wrong edge, and an SCC pass that finds no cycles) and fails on the assertion that names the break. The ring fixture's edge and lazy-direct-dep helpers move to the shared test support so both test modules build trees the same way. Co-Authored-By: Claude Fable 5.1 <[email protected]> Claude-Session: https://claude.ai/code/session_01QYTBQo8HY7xD2iz6hjo1CW
PeerDiscoveryCaches::view_generation was a u64 whose only mutation is the increment in PeerHoistDiscovery::discover; the gate stamps its SCC table with it and compares for equality. ViewGeneration offers exactly that: advance() and equality, no arithmetic and no construction from a number, so a generation cannot be confused with any other count. The doc that explained the generation on the field now lives on the type. The two generation mutations (a gate that ignores the generation, an engine that never advances it) still fail the discovery tests on the assertions that name them. Co-Authored-By: Claude Fable 5.1 <[email protected]> Claude-Session: https://claude.ai/code/session_01QYTBQo8HY7xD2iz6hjo1CW
The doc on PeerProviderIndex::peer_names restated the rule that PeerProviderIndex::refresh documents (rebuild when the tree's peer names differ from the ones the index was built under) and gave the reason, which had no other home. The reason now sits on the type, next to what the index is, and both fields stand on their names. Co-Authored-By: Claude Fable 5.1 <[email protected]> Claude-Session: https://claude.ai/code/session_01QYTBQo8HY7xD2iz6hjo1CW
The docs this PR added narrated mechanism that other items already state: the cut rule on CanonicalCycleGate::sccs repeated Walker::cuts_cycle_edge, the build-share-rebuild lifecycle appeared on ViewGeneration, on the sccs field and on CanonicalCycleGate::table, and realize_children listed the steps of its body. Each doc now says what the item is and links the item that holds the rule, so a rename fails the doc build instead of leaving prose behind. The test comments give the reason for the step they precede, and the Lazy variant's doc no longer argues for the state it does not carry. Co-Authored-By: Claude Fable 5.1 <[email protected]> Claude-Session: https://claude.ai/code/session_01QYTBQo8HY7xD2iz6hjo1CW
KSXGitHub
left a comment
There was a problem hiding this comment.
There might have been some diff noises.
Brings main up to 2a25e6a. The merge is conflict-free. Co-Authored-By: Claude Fable 5.1 <[email protected]> Claude-Session: https://claude.ai/code/session_01QYTBQo8HY7xD2iz6hjo1CW
The documentation review reduced two docs that main already had and this PR edits only where the ancestor chain went away: the step list on realize_children and the second sentence of merge_realize_undo. Reducing them is diff noise, so both return to their wording before the review, as the PR review asked. Co-Authored-By: Claude Fable 5.1 <[email protected]> Claude-Session: https://claude.ai/code/session_01QYTBQo8HY7xD2iz6hjo1CW
…details It had to be edited anyway
There was a problem hiding this comment.
Copilot review overview
🔵 Needs a closer look
The core peer-resolution cycle and cache invariants are sufficiently intricate to warrant final human validation despite focused regression coverage.
Review effort: Balanced
Findings: None
What changed in this PR
Optimizes the Rust v12 peer resolver by caching the canonical SCC table per discovery-tree generation and removing unused lazy-node ancestor chains.
Changes:
- Shares one generation-validated cycle table across walkers.
- Simplifies
TreeChildren::Lazyto a unit variant. - Adds focused cycle-gate tests and a
pacquetchangeset.
| File | Description |
|---|---|
.changeset/cache-children-cycle-table.md |
Records the resolver performance improvement. |
pnpm/crates/package-manager/src/dependencies_graph_to_lockfile/tests/resolution.rs |
Updates a lazy-node fixture. |
pnpm/crates/resolving-deps-resolver/src/lib.rs |
Removes the obsolete public AncestorIds export. |
pnpm/crates/resolving-deps-resolver/src/resolved_tree.rs |
Removes ancestor-chain storage from lazy children. |
pnpm/crates/resolving-deps-resolver/src/resolve_dependency_tree/reuse.rs |
Stops recording unused parent IDs. |
pnpm/crates/resolving-deps-resolver/src/resolve_dependency_tree/reuse/snapshot_children.rs |
Uses unit lazy children during reuse. |
pnpm/crates/resolving-deps-resolver/src/resolve_dependency_tree/walk.rs |
Updates imports for simplified lazy children. |
pnpm/crates/resolving-deps-resolver/src/resolve_dependency_tree/walk/level_walk.rs |
Creates lazy nodes without ancestor chains. |
pnpm/crates/resolving-deps-resolver/src/resolve_dependency_tree/workspace_ctx.rs |
Removes parent-ID workspace storage. |
pnpm/crates/resolving-deps-resolver/src/resolve_dependency_tree/workspace_ctx/children_ownership.rs |
Simplifies ownership handovers to unit lazy nodes. |
pnpm/crates/resolving-deps-resolver/src/resolve_dependency_tree/workspace_ctx/tests.rs |
Updates ownership and lazy-node assertions. |
pnpm/crates/resolving-deps-resolver/src/resolve_peers/cache.rs |
Removes ancestor state from realization contexts. |
pnpm/crates/resolving-deps-resolver/src/resolve_peers/cache/fast_match.rs |
Uses the consolidated provider index and unit variant. |
pnpm/crates/resolving-deps-resolver/src/resolve_peers/cache/realize_children.rs |
Applies the canonical gate without ancestor chains. |
pnpm/crates/resolving-deps-resolver/src/resolve_peers/discovery.rs |
Adds generation-aware SCC and provider caches. |
pnpm/crates/resolving-deps-resolver/src/resolve_peers/discovery/tests.rs |
Tests SCC cuts, caching, and view refreshes. |
pnpm/crates/resolving-deps-resolver/src/resolve_peers/test_support.rs |
Adds reusable lazy-node and edge fixtures. |
pnpm/crates/resolving-deps-resolver/src/resolve_peers/tests.rs |
Refactors peer-cycle fixtures to shared helpers. |
pnpm/crates/resolving-deps-resolver/src/resolve_peers/tests/behavior.rs |
Updates a lazy-node fixture. |
pnpm/crates/resolving-deps-resolver/src/resolve_peers/tests/peer_dependencies_own_peer_is_resolved.rs |
Updates cycle-test lazy nodes. |
pnpm/crates/resolving-deps-resolver/src/resolve_peers/tests/resolution_order.rs |
Updates resolution-order fixtures. |
pnpm/crates/resolving-deps-resolver/src/resolve_peers/walker.rs |
Reads SCCs and back-edge nodes from shared caches. |
pnpm/crates/resolving-deps-resolver/src/resolve_peers/walker/child_walk.rs |
Removes ancestor propagation from deferred walks. |
pnpm/crates/resolving-deps-resolver/src/resolve_peers/walker/missing_names.rs |
Exposes SCC construction to discovery caching. |
pnpm/crates/resolving-deps-resolver/src/resolve_peers/walker/node_walk.rs |
Simplifies deferred-child inputs. |
pnpm/crates/resolving-deps-resolver/src/resolve_peers/walker/walk_context.rs |
Simplifies deferred walk state and exposes indexing. |
pnpm/crates/resolving-deps-resolver/src/tests/peers/behavior.rs |
Updates lazy-child matching assertions. |
💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.
Brings main up to 5a389e4. The merge is conflict-free. Co-Authored-By: Claude Fable 5.1 <[email protected]> Claude-Session: https://claude.ai/code/session_01QYTBQo8HY7xD2iz6hjo1CW
deploy/target.rs reached 403 lines of code after the recent deploy fixes, above perfectionist's limit of 400, which fails the dylint job on every pull request that includes them. The lexical path comparison (same_path, ProjectPathKey, has_path_prefix, the component helpers, relative_components_from_child and relative_path) is a leaf concern the rest of target.rs and deploy.rs call, so it moves to deploy/paths.rs, a sibling module like the others under deploy/. No function body changes. Co-Authored-By: Claude Fable 5.1 <[email protected]> Claude-Session: https://claude.ai/code/session_01QYTBQo8HY7xD2iz6hjo1CW
Brings main up to 2f41427, whose refactor moves the deploy path comparison out of target.rs into path_compare.rs, the same split this branch made in c1ddbfb under the name paths.rs. The conflicts in deploy.rs and target.rs are resolved to main's version and the branch's paths.rs is removed, so the CLI crate is identical to main again. Co-Authored-By: Claude Fable 5.1 <[email protected]> Claude-Session: https://claude.ai/code/session_01QYTBQo8HY7xD2iz6hjo1CW

Summary
Two follow-ups to #16345 in the peer resolver. Base is
main; the commit list still shows the base PR's own commits, which main carries as the squasha949da4. The diff against main is 27 files (+365, -332): the two changes below, their tests, a changeset and a one-line clippy fix.1. Build the children SCC table once per discovery tree view
Walker, and each walker rebuilt the children-graph SCC table behind the canonical cycle gate on first use. One pass per importer per hoist round meant hundreds of rebuilds of the same table per round: 19 percent of the CPU time and 3.3 million allocations of the peer-heavy profile behind perf(resolver): share package ids across the walk and the peer pass #16345.PeerDiscoveryCaches, in a newCanonicalCycleGatenext to the canonical back-edge occurrences of the same gate, and every walker over one tree view shares it. The final peer pass starts from fresh caches and builds it once, as before.children_by_id, so it must never outlive the view it was built from. The cell is private;CanonicalCycleGate::tableis the only way to fill it, from the tree it is given, and it stamps the table with the engine's view generation. That generation is aViewGenerationnewtype whose only operations areadvanceand equality:PeerHoistDiscoveryadvances it whenever it refreshes or rebuilds its view, and a read under a different generation rebuilds the table, so nothing depends on remembering to drop it.PeerProviderIndexon the same caches, with the peer names private to it.2. Drop the unread ancestor ids of lazy children
TreeChildren::Lazycarried anAncestorIdschain meant for a per-occurrence cycle break. The peer walk's cycle break is the canonical SCC gate (Walker::cuts_cycle_edge), which cuts the same edges at every occurrence, and nothing read the chain:base_idsandappended_idshad no callers.AncestorIds(public type), thenode_parent_ids_by_idmap and theremember_node_parent_idsandlazy_childrenhelpers in the dependency walk, the chain fields on the peer walk's realization and deferred-child state, and the undo state that restored the chain.Lazyis a unit variant; the ownership handover flips non-owner occurrences to lazy directly, without collecting their chains under a second lock.TreeChildreninstead of spelling outcrate::resolved_tree::TreeChildrenat each use.Not in this PR
A CI benchmark for the lockfile-reuse resolution path. It needs a fixture-backed wanted lockfile built through
pnpm-package-manager, which is a benchmark-harness change of its own.Measurements
One machine, idle, three runs each of
micro-benchmark --full-workspace-resolution(331 importers, 5,000 packages) plus the CI criterion group. "Base" is the head of #16345 at the time.real)workspace_resolution/hoist_heavy(criterion)Change 1 takes 26 to 39 percent off the two peer shapes on that machine; change 2 moves no measured time. CI's own micro-benchmark, main against the PR on one runner, has varied between heads: one run showed the criterion group unchanged (318 ms against 324 ms), a later run showed it 17 percent faster (252 ms against 209 ms). CI does not run the full-size peer shapes.
Verification
Run locally on the merged tree: pinned rustfmt,
taplo format --check,typos,cargo check,cargo clippy -- -D warnings,cargo docwith-D warningsand private items (with and without--all-features),cargo dylint,cargo deny check;pnpm test:rust -p pnpm-resolving-deps-resolver429 passed;pnpm test:rust-affected1,315 passed, 1 skipped, smoke profile 23 passed. Main was merged up to 2f41427 withchore(git)commits; the squash of #16345 made this branch's resolver files conflict once, each was resolved to this branch's version, and the crate's diff against main was checked byte-identical to the diff against the previous base. The branch briefly carried its own split ofdeploy/target.rsbelow the 400-line file limit; main's #16480 made the same split, and the merge takes main's version, so the CLI crate is identical to main.Squash Commit Body
Checklist
are implemented in every affected version. (pnpm v12 resolver performance
and cleanup only.)
pnpm changeset) if this PR changes any publishedpackage. Keep it short and written for pnpm users — it becomes a release note.
cover both changes; fixtures were updated for the unit
Lazyvariant,no assertion changed; three unit tests cover the cycle gate and the
engine's refresh of it, each checked against a broken implementation.)
Written by an agent (Claude Code, Claude Fable 5.1).
🤖 Generated with Claude Code
https://claude.ai/code/session_01QYTBQo8HY7xD2iz6hjo1CW
Generated by Claude Code