Skip to content
TopicTracker
From HackerNewsView original
TranslationTranslation

A faster bump allocator for rust

The author presents Stumpalo, a new Rust bump allocator designed for performance. It uses a stack-like linear allocator with a free list for block reuse, aiming to surpass existing allocators like bumpalo in speed and memory efficiency.

Background

- A **bump allocator** (or arena allocator) is a simple memory allocation strategy that hands out memory by incrementing a pointer — extremely fast, but only works if all allocations can be freed at once. It's commonly used for short-lived, batch workloads (e.g., per-frame game data, compiler passes). - The Rust standard library offers `std::alloc::GlobalAlloc`, but the default global allocator is aimed at general-purpose use. Custom allocators, including bump allocators, are often written for performance-critical systems. - Rust's **allocator API** is still evolving; the `Allocator` trait (unstable, nightly-only) enables more flexible allocator design than the stable `GlobalAlloc` trait. - This post describes a custom bump allocator (`Stumpalo`) that beats existing Rust bump allocators (like `bumpalo`) by reducing branching and better exploiting the bump pointer pattern — relevant to game dev, real-time audio, and other latency-sensitive Rust applications.