Step zero of using arena allocation is to build realistic benchmarks so you can measure if it's worth the trouble in the first place. Standard allocators are incredibly good these days, and even plugging in mimalloc or jemalloc will be much less work, and much less error prone.
I meant to suggest using arena allocation for everything and not even using a malloc style allocator. Just getting memory via memmap at program start and then using arenas for everything after that.
It makes it much easier to avoid lifetime mistakes in my experience.
Using arena allocation also makes me think more about how much memory I am using and how much memory I should be using etc.
It is hard to benchmark it against just using a global allocator because it is a structural change to the whole codebase.
If this works for the programs you write, that’s great. It does preclude you from using many great data structures with potentially better performance - especially hash maps. Rehashing is pretty detrimental to most arena allocators you can think of.
ozgrakkurt · · focus · HN ↗
fn run_query(alloc) {
simonask · · focus · HN ↗
ozgrakkurt · · focus · HN ↗
It makes it much easier to avoid lifetime mistakes in my experience.
Using arena allocation also makes me think more about how much memory I am using and how much memory I should be using etc.
It is hard to benchmark it against just using a global allocator because it is a structural change to the whole codebase.
simonask · · focus · HN ↗
ozgrakkurt · · focus · HN ↗
But, you can use hashmaps fine. Just need to think about it and structure the program well for it.
It becomes clear once you do it a couple of times