Repository navigation
mimalloc: additional integration and changes for --disable-gil builds #112532
Copy link
Copy link
Closed
Labels
3.13only security fixesonly security fixesinterpreter-core(Objects, Python, Grammar, and Parser dirs)(Objects, Python, Grammar, and Parser dirs)topic-free-threadingtype-featureA feature request or enhancementA feature request or enhancement
Description
Activity
- addedtype-featureA feature request or enhancementA feature request or enhancementinterpreter-core(Objects, Python, Grammar, and Parser dirs)(Objects, Python, Grammar, and Parser dirs)3.13only security fixesonly security fixes
on Nov 29, 2023 - added a commit that references this issue
on Dec 8, 2023 - added 5 commits that reference this issue
on Dec 18, 2023 - added a commit that references this issue
on Jan 4, 2024 26 remaining items
I think think this is done now. There are still a few QSBR-related mimalloc changes, but those will be tracked in #115103.
- added 7 commits that reference this issue
on Sep 2, 2024 - added a commit that references this issue
on Jul 15, 2026 - added 2 commits that reference this issue
on Oct 10, 2026
Metadata
Metadata
Assignees
Labels
3.13only security fixesonly security fixesinterpreter-core(Objects, Python, Grammar, and Parser dirs)(Objects, Python, Grammar, and Parser dirs)topic-free-threadingtype-featureA feature request or enhancementA feature request or enhancement
Feature or enhancement
Mimalloc was added as an allocator in #90815. The
--disable-gilbuilds need further integration with mimalloc, as well as some modifications to mimalloc to support thread-safe garbage collection in--disable-gilbuilds and the dictionary accesses that mostly avoid locking.These changes can be split up across multiple PRs.
PyMem_Malloccalls, but we need separate heaps forPyObject_MallocandPyObject_GC_New. We should associate somemi_heap_ts with eachPyThreadState. Every PyThreadState needs four heaps: one for PyMem_Malloc, one for non-GC objects (via PyObject_Malloc), one for GC objects with managed dicts (extra pre-header) and one for GC objects without a managed dict. We need some way to know which heap to use in_PyObject_MiMalloc. There's not a great way to do this, but I suggest adding something like a "current pyobject heap" variable to PyThreadState. It should generally point to thePyObject_Mallocheap, butPyObject_GC_Newshould temporarily override it to point to the correct GC heap when called--disable-gilshould imply--with-mimallocand require mimalloc (i.e., disallow changing the allocator withPYTHONMALLOC).cc @DinoV
Linked PRs
--disable-gilbuilds #112883