Skip to content

use MemoryPool instead of allocator, fix examples#1

Open
zxcv05 wants to merge 2 commits into
dayvster:mainfrom
zxcv05:main
Open

use MemoryPool instead of allocator, fix examples#1
zxcv05 wants to merge 2 commits into
dayvster:mainfrom
zxcv05:main

Conversation

@zxcv05
Copy link
Copy Markdown

@zxcv05 zxcv05 commented Dec 18, 2025

MemoryPool is more performant and efficient than using a generic allocator, especially for lots of create()s and destroy()s of only a single type (Node(K, V, D) in this case)

also refactored part of the BPlusTree struct for easier readability and nicer qualities like BPlusTree(K, V, D).Node instead of having detached BPlusTree(K, V, D) and Node(K, V, D) (they are intrinsically linked)

@dayvster
Copy link
Copy Markdown
Owner

dayvster commented May 6, 2026

Sorry, life got in the way and github is not really all that great at notifying people on PRs.

This looks good, I'll do some testing/playing around with this today, run some benchmarks and if it's all positive merge it into main.

Appreciate it :)

@dayvster
Copy link
Copy Markdown
Owner

dayvster commented May 19, 2026

@zxcv05 had some time to play around with this, I have some thoughts.

I like where you're going with this. MemoryPool(Node) is a solid upgrade, the new init(allocator) style is cleaner, DebugAllocator in the examples is much better, and nesting Node inside BPlusTree feels nicer. Good stuff here.

That said, I can't merge it yet

  • removeNode and the rebalancing logic have some inconsistent parts (especially around freeNode calls)
  • createNode doesn't always initialize fields properly

What needs fixing/attention:

  • run zig fmt some formatting is inconsistent
  • Clean up inconsistent freeNode / pool.destroy usage
  • Finish (or properly stub) the remove path

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.

2 participants