From 195249e6bf5eebb7c25118f15ff29fddf8761bfb Mon Sep 17 00:00:00 2001 From: Daan Leijen Date: Tue, 7 Jan 2025 19:28:44 -0800 Subject: [PATCH 1/2] maintain precise try count for reclaim --- ide/vs2022/mimalloc-lib.vcxproj | 10 +++++----- ide/vs2022/mimalloc-lib.vcxproj.filters | 6 +++--- ide/vs2022/mimalloc-override-dll.vcxproj | 10 +++++----- ide/vs2022/mimalloc-override-dll.vcxproj.filters | 6 +++--- src/segment.c | 1 + 5 files changed, 17 insertions(+), 16 deletions(-) diff --git a/ide/vs2022/mimalloc-lib.vcxproj b/ide/vs2022/mimalloc-lib.vcxproj index 6c652b8a..9e5371af 100644 --- a/ide/vs2022/mimalloc-lib.vcxproj +++ b/ide/vs2022/mimalloc-lib.vcxproj @@ -421,15 +421,15 @@ - + + true + true true true - true true - true - true true - true + true + true diff --git a/ide/vs2022/mimalloc-lib.vcxproj.filters b/ide/vs2022/mimalloc-lib.vcxproj.filters index 90703da8..3acf4015 100644 --- a/ide/vs2022/mimalloc-lib.vcxproj.filters +++ b/ide/vs2022/mimalloc-lib.vcxproj.filters @@ -16,9 +16,6 @@ Sources - - Sources - Sources @@ -64,6 +61,9 @@ Sources + + Sources + diff --git a/ide/vs2022/mimalloc-override-dll.vcxproj b/ide/vs2022/mimalloc-override-dll.vcxproj index bc822590..728c4f59 100644 --- a/ide/vs2022/mimalloc-override-dll.vcxproj +++ b/ide/vs2022/mimalloc-override-dll.vcxproj @@ -438,15 +438,15 @@ - + + true + true true true - true true - true - true true - true + true + true diff --git a/ide/vs2022/mimalloc-override-dll.vcxproj.filters b/ide/vs2022/mimalloc-override-dll.vcxproj.filters index c6bde0ac..00d677d3 100644 --- a/ide/vs2022/mimalloc-override-dll.vcxproj.filters +++ b/ide/vs2022/mimalloc-override-dll.vcxproj.filters @@ -16,9 +16,6 @@ Sources - - Sources - Sources @@ -61,6 +58,9 @@ Sources + + Sources + diff --git a/src/segment.c b/src/segment.c index 3f23374b..27a3f295 100644 --- a/src/segment.c +++ b/src/segment.c @@ -1044,6 +1044,7 @@ static mi_segment_t* mi_segment_try_reclaim(mi_heap_t* heap, size_t block_size, else { // otherwise, mark it back as abandoned // todo: reset delayed pages in the segment? + max_tries++; // don't count this as a try since it was not suitable _mi_arena_segment_mark_abandoned(segment); } } From 7fa3b41fc97d12ec4e08f35ddd4916443cdcb5be Mon Sep 17 00:00:00 2001 From: Daan Leijen Date: Tue, 7 Jan 2025 19:30:52 -0800 Subject: [PATCH 2/2] limit object size in pages to 1/8th --- include/mimalloc/types.h | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/include/mimalloc/types.h b/include/mimalloc/types.h index 788d1731..c8c10a2a 100644 --- a/include/mimalloc/types.h +++ b/include/mimalloc/types.h @@ -195,9 +195,9 @@ typedef int32_t mi_ssize_t; // 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_OBJ_SIZE_MAX (MI_SMALL_PAGE_SIZE/4) // 16KiB -#define MI_MEDIUM_OBJ_SIZE_MAX (MI_MEDIUM_PAGE_SIZE/4) // 128KiB -#define MI_LARGE_OBJ_SIZE_MAX (MI_LARGE_PAGE_SIZE/2) // 2MiB +#define MI_SMALL_OBJ_SIZE_MAX (MI_SMALL_PAGE_SIZE/8) // 8 KiB +#define MI_MEDIUM_OBJ_SIZE_MAX (MI_MEDIUM_PAGE_SIZE/8) // 64 KiB +#define MI_LARGE_OBJ_SIZE_MAX (MI_LARGE_PAGE_SIZE/4) // 1 MiB #define MI_LARGE_OBJ_WSIZE_MAX (MI_LARGE_OBJ_SIZE_MAX/MI_INTPTR_SIZE) // Maximum number of size classes. (spaced exponentially in 12.5% increments)