From d9397be17803e0408944329d63151ae57827e582 Mon Sep 17 00:00:00 2001 From: daanx Date: Mon, 16 Dec 2024 10:00:32 -0800 Subject: [PATCH] comments --- include/mimalloc/types.h | 4 ++-- src/bitmap.h | 9 +++++++-- 2 files changed, 9 insertions(+), 4 deletions(-) diff --git a/include/mimalloc/types.h b/include/mimalloc/types.h index f8615d1c..920a8e2c 100644 --- a/include/mimalloc/types.h +++ b/include/mimalloc/types.h @@ -321,9 +321,9 @@ typedef struct mi_page_s { // The max object size are checked to not waste more than 12.5% internally over the page sizes. // (Except for large pages since huge objects are allocated in 4MiB chunks) -#define MI_SMALL_MAX_OBJ_SIZE ((MI_SMALL_PAGE_SIZE-MI_PAGE_INFO_SIZE)/4) // < 8 KiB +#define MI_SMALL_MAX_OBJ_SIZE ((MI_SMALL_PAGE_SIZE-MI_PAGE_INFO_SIZE)/6) // < 11 KiB #define MI_MEDIUM_MAX_OBJ_SIZE ((MI_MEDIUM_PAGE_SIZE-MI_PAGE_INFO_SIZE)/4) // < 128 KiB -#define MI_LARGE_MAX_OBJ_SIZE ((MI_LARGE_PAGE_SIZE-MI_PAGE_INFO_SIZE)/2) // < 2 MiB +#define MI_LARGE_MAX_OBJ_SIZE ((MI_LARGE_PAGE_SIZE-MI_PAGE_INFO_SIZE)/4) // < 1 MiB #define MI_LARGE_MAX_OBJ_WSIZE (MI_LARGE_MAX_OBJ_SIZE/MI_SIZE_SIZE) diff --git a/src/bitmap.h b/src/bitmap.h index 62c42129..4faaa3a1 100644 --- a/src/bitmap.h +++ b/src/bitmap.h @@ -210,15 +210,20 @@ bool _mi_bitmap_forall_set_ranges(mi_bitmap_t* bitmap, mi_forall_set_fun_t* visi /* ---------------------------------------------------------------------------- Binned concurrent bitmap Assigns a size class to each chunk such that small blocks don't cause too - much fragmentation by keeping chunks for larger blocks separate. + much fragmentation since we keep chunks for larger blocks separate. ---------------------------------------------------------------------------- */ +// Size bins; larger bins are allowed to go into smaller bins. +// Since LARGE and MEDIUM are aligned (on word and byte boundaries respectively), +// they are larger than OTHER even though those can contain very large objects (but we +// don't want those in the MEDIUM or LARGE bins as these are variable size). +// SMALL can only be in small (and NONE), so they cannot fragment the larger bins. typedef enum mi_bbin_e { MI_BBIN_NONE, // no bin assigned yet (the chunk is completely free) MI_BBIN_SMALL, // slice_count == 1 + MI_BBIN_OTHER, // slice_count: any other from the other bins, and 1 <= slice_count <= MI_BCHUNK_BITS MI_BBIN_MEDIUM, // slice_count == 8 MI_BBIN_LARGE, // slice_count == MI_BFIELD_BITS - MI_BBIN_OTHER, // slice_count > 1, and not 8 or MI_BFIELD_BITS MI_BBIN_COUNT } mi_bbin_t;