microsoft / microsoft/mimalloc

get worse performance after changing from jemalloc to mimalloc

Open
#1,119 1 comment 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

stale
Dominant language
C
Stars
13.4k
Forks
1.2k
Avg merge
4d 45m
Merged PRs (30d)
13

Description

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!

Contributor guide

No contributing guide indexed for this repository

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start with the Rust wrapper version and the provided perf trace, focusing on program::test1::benchmark::flush, mi_heap_collect_ex, _mi_page_free_collect, and _mi_page_malloc. Reproduce the workload while comparing jemalloc and mimalloc with the listed environment settings; done requires a measured, reproducible explanation of the performance difference.

Written by the indexing model from the issue text.

Assessment

Tech stack
linux, rust
Domain
backend, performance
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Quiet
Clarity
Needs clarification
Newbie friendliness
42/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.