From c6b82a4b37b8bdf0ccc754371492c632c3376311 Mon Sep 17 00:00:00 2001 From: daan Date: Fri, 12 Nov 2021 17:31:21 -0800 Subject: [PATCH] wip: change decommit expiration --- CMakeLists.txt | 2 +- src/options.c | 2 +- src/segment.c | 16 +++++++++++++++- 3 files changed, 17 insertions(+), 3 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 7f880f74..bc4b3a51 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -176,7 +176,7 @@ endif() # Compiler flags if(CMAKE_C_COMPILER_ID MATCHES "AppleClang|Clang|GNU") - list(APPEND mi_cflags -Wall -Wextra -Wno-unknown-pragmas -fvisibility=hidden) + list(APPEND mi_cflags -Wall -Wextra -Wno-unknown-pragmas -fvisibility=hidden $<$:-O3>) if(NOT MI_USE_CXX) list(APPEND mi_cflags -Wstrict-prototypes) endif() diff --git a/src/options.c b/src/options.c index dbd4158c..21edd97c 100644 --- a/src/options.c +++ b/src/options.c @@ -89,7 +89,7 @@ static mi_option_desc_t options[_mi_option_last] = { 1, UNINIT, MI_OPTION(eager_commit_delay) }, // the first N segments per thread are not eagerly committed (but per page in the segment on demand) #endif { 1, UNINIT, MI_OPTION(allow_decommit) }, // decommit slices when no longer used (after reset_delay milli-seconds) - { 100, UNINIT, MI_OPTION(reset_delay) }, // page reset delay in milli-seconds (= decommit) + { 50, UNINIT, MI_OPTION(reset_delay) }, // page reset delay in milli-seconds (= decommit) { 500, UNINIT, MI_OPTION(segment_decommit_delay) },// decommit delay in milli-seconds for freed segments { 0, UNINIT, MI_OPTION(use_numa_nodes) }, // 0 = use available numa nodes, otherwise use at most N nodes. { 0, UNINIT, MI_OPTION(limit_os_alloc) }, // 1 = do not use OS memory for allocation (but only reserved arenas) diff --git a/src/segment.c b/src/segment.c index 1533d281..1ab7328e 100644 --- a/src/segment.c +++ b/src/segment.c @@ -416,7 +416,21 @@ static void mi_segment_perhaps_decommit(mi_segment_t* segment, uint8_t* p, size_ // update delayed commit mi_commit_mask_set(&segment->decommit_mask, mi_commit_mask_intersect(mask,segment->commit_mask)); // only decommit what is committed; span_free may try to decommit more - segment->decommit_expire = _mi_clock_now() + mi_option_get(mi_option_reset_delay); + mi_msecs_t now = _mi_clock_now(); + if (segment->decommit_expire == 0) { + // no previous decommits, initialize now + mi_assert_internal(mi_commit_mask_is_empty(segment->decommit_mask)); + segment->decommit_expire = now + mi_option_get(mi_option_reset_delay); + } + else if (segment->decommit_expire <= now) { + // previous decommit mask already expired + // mi_segment_delayed_decommit(segment, true, stats); + segment->decommit_expire = now + 1; + } + else { + // previous decommit mask is not yet expired + // segment->decommit_expire++; + } } }