Skip to content

gh-90815: Add mimalloc memory allocator#109914

Merged
vstinner merged 24 commits intopython:mainfrom
DinoV:nogil/mimalloc_212
Oct 30, 2023
Merged

gh-90815: Add mimalloc memory allocator#109914
vstinner merged 24 commits intopython:mainfrom
DinoV:nogil/mimalloc_212

Conversation

@DinoV
Copy link
Contributor

@DinoV DinoV commented Sep 26, 2023

This adds mimalloc as an optional (but preferred when available) allocator to CPython. This is a bit of a mashup of the work from #109914 and the work of @colesbury to use mimalloc for no-gil and various updates to bring it up to current CPython.

The configuration logic added by @tiran is re-used and we keep pymalloc support unlike in the version from @colesbury. mimalloc is updated to 2.12 and along with a few changes @colesbury made to it.

This has run into some issues with subinterpreter support in that the allocator's are now stored in thread state and are per-thread. Sub interpreters in some scenarios will create a thread state on one thread and run that on another thread. Most of these are documented in the code base as being known issues. I've modified these so that we will find the right thread based upon the current thread ID and switch to it rather than getting the head thread. This seems pretty reasonable but looks pretty weird when we need to do it at interpreter shutdown.

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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

8 participants