hn.today

The state of Rust allocators in 2026: stabilised

cetra3.github.io89 points16 comments
Screenshot of The state of Rust allocators in 2026: stabilised

Rust 1.100 stabilizes a minimum viable version of Rust’s allocator API, enabling programs to choose allocation strategies for specific data rather than relying only on a global allocator. One example is a bump allocator for bursty workloads such as web requests or database queries: it serves many allocations cheaply from a reserved block, then releases the whole block at once. This can avoid the cost of individually dropping large, nested structures, though it may increase peak memory use and is not appropriate for every allocation pattern.

Custom allocators can also track memory use and influence where memory lives. A wrapper can count allocated bytes, supporting decisions such as evicting cache entries, using available memory for sorting, or enforcing sandbox limits. The Thresher crate adds threshold callbacks while reducing atomic-counter overhead by combining local and global accounting; it is used to trigger heap profiles for Rust services when memory crosses a configured limit. For placement, a stack-first allocator can serve small allocations from a fixed stack buffer and spill larger ones to the heap, much like small-vector designs. The discussion also introduces stronger-than-usual alignment as a way to match external requirements, beginning with Linux disk reads and the kernel’s page cache.

Read on cetra3.github.io16 comments on Hacker News

Summary generated by AI from the linked article. hn.today is not affiliated with Hacker News or Y Combinator.

More in Programming

Personal Computing

Personal Computing

Cory Doctorow recalls Vernor Vinge’s visionary novel *Rainbows End* and the friendship and encouragement he shared with its author. He connects its vision of personal computing to vibe coding, while asking who will build and maintain the free and open-source software it depends on. (pluralistic.net)

The daily digest

Today's best Hacker News stories, summarized and screenshotted, one email a day.