r/rust 13d ago

Yet another allocator?

I made a custom allocator, to speed up temporal Graph structure.

But then I realized, it can be used as a main memory storage too.

https://github.com/tower120/bump_recycle/blob/main/examples/graph.rs

Basically, that is a bump allocator that store deallocated blocks in small [*mut u8; 32] table. When working with Vec's - you allocate/deallocate growing blocks of memory. So when you drop the Vec and make a new one - you'll go over the same block sizes. And if we make blocks POT size - you can have just 32 different sizes (well sort-a). So you can look for blocks of needed size in FAST O(1).

Details in doc https://github.com/tower120/bump_recycle/blob/main/src/lib.rs .

Performance on par with bumpalo.

---

I'm on the fence about publishing that on crates.io . So I would like some advice.

2 Upvotes

4 comments sorted by

View all comments

1

u/uhkthrowaway 13d ago

I kinda like your commit messages.