microsoft / microsoft/mimalloc

Huge chunk of time spent on _mi_page_retire normal?

Open
#547 2 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

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

Description

Hi, I am using mimalloc in a programming language runtime, which relies on closures heavily. While the performance is not bad at all, when profiling, I notice that a significant chunk of time is spent on _mi_page_retire. The language runtime does allocate and deallocate closure objects at a very frequent rate hence this behavior makes sense to me on a high level. However, my intuition is that: wouldn't it be great if mimalloc can just let emptied-out pages lying around without retiring them, which I imagine would cut down the _mi_page_retire cost?

I am using the library version v1.7.5. The allocation is mostly performed via aligned_alloc calls (64-byte alignment).

Interestingly, profiling results across different running sessions vary as well, which confuses me even more. Some guidance on this is much appreciated. Thanks!

sample running session 1

s1

sample running session 2

s2

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 by reading the implementation and profiling behavior around _mi_page_retire, including how aligned_alloc with 64-byte alignment reaches that path. Compare the two reported sessions and determine whether page retirement is expected and what explains the differing costs; document the guidance or a reproducible issue if behavior is abnormal.

Written by the indexing model from the issue text.

Assessment

Tech stack
c
Domain
performance
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Needs clarification
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.