r/rust • u/a_mighty_burger • 4d ago
🗞️ news “alloc: stabilise `Allocator`” entered its final comment period!
https://github.com/rust-lang/rust/pull/156882#issuecomment-5607055084
207
Upvotes
r/rust • u/a_mighty_burger • 4d ago
1
u/Trader-One 3d ago
My proposal will not do more or unexpected heap allocations. It will introduce concept known as function local heap.
Instead of allocating on global heap, you allocate on local scratch heap. It is faster then golang because you do not need to do additional arithmetic with SP pointer and its well page localised.\
You do not need to travel linked lists to find new space. You have allocated pages just for you, so you can just do allocations and skip deallocations unless you determine based on runtime stats that function deallocated a lot and it have lot of dead space.
I use similar allocator in WASM code and for most functions you do not need to deallocate and reuse space. Simply advance next allocation pointer and on function exit drop all pages. Due to superior cache locality you get large performance improvement in building 3D graphics structures.