zipper,node: reduce wrapper churn and grow key scratch geometrically#825
zipper,node: reduce wrapper churn and grow key scratch geometrically#825snissn wants to merge 3 commits intopr/zipper-scratch-reuse-tuningfrom
Conversation
There was a problem hiding this comment.
Pull request overview
This PR reduces allocations in hot read/merge paths by switching zipper node loading to use node.Node value views (via NewNodeView) and by improving Node’s internal key-scratch growth strategy to avoid repeated small allocations during leaf key reconstruction.
Changes:
- Update
Zipper.loadNodeto returnnode.Nodevalues and usenode.NewNodeView, adjusting downstream call sites to pass*node.Nodewhere required. - Change
(*node.Node).ensureKeyScratchto grow geometrically (with overflow guard) instead of reallocating to the exact requested size. - Add a focused unit test validating key-scratch geometric reuse behavior.
Reviewed changes
Copilot reviewed 3 out of 4 changed files in this pull request and generated no comments.
| File | Description |
|---|---|
| TreeDB/zipper/zipper.go | Switch node loading from *node.Node to allocation-free node.Node views and update call sites accordingly. |
| TreeDB/node/leaf.go | Make ensureKeyScratch grow geometrically (min 64 bytes) to reduce repeated allocations. |
| TreeDB/node/key_scratch_test.go | Add test ensuring small size increases reuse capacity and larger increases trigger growth. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
You can also share your feedback on Copilot code review. Take the survey.
There was a problem hiding this comment.
Pull request overview
This PR reduces heap allocations and improves scratch-buffer reuse in TreeDB’s page/node handling, primarily around zipper node loading and leaf key decoding.
Changes:
- Update
Zipper.loadNodeto returnnode.Nodeby value and usenode.NewNodeView(no heap allocation) for loaded pages. - Adjust zipper merge/coalesce call sites to pass
*node.Nodewhere required after the value-return change. - Improve
node.Node.ensureKeyScratchto grow geometrically and add a unit test validating reuse behavior.
Reviewed changes
Copilot reviewed 3 out of 4 changed files in this pull request and generated no comments.
| File | Description |
|---|---|
| TreeDB/zipper/zipper.go | Switch node loading to allocation-free Node values and update merge/coalesce call sites accordingly. |
| TreeDB/node/leaf.go | Change key scratch allocation strategy to geometric growth to avoid repeated small allocations. |
| TreeDB/node/key_scratch_test.go | Add coverage to ensure key scratch capacity is reused on small growth and increases when necessary. |
| TreeDB/caching/db.go | Formatting/alignment-only change within arena sizing constants. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
You can also share your feedback on Copilot code review. Take the survey.
…-scratch-standalone
Summary
Validation