Malloc perf

What is the worst-case performance for malloc on a modern machine in practice? - Benchmarking Malloc with Doom 3 - ForrestTheWoods

some observations

CRT is quite bad
dlmalloc and tlsf are old and single-threaded
jemalloc, mimalloc, and rpmalloc are “modern allocators”

Modern allocators:

  • Are designed for multi-threading
  • p50 malloc in under 10 nanoseconds
  • p95 malloc in ~25 nanoseconds
  • Worst 0.1%: 1 to 50 microseconds
  • Absolute Worst: ~500 microseconds

Latency vs Reliability

How much latency is too much? A Reddit discussion contained a rule of thumb I like: 2ms - works for pro audio
20ms - works for gaming
200ms - works for music
2000ms - works for streaming

caption

see also

Written on June 8, 2022, Last update on March 27, 2023
malloc memory allocator c++ fastware latency