Hasty Briefsbeta

Bilingual

mimalloc: A new, high-performance, scalable memory allocator for the modern era

3 hours ago
  • #concurrency
  • #memory-allocator
  • #open-source
  • mimalloc is an open-source, scalable memory allocator designed for high concurrency and large memory scales, used in services like Bing and NoGIL CPython.
  • It uses thread-local heaps (theaps) and fixed-size pages to minimize synchronization, relying on atomic operations only for cross-thread frees, optimizing fast paths for allocation and deallocation.
  • The allocator maintains three free lists per page (free, local_free, thread_free) to enhance scalability and cache locality, reducing contention through distributed free lists.
  • mimalloc balances scalability and memory efficiency via 'page stealing,' allowing threads to share pages without heavy synchronization, improving memory usage in concurrent workloads.
  • It features a compact codebase (~12K lines of C) with clear data structures, making it easy to integrate and port across platforms like Windows, macOS, Linux, and game engines.