You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
question: mimalloc shows significant presense on cpu profiler graph #669
I am almost sure it's expected - it happens during a very active memory growth phase. Still, I would like to double-check that there is nothing that can be tuned in order to reduce the CPU usage of these routines. We are using v2.0.5
changed the title [-]mimalloc shows significant presense on cpu profiler graph[/-][+]question: mimalloc shows significant presense on cpu profiler graph[/+]on Dec 17, 2022
Very interesting (can you tell me how I can generate such graphs myself?).
In a growth phase it is a bit expected to see this of course; I am a bit surprised by the page_extend taking so much time... You may go into src/page.c and redefine MI_MAX_EXTEND_SIZE to be, say, 8*1024 (twice as large as now). Let me know if it makes a difference.
Second, the _mprotect calls are quite expensive :-(. this is used to commit the memory so you may experiment by setting MI_EAGER_COMMIT_DELAY=0 so the segments get committed completely upfront. (this will still allow fine grained decommit/commit later on to battle fragmentation). Can you see if that makes a difference? Otherwise I am surprised by that many commits; did you change the decommit delay?
I fixed a bug in dev-slice that would decommit eagerly committed memory -- thanks! Maybe this will decrease the mprotect percentage? Can you try again with the latest dev-slice?
This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs in the next 14 days. Thank you for your contributions!
This issue was closed because it has been inactive for 14 days since being marked as stale. Please feel free to reopen if this is still an active issue.
Activity
[-]mimalloc shows significant presense on cpu profiler graph[/-][+]question: mimalloc shows significant presense on cpu profiler graph[/+]daanx commentedon Dec 20, 2022
Very interesting (can you tell me how I can generate such graphs myself?).
In a growth phase it is a bit expected to see this of course; I am a bit surprised by the
page_extendtaking so much time... You may go intosrc/page.cand redefineMI_MAX_EXTEND_SIZEto be, say,8*1024(twice as large as now). Let me know if it makes a difference.Second, the
_mprotectcalls are quite expensive :-(. this is used to commit the memory so you may experiment by settingMI_EAGER_COMMIT_DELAY=0so the segments get committed completely upfront. (this will still allow fine grained decommit/commit later on to battle fragmentation). Can you see if that makes a difference? Otherwise I am surprised by that many commits; did you change the decommit delay?romange commentedon Dec 20, 2022
Yes, I use https://github.com/gperftools/gperftools that provides a cpu profiling and tcmalloc-ing functionality when linking with your executable. I configure it without tcmalloc of course because I am a mimalloc fan, and use it as CPU profiler only: https://gperftools.github.io/gperftools/cpuprofile.html
then pprof from https://github.com/google/pprof can take a prof file generated by cpu profiler can generate such graphs or flamegraphs.
Another option is to use linux perf tool and create flamegraphs with, say, this tool:
https://github.com/flamegraph-rs/flamegraph
romange commentedon Dec 20, 2022
we set decommit_delay to zero but in this particular use-case we almost do not have decommits (only growth).
fix bug where eager committed memory would be immediatedy decommitted…
daanx commentedon Dec 21, 2022
I fixed a bug in
dev-slicethat would decommit eagerly committed memory -- thanks! Maybe this will decrease the mprotect percentage? Can you try again with the latestdev-slice?github-actions commentedon Sep 18, 2026
This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs in the next 14 days. Thank you for your contributions!
github-actions commentedon Oct 2, 2026
This issue was closed because it has been inactive for 14 days since being marked as stale. Please feel free to reopen if this is still an active issue.