3 ms·
I am like a moth irresistibly attracted by the far away light of zero allocation. I can almost reach it. Just one more little lifetime annotation. One more...
by bombela 4y ago
I am like a moth irresistibly attracted by the far away light of zero allocation. I can almost reach it. Just one more little lifetime annotation. One more...
- whatshisface 4y agoYou can return structs to an allocation pool ring buffer by writing a custom implementation of the Drop trait. If you do that, almost anything can be zero-allocation. In Zig you can control the allocator as a first-class citizen and, I think, are meant to do things like that.
- kaba0 4y agoHopefully allocators will soon be available in stable Rust as well - then you can optionally specify an Allocator for a given allocation.
- titaniczero 4y agoThis is similar to Go’s sync.Pool to reuse buffers and prevent allocations when you want to optimize things, right?
- bombela 4y agoYes, this is similar. In Rust you control yourself the allocation on the stack or the heap. So before reaching out to a memory pool/arena, it's too tempting trying to put everything on the stack for "maximum performance".