3 ms·
If you're writing ultra low latency code you basically want everything allocated from an arena, with different arenas for different kinds of objects. Zig comes
by logicchains 7d ago
If you're writing ultra low latency code you basically want everything allocated from an arena, with different arenas for different kinds of objects. Zig comes with this built in, while Rust makes it extremely unergonomic to do safely (due to the lifetime system).
- kibwen 7d agoArenas in Rust work very well with lifetimes. In fact arenas benefit greatly from lifetimes, because lifetimes allow them to uphold the usual Rust safety guarantees about preventing use-after-free. For example, here's the bumpalo crate in action: let mut arena = Bump::new(); // create arena let foo = arena.alloc(Foo { x: 42 }); // allocate item in arena bump.reset(); // clear arena foo.x += 1; // compiler error preventing use-after-free