This page contains notes and ideas on improving glibc malloc performance.

jemalloc

jemalloc is an allocator that was developed for FreeBSD but is now used by other BSDs, Mozilla and Facebook. It is claimed to be significantly faster than the glibc malloc implementation on multi-threaded workloads.

The license is BSD-derived so is unlikely to be suitable as a drop-in replacement for the glibc malloc.

tcmalloc

tcmalloc is an allocator that has been developed by Google. It also claims ot be significantly faster than the current glibc code.

tcmalloc does not return memory to the system, and the code is C++ and BSD licensed so is unlikely to be suitable as a drop-in replacement for the glibc malloc.

TLSF

TLSF is an allocator designed for real time systems with constant time overhead. It is GPL/LGPL licensed.

Hoard

Hoard is an allocator specifically designed for multi-processor systems. It can be used by the Intel compilers for SPEC benchmark builds. It's performance does not seem as good as jemalloc, tcmalloc and others. The code is in C++ and licensed either GPL or commercially.

nedmalloc

nedmalloc claims to have performance similar to jemalloc. Licensed under the Boost license.

mtmalloc

mtmalloc is the OpenSolaris implementation of malloc, that has claimed performance better than Hoard.

Streamflow

Streamflow is a mostly lockless allocator that keeps per-thread free lists rather than using multiple arenas and allocating threads to them. Code is LGPL licensed and on github.

SFMalloc

SFMalloc is a lockless allocator with per-thread free lists.

SSMalloc

SSMalloc is a mostly lockless allocator with per-thread free lists. It claims better performance than Streamflow or SFMalloc. Code is BSD licensed and on github.

glibc

The current glibc malloc implementation is based on ptmalloc which is a multi-threaded version of dlmalloc.

The glibc wiki contains a list of enhancement ideas for the malloc implementation.

Workloads

Various real world workloads are known to be sensitive to malloc implementation, these include:

  • MySQL / MariaDB
  • gcc

Benchmarks

Design considerations

/CortexMallocDesign

WorkingGroups/ToolChain/LibraryPerformance/GlibcPerformance/GlibcMalloc (last modified 2014-03-25 15:20:09)