Skip to content

question: mimalloc shows significant presense on cpu profiler graph #669

Closed as not planned

Description

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

image

Activity

  1. changed the title [-]mimalloc shows significant presense on cpu profiler graph[/-] [+]question: mimalloc shows significant presense on cpu profiler graph[/+] on Dec 17, 2022
  2. daanx commented on Dec 20, 2022

    @daanx
    Collaborator

    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?

  3. romange commented on Dec 20, 2022

    @romange
    ContributorAuthor

    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

  4. romange commented on Dec 20, 2022

    @romange
    ContributorAuthor

    we set decommit_delay to zero but in this particular use-case we almost do not have decommits (only growth).

  5. daanx commented on Dec 21, 2022

    @daanx
    Collaborator

    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?

  6. github-actions commented on Sep 18, 2026

    @github-actions

    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!

  7. added
    stale
    on Sep 18, 2026
  8. github-actions commented on Oct 2, 2026

    @github-actions

    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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    stale

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions