Skip to content

zipper,node: reduce wrapper churn and grow key scratch geometrically#823

Closed
snissn wants to merge 1 commit intopr/appendonly-direct-borrow-gatefrom
pr/zipper-node-wrapper-scratch
Closed

zipper,node: reduce wrapper churn and grow key scratch geometrically#823
snissn wants to merge 1 commit intopr/appendonly-direct-borrow-gatefrom
pr/zipper-node-wrapper-scratch

Conversation

@snissn
Copy link
Copy Markdown
Owner

@snissn snissn commented Mar 13, 2026

Summary

  • switch zipper loadNode to node.NewNodeView/value wrappers to avoid per-load *Node allocations
  • thread value-node wrappers through recursive and coalesce leaf merge paths
  • grow node.ensureKeyScratch geometrically to avoid per-step realloc churn
  • add node unit coverage for scratch reuse growth behavior

Testing

  • go test ./TreeDB/node ./TreeDB/zipper
  • go test ./TreeDB/caching ./TreeDB/internal/memtable ./TreeDB/zipper ./TreeDB/node

Copilot AI review requested due to automatic review settings March 13, 2026 21:41
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Reduces allocation overhead in the zipper hot path by returning node.Node values instead of *node.Node pointers from loadNode, and grows the key scratch buffer geometrically to avoid per-step reallocations.

Changes:

  • loadNode now returns node.Node (value) using NewNodeView, avoiding per-load heap allocations; callers take & when passing to functions expecting *node.Node
  • ensureKeyScratch grows geometrically (doubling from min 64) instead of exact-fit allocation
  • Added unit test for geometric scratch reuse behavior

Reviewed changes

Copilot reviewed 3 out of 3 changed files in this pull request and generated no comments.

File Description
TreeDB/zipper/zipper.go loadNode returns value node.Node via NewNodeView; callers use & for pointer params
TreeDB/node/leaf.go Geometric growth for keyScratch buffer
TreeDB/node/key_scratch_test.go New test verifying scratch reuse and 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.

@snissn
Copy link
Copy Markdown
Owner Author

snissn commented Mar 13, 2026

Closing in favor of standalone PR #825 (same core changes without stacked experimental dependencies).}

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants