Repository navigation
Upgrade mimalloc version from 2.1.2 to 2.5.2 #159111
Copy link
Copy link
Open
Labels
performancePerformance or resource usagePerformance or resource usagetopic-free-threadingtype-featureA feature request or enhancementA feature request or enhancement
Description
Feature or enhancement
Upgrading to mimalloc to 3.x.x would need huge architecture changes, maybe we need to write a PEP for this.
But upgrading to latest 2.5.2 version would get following benefits.
- Some CPython downstream changes are already applied to upstream.
- microsoft/mimalloc@0c4041fa: custom heap and page tags
- microsoft/mimalloc@d9aa19a7: sub-processes to isolate abandoned segments per interpreter
- microsoft/mimalloc@855e3b25: visit all abandoned blocks per sub-process
- microsoft/mimalloc@66052f13:
MI_PRIM_THREAD_IDhook for a custom thread id
- Handling abandoned segments have been improved.
- microsoft/mimalloc@bdda13b8: track abandoned segments in per-arena bitmaps instead of a global list
- microsoft/mimalloc@64edbc92, microsoft/mimalloc@9c96d05e: reclaim an abandoned segment when freeing into it (on by default)
- microsoft/mimalloc@ee92b337: don't reclaim segments when freeing from a thread whose heap is already abandoned
- microsoft/mimalloc@7774e800: don't visit full pages on a collection
- Several memory leakage issues are fixed.
- microsoft/mimalloc@d7a72c49: fix thread data leak
- microsoft/mimalloc@96b69d7e: fix leak where OS-allocated abandoned segments were not always reclaimed
- microsoft/mimalloc@635d626c: fix leak in abandoned block visiting
- microsoft/mimalloc@acd6f6ce, microsoft/mimalloc@4e50cec3: fix purge expiry handling so arena memory is actually returned to the OS
- Security fixes are applied.
- microsoft/mimalloc@ef3867f5: guard against free list corruption in the double-free check
- microsoft/mimalloc@25d6dcfc: check for overflow in
claim_huge_pages - microsoft/mimalloc@4bc8b2f9: check size limits in
mi_manage_os_memory/mi_reserve_os_memory - microsoft/mimalloc@66b93802, microsoft/mimalloc@204c6cbc — validate overlong environment values and
strtolerrors when readingMIMALLOC_*options
I 've applied changes in my local but we need to veify this on free-threading performance benchmark from Meta.
Has this already been discussed elsewhere?
No response given
Links to previous discussion of this feature:
No response
Linked PRs
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
performancePerformance or resource usagePerformance or resource usagetopic-free-threadingtype-featureA feature request or enhancementA feature request or enhancement
Activity
corona10 commentedon Oct 10, 2026
IMO, we don't need to backport this change to previous version since we did not chage anything about mimalloc for a while.
StanFromIreland commentedon Oct 11, 2026
See also #113141.
Merge remote-tracking branch 'upstream/main' into pythongh-159111