3 ms·
Is there a reason why someone wouldn't use retain_with_limit or is doing without it just an exercise?
by skybrian 2y ago
Is there a reason why someone wouldn't use retain_with_limit or is doing without it just an exercise?
- latch 2y agoThe inspiration for the post came from my httpz library. The fallback using a FixedBufferAllocator + ArenaAllocator is used. The fixed buffer is a thread local. But the arena allocators belong to connections, of which there could be thousands. You might have 1 fixed buffer, for N (500+) ArenaAllocators (but only being used per one at a time). This allows you to allocate a relatively large fixed buffer since you have relatively few threads. If you just used retain_with_limit, then you'd either have to have a much smaller retained size, or you'd need a lot more memory. https://github.com/karlseguin/http.zig/blob/c8b04e3fef5abf324c452f023e6b999c2ab85d6f/src/httpz.zig#L481 https://github.com/karlseguin/http.zig/blob/c8b04e3fef5abf32...