mimalloc icon indicating copy to clipboard operation
mimalloc copied to clipboard

get worse performance after changing from jemalloc to mimalloc

Open weixingsun opened this issue 5 months ago • 0 comments

Hi, I have a rust app using jemalloc, when changing to mimalloc , our app get slower: the rust wrapper: https://github.com/purpleprotocol/mimalloc_rust shows it's backed by version: mimalloc v2.2.4

adding these options as environment variable, but no improvement: env MIMALLOC_VERBOSE=1 MIMALLOC_SHOW_STATS=1 MIMALLOC_SHOW_ERRORS=1 MIMALLOC_PURGE_DELAY=100 MIMALLOC_USE_NUMA_NODES=1 MIMALLOC_RESERVE_HUGE_OS_PAGES=200 MIMALLOC_EAGER_COMMIT_DELAY=1 ./program

there are some heap info from stderr, I am very new to mimalloc, it seems 0 pages and cached for unknown reason: Image

Linux kernel: 6.1.119

and the perf trace shows an overhead from mimalloc took pretty much CPU cycles:

Samples: 389K of event 'cycles', Event count (approx.): 6934350124
Overhead  Shared Object       Symbol
  11.83%  program            [.] mi_heap_collect_ex
   8.76%  program            [.] _mi_page_free_collect
   4.76%  libc-2.26.so       [.] __memcpy_avx_unaligned_erms
   4.57%  program            [.] program::test1::benchmark::flush
   3.12%  program            [.] program::test1::lib::custom_map::remove_item
   2.74%  program            [.] _mi_page_malloc

Thanks for advise!

weixingsun avatar Jul 30 '25 12:07 weixingsun