Skip to content

use mimalloc as raw memory allocator in free-threading #144914

@kumaraditya303

Description

@kumaraditya303

This came up in context of numpy/numpy#30494.

Currently the raw allocator (PyMem_RawMalloc and friends) uses the system allocator because it should be possible to call these APIs without an active thread state. pymalloc requires an active thread state hence that cannot be used, however on free-threading we can instead use mimalloc instead of directly calling the system allocator.

Using mimalloc instead of system allocator I see much less contention while freeing the memory on macos, see the benchmark on the numpy issue on how to reproduce the issue.

Linked PRs

Metadata

Metadata

Assignees

No one assigned

    Labels

    3.15new features, bugs and security fixesinterpreter-core(Objects, Python, Grammar, and Parser dirs)performancePerformance or resource usagetopic-free-threadingtype-featureA feature request or enhancement

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions