summaryrefslogtreecommitdiffstats
path: root/Include/internal/pycore_mimalloc.h
diff options
context:
space:
mode:
authorSam Gross <colesbury@gmail.com>2024-01-04 22:21:40 (GMT)
committerGitHub <noreply@github.com>2024-01-04 22:21:40 (GMT)
commitfcb3c2a444709d2a53faa20c5b43541674064018 (patch)
treec0d5d58c179a2e7d5dd1c234360c6afdb8beaf42 /Include/internal/pycore_mimalloc.h
parentc2e8298eba3f8d75a58e5b3636f8edc8d60e68da (diff)
downloadcpython-fcb3c2a444709d2a53faa20c5b43541674064018.zip
cpython-fcb3c2a444709d2a53faa20c5b43541674064018.tar.gz
cpython-fcb3c2a444709d2a53faa20c5b43541674064018.tar.bz2
gh-112532: Isolate abandoned segments by interpreter (#113717)
* gh-112532: Isolate abandoned segments by interpreter Mimalloc segments are data structures that contain memory allocations along with metadata. Each segment is "owned" by a thread. When a thread exits, it abandons its segments to a global pool to be later reclaimed by other threads. This changes the pool to be per-interpreter instead of process-wide. This will be important for when we use mimalloc to find GC objects in the `--disable-gil` builds. We want heaps to only store Python objects from a single interpreter. Absent this change, the abandoning and reclaiming process could break this isolation. * Add missing '&_mi_abandoned_default' to 'tld_empty'
Diffstat (limited to 'Include/internal/pycore_mimalloc.h')
-rw-r--r--Include/internal/pycore_mimalloc.h6
1 files changed, 6 insertions, 0 deletions
diff --git a/Include/internal/pycore_mimalloc.h b/Include/internal/pycore_mimalloc.h
index adebb55..1e7ed5a 100644
--- a/Include/internal/pycore_mimalloc.h
+++ b/Include/internal/pycore_mimalloc.h
@@ -35,6 +35,12 @@ typedef enum {
#endif
#ifdef Py_GIL_DISABLED
+struct _mimalloc_interp_state {
+ // When exiting, threads place any segments with live blocks in this
+ // shared pool for other threads to claim and reuse.
+ mi_abandoned_pool_t abandoned_pool;
+};
+
struct _mimalloc_thread_state {
mi_heap_t *current_object_heap;
mi_heap_t heaps[_Py_MIMALLOC_HEAP_COUNT];