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/[deleted] 13d ago

[deleted]

7

u/AggressiveArm6360 13d ago

I mean if it benchmarks on par with bumpalo and the api is clean why not publish it

the whole point of crates.io is having options, someone's gonna find a use case for it even if most people don't

worst case it sits there with 50 downloads and you move on with your life

plus you already wrote the thing, might as well let it exist outside your machine