@@ -208,7 +208,11 @@ typedef unsigned int pymem_uint; /* assuming >= 16 bits */
208208 * mappings to reduce heap fragmentation.
209209 */
210210#ifdef USE_LARGE_ARENAS
211- #define ARENA_BITS 20 /* 1 MiB */
211+ # ifdef PYMALLOC_USE_HUGEPAGES
212+ # define ARENA_BITS 21 /* 2 MiB */
213+ # else
214+ # define ARENA_BITS 20 /* 1 MiB */
215+ # endif
212216#else
213217#define ARENA_BITS 18 /* 256 KiB */
214218#endif
@@ -469,7 +473,7 @@ nfp free pools in usable_arenas.
469473*/
470474
471475/* How many arena_objects do we initially allocate?
472- * 16 = can allocate 16 arenas = 16 * ARENA_SIZE = 4MB before growing the
476+ * 16 = can allocate 16 arenas = 16 * ARENA_SIZE before growing the
473477 * `arenas` vector.
474478 */
475479#define INITIAL_ARENA_OBJECTS 16
@@ -512,14 +516,26 @@ struct _obmalloc_mgmt {
512516
513517 memory address bit allocation for keys
514518
515- 64-bit pointers, IGNORE_BITS=0 and 2^20 arena size:
519+ ARENA_BITS is configurable: 20 (1 MiB) by default on 64-bit, or
520+ 21 (2 MiB) when PYMALLOC_USE_HUGEPAGES is enabled. All bit widths
521+ below are derived from ARENA_BITS automatically.
522+
523+ 64-bit pointers, IGNORE_BITS=0 and 2^20 arena size (default):
516524 15 -> MAP_TOP_BITS
517525 15 -> MAP_MID_BITS
518526 14 -> MAP_BOT_BITS
519527 20 -> ideal aligned arena
520528 ----
521529 64
522530
531+ 64-bit pointers, IGNORE_BITS=0 and 2^21 arena size (hugepages):
532+ 15 -> MAP_TOP_BITS
533+ 15 -> MAP_MID_BITS
534+ 13 -> MAP_BOT_BITS
535+ 21 -> ideal aligned arena
536+ ----
537+ 64
538+
523539 64-bit pointers, IGNORE_BITS=16, and 2^20 arena size:
524540 16 -> IGNORE_BITS
525541 10 -> MAP_TOP_BITS
0 commit comments