News for hackers. Stuff that matters.
Re:Leveraging Zig's Allocators by foota on Saturday June 15, 2024 @01:01PM (#40690976)
O(1) is nice, but I feel like avoiding walking a bunch of data structures is maybe most important.
Re:Leveraging Zig's Allocators by elvircrn on Saturday June 15, 2024 @01:22PM (#40691118)
Any papers/blogs/SO answers covering this?
Re:Leveraging Zig's Allocators by saagarjha on Saturday June 15, 2024 @04:10PM (#40692374)
What are you looking for? Bump allocators are quite simple, compared to typical allocators at least.
Re:Leveraging Zig's Allocators by foota on Saturday June 15, 2024 @05:03PM (#40692676)
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.
Re:Leveraging Zig's Allocators by josephg on Saturday June 15, 2024 @05:56PM (#40692986)
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.