@@ -894,13 +894,17 @@ static int running_on_valgrind = -1;
894
894
#endif
895
895
#endif
896
896
897
- /* use radix-tree to track arena memory regions, for address_in_range() */
898
- #define USE_RADIX_TREE
897
+ #if !defined(WITH_PYMALLOC_RADIX_TREE )
898
+ /* Use radix-tree to track arena memory regions, for address_in_range().
899
+ * Enable by default since it allows larger pool sizes. Can be disabled
900
+ * using -DWITH_PYMALLOC_RADIX_TREE=0 */
901
+ #define WITH_PYMALLOC_RADIX_TREE 1
902
+ #endif
899
903
900
904
#if SIZEOF_VOID_P > 4
901
905
/* on 64-bit platforms use larger pools and arenas if we can */
902
906
#define USE_LARGE_ARENAS
903
- #ifdef USE_RADIX_TREE
907
+ #if WITH_PYMALLOC_RADIX_TREE
904
908
/* large pools only supported if radix-tree is enabled */
905
909
#define USE_LARGE_POOLS
906
910
#endif
@@ -942,9 +946,9 @@ static int running_on_valgrind = -1;
942
946
#define POOL_SIZE (1 << POOL_BITS)
943
947
#define POOL_SIZE_MASK (POOL_SIZE - 1)
944
948
945
- #ifndef USE_RADIX_TREE
949
+ #if ! WITH_PYMALLOC_RADIX_TREE
946
950
#if POOL_SIZE != SYSTEM_PAGE_SIZE
947
- # error "pool size must be system page size"
951
+ # error "pool size must be equal to system page size"
948
952
#endif
949
953
#endif
950
954
@@ -1261,7 +1265,7 @@ _Py_GetAllocatedBlocks(void)
1261
1265
return n ;
1262
1266
}
1263
1267
1264
- #ifdef USE_RADIX_TREE
1268
+ #if WITH_PYMALLOC_RADIX_TREE
1265
1269
/*==========================================================================*/
1266
1270
/* radix tree for tracking arena usage
1267
1271
@@ -1514,7 +1518,7 @@ arena_map_is_used(block *p)
1514
1518
1515
1519
/* end of radix tree logic */
1516
1520
/*==========================================================================*/
1517
- #endif /* USE_RADIX_TREE */
1521
+ #endif /* WITH_PYMALLOC_RADIX_TREE */
1518
1522
1519
1523
1520
1524
/* Allocate a new arena. If we run out of memory, return NULL. Else
@@ -1585,7 +1589,7 @@ new_arena(void)
1585
1589
unused_arena_objects = arenaobj -> nextarena ;
1586
1590
assert (arenaobj -> address == 0 );
1587
1591
address = _PyObject_Arena .alloc (_PyObject_Arena .ctx , ARENA_SIZE );
1588
- #ifdef USE_RADIX_TREE
1592
+ #if WITH_PYMALLOC_RADIX_TREE
1589
1593
if (address != NULL ) {
1590
1594
if (!arena_map_mark_used ((uintptr_t )address , 1 )) {
1591
1595
/* marking arena in radix tree failed, abort */
@@ -1625,7 +1629,7 @@ new_arena(void)
1625
1629
1626
1630
1627
1631
1628
- #ifdef USE_RADIX_TREE
1632
+ #if WITH_PYMALLOC_RADIX_TREE
1629
1633
/* Return true if and only if P is an address that was allocated by
1630
1634
pymalloc. When the radix tree is used, 'poolp' is unused.
1631
1635
*/
@@ -1726,7 +1730,7 @@ address_in_range(void *p, poolp pool)
1726
1730
arenas [arenaindex ].address != 0 ;
1727
1731
}
1728
1732
1729
- #endif /* !USE_RADIX_TREE */
1733
+ #endif /* !WITH_PYMALLOC_RADIX_TREE */
1730
1734
1731
1735
/*==========================================================================*/
1732
1736
@@ -2072,7 +2076,7 @@ insert_to_freepool(poolp pool)
2072
2076
ao -> nextarena = unused_arena_objects ;
2073
2077
unused_arena_objects = ao ;
2074
2078
2075
- #ifdef USE_RADIX_TREE
2079
+ #if WITH_PYMALLOC_RADIX_TREE
2076
2080
/* mark arena region as not under control of obmalloc */
2077
2081
arena_map_mark_used (ao -> address , 0 );
2078
2082
#endif
0 commit comments