Hacker Newsnew | past | comments | ask | show | jobs | submitlogin

Deinit in O(1) seems to be a big attraction of arenas.


O(1) is nice, but I feel like avoiding walking a bunch of data structures is maybe most important.


Any papers/blogs/SO answers covering this?


I don't have anything for you, but if you have some normally allocated hierarchal data structures in order to free them you'll have to go through their members, chase pointers, etc., to figure out the addresses to free, then call free on them in sequence. That's all going to be a lot more expensive than just memsetting a bunch of data to zero, which you can do at whatever the speed of your cores memory bandwidth is.


Yep. And you often don’t even need to zero the data.

Generally, no paper or SO answer will tell you where your program spends its time. Learn to use profiling tools, and experiment with stuff like this. Try out arenas. Benchmark before and after and see what kind of real performance difference it makes in your own program.


What are you looking for? Bump allocators are quite simple, compared to typical allocators at least.




Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: