GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — Upgrade mimalloc version from 2.1.2 to 2.5.2 · Issue #159111 · python/cpython

Upgrade mimalloc version from 2.1.2 to 2.5.2 #159111

New issue
Copy link
New issue
Copy link
Closed
Closed
Upgrade mimalloc version from 2.1.2 to 2.5.2#159111
Copy link
Assignees
corona10
Labels
3.14bugs and security fixesbugs and security fixes3.15bugs and security fixesbugs and security fixesperformancePerformance or resource usagePerformance or resource usagesprinttopic-free-threadingtype-featureA feature request or enhancementA feature request or enhancement

Description

@corona10
corona10
opened on Oct 10, 2026
Issue body actions

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.

  1. 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_ID hook for a custom thread id
  2. 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
  3. 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
  4. 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 strtol errors when reading MIMALLOC_* options

I 've applied changes in my local but we need to veify this on free-threading performance benchmark from Meta.

cc @mpage @itamaro @colesbury

Has this already been discussed elsewhere?

No response given

Links to previous discussion of this feature:

No response

Linked PRs

  • gh-159111: Update vendored mimalloc to v2.5.2 #159112
  • [3.15] gh-159111: Update vendored mimalloc to v2.5.2 (gh-159112) #160178
  • [3.14] gh-159111: Update vendored mimalloc to v2.5.2 (gh-159112) #160183
  • gh-159111: Add missing downstream changes when upgrade to 2.5.2. #160207

Activity

Next
  1. corona10
    self-assigned this
    on Oct 10, 2026
  2. corona10
    added
    type-featureA feature request or enhancementA feature request or enhancement
    topic-free-threading
    performancePerformance or resource usagePerformance or resource usage
    on Oct 10, 2026
  3. corona10 commented on Oct 10, 2026

    @corona10
    corona10
    on Oct 10, 2026
    MemberAuthor
    More actions

    IMO, we don't need to backport this change to previous version since we did not chage anything about mimalloc for a while.

  4. itamaro
    added
    🔨 test-with-buildbotsTest PR w/ buildbots; report in status sectionTest PR w/ buildbots; report in status section
    🔨 test-with-refleak-buildbotsTest PR w/ refleak buildbots; report in status sectionTest PR w/ refleak buildbots; report in status section
    and removed
    🔨 test-with-buildbotsTest PR w/ buildbots; report in status sectionTest PR w/ buildbots; report in status section
    🔨 test-with-refleak-buildbotsTest PR w/ refleak buildbots; report in status sectionTest PR w/ refleak buildbots; report in status section
    on Oct 10, 2026
  5. StanFromIreland commented on Oct 11, 2026

    @StanFromIreland
    StanFromIreland
    on Oct 11, 2026
    Member
    More actions

    See also #113141.

    Reacted by Donghee Na
  6. corona10
    added 2 commits that reference this issue on Oct 11, 2026

    Merge remote-tracking branch 'upstream/main' into pythongh-159111

    fea8db6

    Merge remote-tracking branch 'upstream/main' into pythongh-159111

    09196b1
  7. daanx commented on Oct 17, 2026

    @daanx
    daanx
    on Oct 17, 2026
    More actions

    (I am the mimalloc maintainer): Ah, apologies, I wasn't aware of this effort @corona10 :-( -- I just added a comment in #113141 about recent efforts to update to mimalloc v3 for the next CPython release -- hope that doesn't interfere with the current efforts too much. I think is better though than upgrading the v2 version, as v3 has many improvements. Hope we can work on this.

    Reacted by Donghee Na
  8. corona10 commented on Oct 17, 2026

    @corona10
    corona10
    on Oct 17, 2026
    MemberAuthor
    More actions

    (I am the mimalloc maintainer): Ah, apologies, I wasn't aware of this effort @corona10 :-( -- I just added a #113141 (comment) about recent efforts to update to mimalloc v3 for the next CPython release

    Yeah please send a draft PR as I replied. There are a lot of things to be verified. I am fine to move on v3 directly as possible.

  9. kevinprimeraquecreo-stack
    added this to Project_VKon Oct 18, 2026
  10. 5 remaining items

  11. corona10
    added
    sprint
    on Oct 22, 2026
  12. github-project-automation
    added this to Sprinton Oct 22, 2026
  13. github-project-automation
    moved this to Todo in Sprinton Oct 22, 2026
  14. corona10
    added 8 commits that reference this issue on Oct 22, 2026

    [3.15] pythongh-159111: Update vendored mimalloc to v2.5.2 (pythongh-…

    265f0fb

    pythongh-159111: Mark remaining CPython-specific changes in vendored …

    2685712

    pythongh-159111: Mark remaining CPython-specific changes in vendored …

    7bcb211

    pythongh-159111: Restore arc4random_buf() usage on Cygwin in vendored…

    3f5299b

    pythongh-159111: Remove the mimalloc update entry from What's New in …

    130a1a1

    gh-159111: Add missing downstream changes when upgrade to 2.5.2. (gh-…

    9f3d506

    [3.14] gh-159111: Update vendored mimalloc to v2.5.2 (gh-159112) (gh-…

    1bcc0d1

    [3.15] gh-159111: Update vendored mimalloc to v2.5.2 (gh-159112) (gh-…

    86e3b9f
  15. corona10 commented on Oct 22, 2026

    @corona10
    corona10
    on Oct 22, 2026
    MemberAuthor
    More actions

    @DinoV and I agreed to target v3 for the main branch, but we'll upgrade to 2.5.2 for now, since we still need to backport these changes.
    cc @daanx

  16. corona10
    closed this as completedon Oct 22, 2026
  17. github-project-automation
    moved this from Todo to Done in Sprinton Oct 22, 2026
  18. vstinner commented on Nov 6, 2026

    @vstinner
    vstinner
    on Nov 6, 2026
    Member
    More actions

    There is a regression: see #161420 "Free-threaded 3.14.10 and 3.15.2 keep memory freed by other threads: 10 GB peaks since the mimalloc 2.5.2 update".

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

Metadata

Metadata

Assignees

  • @corona10
    corona10

Labels

3.14bugs and security fixesbugs and security fixes3.15bugs and security fixesbugs and security fixesperformancePerformance or resource usagePerformance or resource usagesprinttopic-free-threadingtype-featureA feature request or enhancementA feature request or enhancement

Projects

  • Sprint
    Status
    Done
    Show more project fields

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions

You are visitor 01402503 — GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.