From b18e7135cbe67b316d56d096ec5eb45c88c1ef79 Mon Sep 17 00:00:00 2001 From: Dino Viehland Date: Mon, 30 Oct 2023 18:43:43 -0700 Subject: [PATCH 1/2] Don't include mimalloc .c's in Windows build Summary: Test Plan: Reviewers: Subscribers: Tasks: Tags: --- Objects/obmalloc.c | 3 +- PC/pyconfig.h | 3 ++ PCbuild/_freeze_module.vcxproj | 14 --------- PCbuild/_freeze_module.vcxproj.filters | 42 -------------------------- PCbuild/pythoncore.vcxproj | 14 --------- PCbuild/pythoncore.vcxproj.filters | 42 -------------------------- 6 files changed, 5 insertions(+), 113 deletions(-) diff --git a/Objects/obmalloc.c b/Objects/obmalloc.c index d230bbdad3c4cf..b05273b09126eb 100644 --- a/Objects/obmalloc.c +++ b/Objects/obmalloc.c @@ -2738,7 +2738,8 @@ py_mimalloc_print_stats(FILE *out) MI_LARGE_OBJ_SIZE_MAX); mi_heap_t *heap = mi_heap_get_default(); - struct _alloc_stats stats = {}; + struct _alloc_stats stats; + memset(&stats, 0, sizeof(stats)); mi_heap_visit_blocks(heap, false, &_collect_alloc_stats, &stats); fprintf(out, " Allocated Blocks: %ld\n", stats.allocated_blocks); diff --git a/PC/pyconfig.h b/PC/pyconfig.h index ac20129cd30fcc..e6b368caffe280 100644 --- a/PC/pyconfig.h +++ b/PC/pyconfig.h @@ -511,6 +511,9 @@ Py_NO_ENABLE_SHARED to find out. Also support MS_NO_COREDLL for b/w compat */ /* Use Python's own small-block memory-allocator. */ #define WITH_PYMALLOC 1 +/* Define if you want to compile in mimalloc memory allocator. */ +#define WITH_MIMALLOC 1 + /* Define if you want to compile in object freelists optimization */ #define WITH_FREELISTS 1 diff --git a/PCbuild/_freeze_module.vcxproj b/PCbuild/_freeze_module.vcxproj index 05b8bfdc38a99c..20d800a6959552 100644 --- a/PCbuild/_freeze_module.vcxproj +++ b/PCbuild/_freeze_module.vcxproj @@ -147,20 +147,6 @@ - - - - - - - - - - - - - - diff --git a/PCbuild/_freeze_module.vcxproj.filters b/PCbuild/_freeze_module.vcxproj.filters index d6cbd2d3d47361..40256a22fb5562 100644 --- a/PCbuild/_freeze_module.vcxproj.filters +++ b/PCbuild/_freeze_module.vcxproj.filters @@ -253,48 +253,6 @@ Source Files - - Source Files - - - Source Files - - - Source Files - - - Source Files - - - Source Files - - - Source Files - - - Source Files - - - Source Files - - - Source Files - - - Source Files - - - Source Files - - - Source Files - - - Source Files - - - Source Files - Source Files diff --git a/PCbuild/pythoncore.vcxproj b/PCbuild/pythoncore.vcxproj index 954a59a0bc7019..4d3621a6146807 100644 --- a/PCbuild/pythoncore.vcxproj +++ b/PCbuild/pythoncore.vcxproj @@ -498,20 +498,6 @@ - - - - - - - - - - - - - - diff --git a/PCbuild/pythoncore.vcxproj.filters b/PCbuild/pythoncore.vcxproj.filters index 2f8b206f973f34..69d8e0312e0169 100644 --- a/PCbuild/pythoncore.vcxproj.filters +++ b/PCbuild/pythoncore.vcxproj.filters @@ -1130,48 +1130,6 @@ Objects - - Objects\mimalloc - - - Objects\mimalloc - - - Objects\mimalloc - - - Objects\mimalloc - - - Objects\mimalloc - - - Objects\mimalloc - - - Objects\mimalloc - - - Objects\mimalloc - - - Objects\mimalloc - - - Objects\mimalloc - - - Objects\mimalloc - - - Objects\mimalloc - - - Objects\mimalloc - - - Objects\mimalloc - Objects From 7894cca44b7b5caac139eb69b1fd7606addbc876 Mon Sep 17 00:00:00 2001 From: Dino Viehland Date: Tue, 31 Oct 2023 09:50:01 -0700 Subject: [PATCH 2/2] Fix warnings on Windows --- Objects/obmalloc.c | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/Objects/obmalloc.c b/Objects/obmalloc.c index b05273b09126eb..2761c774209786 100644 --- a/Objects/obmalloc.c +++ b/Objects/obmalloc.c @@ -2730,11 +2730,11 @@ static bool _collect_alloc_stats( static void py_mimalloc_print_stats(FILE *out) { - fprintf(out, "Small block threshold = %ld, in %u size classes.\n", + fprintf(out, "Small block threshold = %zd, in %u size classes.\n", MI_SMALL_OBJ_SIZE_MAX, MI_BIN_HUGE); - fprintf(out, "Medium block threshold = %ld\n", + fprintf(out, "Medium block threshold = %zd\n", MI_MEDIUM_OBJ_SIZE_MAX); - fprintf(out, "Large object max size = %ld\n", + fprintf(out, "Large object max size = %zd\n", MI_LARGE_OBJ_SIZE_MAX); mi_heap_t *heap = mi_heap_get_default(); @@ -2742,11 +2742,11 @@ py_mimalloc_print_stats(FILE *out) memset(&stats, 0, sizeof(stats)); mi_heap_visit_blocks(heap, false, &_collect_alloc_stats, &stats); - fprintf(out, " Allocated Blocks: %ld\n", stats.allocated_blocks); - fprintf(out, " Allocated Bytes: %ld\n", stats.allocated_bytes); - fprintf(out, " Allocated Bytes w/ Overhead: %ld\n", stats.allocated_with_overhead); - fprintf(out, " Bytes Reserved: %ld\n", stats.bytes_reserved); - fprintf(out, " Bytes Committed: %ld\n", stats.bytes_committed); + fprintf(out, " Allocated Blocks: %zd\n", stats.allocated_blocks); + fprintf(out, " Allocated Bytes: %zd\n", stats.allocated_bytes); + fprintf(out, " Allocated Bytes w/ Overhead: %zd\n", stats.allocated_with_overhead); + fprintf(out, " Bytes Reserved: %zd\n", stats.bytes_reserved); + fprintf(out, " Bytes Committed: %zd\n", stats.bytes_committed); } #endif