perf(pacquet): collapse leaf-package occurrences in the dependencies tree#11847
Conversation
…tree Mirrors pnpm's `pkgIsLeaf` reuse: a package with no `dependencies`, `optionalDependencies`, `peerDependencies`, or `peerDependenciesMeta` collapses every parent reference onto one tree node keyed by the package id, instead of allocating a fresh `NodeId` per occurrence. Peer resolution and every downstream `HashMap<NodeId, _>` see the reduced node set. Closes #11844.
Qodo reviews are paused for this user.Troubleshooting steps vary by plan Learn more → On a Teams plan? Using GitHub Enterprise Server, GitLab Self-Managed, or Bitbucket Data Center? |
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: Organization UI Review profile: CHILL Plan: Pro Plus Run ID: 📒 Files selected for processing (5)
📜 Recent review details⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (7)
🧰 Additional context used📓 Path-based instructions (1)pacquet/**/*.rs📄 CodeRabbit inference engine (pacquet/AGENTS.md)
Files:
🧠 Learnings (3)📚 Learning: 2026-05-20T19:40:55.051ZApplied to files:
📚 Learning: 2026-05-22T00:08:44.646ZApplied to files:
📚 Learning: 2026-05-20T23:07:58.444ZApplied to files:
🔇 Additional comments (7)
📝 WalkthroughWalkthrough
ChangesLeaf-Node Collapse Optimization
Estimated code review effort🎯 3 (Moderate) | ⏱️ ~25 minutes Possibly related issues
Possibly related PRs
Poem
🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ 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 #11847 +/- ##
==========================================
+ Coverage 87.51% 87.55% +0.03%
==========================================
Files 204 204
Lines 24371 24394 +23
==========================================
+ Hits 21329 21357 +28
+ Misses 3042 3037 -5 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
Integrated-Benchmark Report (Linux)Scenario: Frozen Lockfile
BENCHMARK_REPORT.json{
"results": [
{
"command": "pacquet@HEAD",
"mean": 2.4866053679,
"stddev": 0.12132253999547483,
"median": 2.4296696102,
"user": 2.7391414399999996,
"system": 3.81943874,
"min": 2.3647601987,
"max": 2.6933798316999997,
"times": [
2.6933798316999997,
2.6508669067,
2.3928174137,
2.5327857027,
2.5891716476999997,
2.3647601987,
2.3994090767,
2.3948123007,
2.4599301437,
2.3881204567
]
},
{
"command": "pacquet@main",
"mean": 2.4988154719,
"stddev": 0.0911977637056548,
"median": 2.5119665567,
"user": 2.79810594,
"system": 3.8081689399999994,
"min": 2.3622272986999997,
"max": 2.6554170047,
"times": [
2.4472507267,
2.5068809927,
2.5365787607,
2.3866953637,
2.3622272986999997,
2.6554170047,
2.5170521207,
2.4378851577,
2.5463718847,
2.5917954087
]
},
{
"command": "pnpm",
"mean": 4.931267035399999,
"stddev": 0.03334715751915896,
"median": 4.9247512977,
"user": 8.34141464,
"system": 4.324075439999999,
"min": 4.8875247087,
"max": 4.9887522717,
"times": [
4.9207839177,
4.8875247087,
4.9454972217,
4.9068063797,
4.9527176427,
4.9287186777,
4.9887522717,
4.8984629007,
4.9091528236999995,
4.9742538097
]
}
]
}Scenario: Frozen Lockfile (Hot Cache)
BENCHMARK_REPORT.json{
"results": [
{
"command": "pacquet@HEAD",
"mean": 0.70928836378,
"stddev": 0.04941757059226638,
"median": 0.6947523743800001,
"user": 0.41165251999999997,
"system": 1.5700459799999997,
"min": 0.68005587438,
"max": 0.8484337353800001,
"times": [
0.8484337353800001,
0.6996865473800001,
0.6984549653800001,
0.6941960773800001,
0.70552094738,
0.68005587438,
0.6929393673800001,
0.6848407393800001,
0.6953086713800001,
0.6934467123800001
]
},
{
"command": "pacquet@main",
"mean": 0.72072106028,
"stddev": 0.06020493479272523,
"median": 0.70219337288,
"user": 0.39082602,
"system": 1.5935422799999999,
"min": 0.6734395123800001,
"max": 0.8773635623800001,
"times": [
0.7527925153800001,
0.7268143423800001,
0.6734395123800001,
0.68660686938,
0.6788138733800001,
0.8773635623800001,
0.7089302753800001,
0.6877977713800001,
0.6954564703800001,
0.7191954103800001
]
},
{
"command": "pnpm",
"mean": 2.7445834424799997,
"stddev": 0.07000393850065967,
"median": 2.7314663023800003,
"user": 3.3717189199999993,
"system": 2.3088752799999996,
"min": 2.66914362738,
"max": 2.90607168038,
"times": [
2.72886031238,
2.78895669938,
2.90607168038,
2.66914362738,
2.68763269438,
2.68464838838,
2.73407229238,
2.78478080338,
2.7065529383799998,
2.75511498838
]
}
]
} |
Summary
Mirrors pnpm's
pkgIsLeafreuse: a package with no `dependencies`, `optionalDependencies`, `peerDependencies`, or `peerDependenciesMeta` collapses every parent reference onto one tree node keyed by the package id, instead of allocating a fresh `NodeId` per occurrence. Peer resolution and every downstream `HashMap<NodeId, _>` see the reduced node set.`NodeId` becomes an enum:
```rust
pub enum NodeId {
Counter(u64), // per-occurrence (existing path, non-leaves)
Leaf(Arc), // shared across every leaf occurrence
}
```
The tree insert switches to `entry().and_modify(min depth).or_insert_with(...)` so collapsed-leaf depth still folds to the shallowest occurrence, matching pnpm's `Math.min` arm.
Two conservative deviations from the issue:
Closes #11844.
Test plan
Written by an agent (Claude Code, claude-opus-4-7).
Summary by CodeRabbit
Bug Fixes
Tests