Loading...
--- libmalloc/libmalloc-166.200.60/src/thresholds.h
+++ libmalloc/libmalloc-140.40.1/src/thresholds.h
@@ -36,7 +36,7 @@
#define NUM_TINY_CEIL_BLOCKS (1 << SHIFT_TINY_CEIL_BLOCKS)
/*
- * Small region size definitions.
+ * Small region size defintions.
*
* We can only represent up to 1<<15 for msize; but we choose to stay
* even below that to avoid the convention msize=0 => msize = (1<<15)
@@ -47,6 +47,15 @@
#define NUM_SMALL_BLOCKS 16319
#define NUM_SMALL_CEIL_BLOCKS (1 << SHIFT_SMALL_CEIL_BLOCKS)
#define SMALL_BLOCKS_ALIGN (SHIFT_SMALL_CEIL_BLOCKS + SHIFT_SMALL_QUANTUM) // 23
+
+/*
+ * The number of slots in the free-list for small blocks. To avoid going to
+ * vm system as often on large memory machines, increase the number of free list
+ * spots above some amount of RAM installed in the system.
+ */
+#define NUM_SMALL_SLOTS 32
+#define NUM_SMALL_SLOTS_LARGEMEM 256
+#define SMALL_BITMAP_WORDS 8
#if MALLOC_TARGET_64BIT
#define NUM_TINY_SLOTS 64 // number of slots for free-lists
@@ -65,45 +74,20 @@
/*
* The threshold above which we start allocating from the large
* "region" (ie. direct vm_allocates). The LARGEMEM size is used
- * on macOS and 64bit iOS with 16k pages, > 2gb and > 2 cores once
- * CONFIG_SMALL_CUTOFF_DYNAMIC is enabled (TODO: rdar://problem/35395572)
- * Must be a multiple of SMALL_QUANTUM (512 bytes)
+ * on systems that have more than 1GB RAM.
*/
-#if MALLOC_TARGET_IOS
-#if MALLOC_TARGET_64BIT
-#define LARGE_THRESHOLD (15 * 1024) // <1 * 16k pages
-#define LARGE_THRESHOLD_LARGEMEM (64 * 1024) // 4 * 16k pages
-#else
-#define LARGE_THRESHOLD (15 * 1024) // <4 * 4k pages
-#define LARGE_THRESHOLD_LARGEMEM (64 * 1024) // 16 * 4k pages
-#endif
-#else
-#define LARGE_THRESHOLD (15 * 1024) // <4 * 4k pages
-#define LARGE_THRESHOLD_LARGEMEM (127 * 1024) // <32 * 4k pages
-#endif
-
-/*
- * The number of slots in the free-list for small blocks. To avoid going to
- * vm system as often on large memory machines, increase the number of free list
- * spots above some amount of RAM installed in the system.
- */
-#define NUM_SMALL_SLOTS (LARGE_THRESHOLD >> SHIFT_SMALL_QUANTUM)
-#define NUM_SMALL_SLOTS_LARGEMEM (LARGE_THRESHOLD_LARGEMEM >> SHIFT_SMALL_QUANTUM)
+#define LARGE_THRESHOLD (15 * 1024)
+#define LARGE_THRESHOLD_LARGEMEM (127 * 1024)
/*
* When all memory is touched after a copy, vm_copy() is always a lose
* But if the memory is only read, vm_copy() wins over memmove() at 3 or 4 pages
* (on a G3/300MHz)
*
- * This must be >= LARGE_THRESHOLD
+ * This must be larger than LARGE_THRESHOLD
*/
-#if MALLOC_TARGET_IOS && MALLOC_TARGET_64BIT
-#define VM_COPY_THRESHOLD (48 * 1024) // 3 * 16k pages
-#define VM_COPY_THRESHOLD_LARGEMEM (96 * 1024) // 6 * 16k pages
-#else
-#define VM_COPY_THRESHOLD (40 * 1024) // 10 * 4k pages
-#define VM_COPY_THRESHOLD_LARGEMEM (128 * 1024) // 32 * 4k pages
-#endif
+#define VM_COPY_THRESHOLD (40 * 1024)
+#define VM_COPY_THRESHOLD_LARGEMEM (128 * 1024)
/*
* Large entry cache (death row) sizes. The large cache is bounded with
@@ -130,47 +114,20 @@
#define SZONE_FLOTSAM_THRESHOLD_HIGH (1024 * 1024)
/*
- * The magazine freelist array must be large enough to accomdate the allocation
- * granularity of both the tiny and small allocators. In addition, the last
- * slot in the list is special and reserved for coalesced regions bigger than
- * the overall max allocation size of the allocator.
- */
-#define MAGAZINE_FREELIST_SLOTS (NUM_SMALL_SLOTS_LARGEMEM + 1)
-#define MAGAZINE_FREELIST_BITMAP_WORDS ((MAGAZINE_FREELIST_SLOTS + 31) >> 5)
-
-/*
* Density threshold used in determining the level of emptiness before
* moving regions to the recirc depot.
*/
#define DENSITY_THRESHOLD(a) \
((a) - ((a) >> 2)) // "Emptiness" f = 0.25, so "Density" is (1 - f)*a. Generally: ((a) - ((a) >> -log2(f)))
-/*
- * Minimum number of regions to retain in a recirc depot.
- */
-#define DEFAULT_RECIRC_RETAINED_REGIONS 2
-
/* Sanity checks. */
-MALLOC_STATIC_ASSERT(NUM_SMALL_SLOTS_LARGEMEM == LARGE_THRESHOLD_LARGEMEM >> SHIFT_SMALL_QUANTUM,
- "NUM_SMALL_SLOTS_LARGEMEM must match LARGE_THRESHOLD_LARGEMEM >> SHIFT_SMALL_QUANTUM");
+#if (LARGE_THRESHOLD > NUM_SMALL_SLOTS * SMALL_QUANTUM)
+#error LARGE_THRESHOLD should always be less than NUM_SMALL_SLOTS * SMALL_QUANTUM
+#endif
-MALLOC_STATIC_ASSERT(NUM_TINY_SLOTS <= NUM_SMALL_SLOTS_LARGEMEM,
- "NUM_TINY_SLOTS must be less than or equal to NUM_SMALL_SLOTS_LARGEMEM");
-
-MALLOC_STATIC_ASSERT((LARGE_THRESHOLD % SMALL_QUANTUM) == 0,
- "LARGE_THRESHOLD must be a multiple of SMALL_QUANTUM");
-MALLOC_STATIC_ASSERT((LARGE_THRESHOLD_LARGEMEM % SMALL_QUANTUM) == 0,
- "LARGE_THRESHOLD_LARGEMEM must be a multiple of SMALL_QUANTUM");
-
-MALLOC_STATIC_ASSERT((LARGE_THRESHOLD / SMALL_QUANTUM) <= NUM_SMALL_SLOTS,
- "LARGE_THRESHOLD must be less than NUM_SMALL_SLOTS * SMALL_QUANTUM");
-MALLOC_STATIC_ASSERT((LARGE_THRESHOLD_LARGEMEM / SMALL_QUANTUM) <= NUM_SMALL_SLOTS_LARGEMEM,
- "LARGE_THRESHOLD_LARGEMEM must be less than NUM_SMALL_SLOTS * SMALL_QUANTUM");
-
-MALLOC_STATIC_ASSERT(VM_COPY_THRESHOLD >= LARGE_THRESHOLD,
- "VM_COPY_THRESHOLD must be larger than LARGE_THRESHOLD");
-MALLOC_STATIC_ASSERT(VM_COPY_THRESHOLD_LARGEMEM >= LARGE_THRESHOLD_LARGEMEM,
- "VM_COPY_THRESHOLD_LARGEMEM must be larger than LARGE_THRESHOLD_LARGEMEM");
+#if (LARGE_THRESHOLD_LARGEMEM > NUM_SMALL_SLOTS_LARGEMEM * SMALL_QUANTUM)
+#error LARGE_THRESHOLD_LARGEMEM should always be less than NUM_SMALL_SLOTS * SMALL_QUANTUM
+#endif
#endif // __THRESHOLDS_H