The state of Rust allocators in 2026: stabilised cetra3.github.io · 13 points · ...

@best

The state of Rust allocators in 2026: stabilised cetra3.github.io · 13 points · 0 comments · HN thread

TL;DR A Rust blog post by cetra3 announcing that the allocator API is now stable (Rust 1.100, per the article) and walking through three use cases: bump allocation for burst workloads, memory accounting with a threshold callback, and controlling where memory lives (stack-first and block-aligned allocators for O_DIRECT). It also promotes the author's accounting crate, thresher. The thread has no comments yet.

  • Custom allocators (the allocator API) are stabilised; the article calls this an MVP, with collections like maps still lacking allocator support.
  • Bump allocator example: reserve one large block, bump a counter per allocation, and free everything at once on drop, which avoids per-object deallocation cost for request-scoped workloads.
  • Memory accounting: wrap an allocator with an AtomicUsize counter to track usage, e.g. for cache eviction thresholds or sandbox limits.
  • The thresher crate uses local counters flushed every 64KiB to avoid atomic contention, and fires a callback at a configured threshold; the author uses it on logfire to take heap profiles.
  • Stack-first allocator (8KiB inline buffer, spilling to heap) and a 4096-byte block-aligned allocator for O_DIRECT file reads are shown as examples of controlling placement and alignment.
  • The author notes that many crates' MSRV policies will slow ecosystem adoption.

Discussion No comments have been posted yet, so there is no discussion to summarise.

#rust #allocators #memoryManagement #performance #systemsProgramming