From 2e2a5477f7152a35144423e24bee7cc0a9f53603 Mon Sep 17 00:00:00 2001 From: Donghee Na Date: Thu, 22 Oct 2026 14:46:47 -0700 Subject: [PATCH 1/3] gh-113141: Tune MI_SEGMENT_SLICE_SHIFT to 14 for using 16 Kib pages --- Include/internal/pycore_mimalloc.h | 3 +++ 1 file changed, 3 insertions(+) diff --git a/Include/internal/pycore_mimalloc.h b/Include/internal/pycore_mimalloc.h index dea88adac15db2d..40febc9148772b2 100644 --- a/Include/internal/pycore_mimalloc.h +++ b/Include/internal/pycore_mimalloc.h @@ -32,6 +32,9 @@ typedef enum { # define MI_NO_THP 1 // Do not use guarded allocations. The free-threaded GC does not support their block layout. # define MI_GUARDED 0 +// Use 16 KiB pages instead of 64 KiB pages. +// Original value was 16. +# define MI_SEGMENT_SLICE_SHIFT 14 #ifdef Py_DEBUG # define MI_DEBUG 2 #else From 84dd47b0b8f77d0cd9c9ef94e058e424eeae2420 Mon Sep 17 00:00:00 2001 From: Donghee Na Date: Thu, 22 Oct 2026 22:13:17 -0700 Subject: [PATCH 2/3] lint --- Include/internal/pycore_mimalloc.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Include/internal/pycore_mimalloc.h b/Include/internal/pycore_mimalloc.h index 40febc9148772b2..8ab0727e2ba8318 100644 --- a/Include/internal/pycore_mimalloc.h +++ b/Include/internal/pycore_mimalloc.h @@ -32,7 +32,7 @@ typedef enum { # define MI_NO_THP 1 // Do not use guarded allocations. The free-threaded GC does not support their block layout. # define MI_GUARDED 0 -// Use 16 KiB pages instead of 64 KiB pages. +// Use 16 KiB pages instead of 64 KiB pages. // Original value was 16. # define MI_SEGMENT_SLICE_SHIFT 14 #ifdef Py_DEBUG From 2be4da2800ba9508d1264226aee6c7a7b6869397 Mon Sep 17 00:00:00 2001 From: Donghee Na Date: Thu, 22 Oct 2026 22:58:55 -0700 Subject: [PATCH 3/3] Update --- Include/internal/pycore_mimalloc.h | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/Include/internal/pycore_mimalloc.h b/Include/internal/pycore_mimalloc.h index 8ab0727e2ba8318..b38feda494207b5 100644 --- a/Include/internal/pycore_mimalloc.h +++ b/Include/internal/pycore_mimalloc.h @@ -32,9 +32,11 @@ typedef enum { # define MI_NO_THP 1 // Do not use guarded allocations. The free-threaded GC does not support their block layout. # define MI_GUARDED 0 -// Use 16 KiB pages instead of 64 KiB pages. -// Original value was 16. -# define MI_SEGMENT_SLICE_SHIFT 14 +// Use 16 KiB pages instead of the default 64 KiB in 64-bit platforms. +// TODO: 32-bit platforms may need tuning too. +# if SIZEOF_VOID_P == 8 +# define MI_SEGMENT_SLICE_SHIFT 14 +# endif #ifdef Py_DEBUG # define MI_DEBUG 2 #else