From f68effe4ac0d1ee5cf26fc9c7fc50c88d16bf6ba Mon Sep 17 00:00:00 2001 From: Shirui Cheng Date: Mon, 12 Aug 2024 16:15:46 -0700 Subject: [PATCH] Add a runtime option opt_experimental_tcache_gc to guard the new design --- include/jemalloc/internal/jemalloc_internal_externs.h | 1 + src/ctl.c | 4 ++++ src/jemalloc.c | 3 +++ src/stats.c | 1 + 4 files changed, 9 insertions(+) diff --git a/include/jemalloc/internal/jemalloc_internal_externs.h b/include/jemalloc/internal/jemalloc_internal_externs.h index 41c0f366..2c6b58f7 100644 --- a/include/jemalloc/internal/jemalloc_internal_externs.h +++ b/include/jemalloc/internal/jemalloc_internal_externs.h @@ -29,6 +29,7 @@ extern void (*JET_MUTABLE invalid_conf_abort)(void); extern bool opt_utrace; extern bool opt_xmalloc; extern bool opt_experimental_infallible_new; +extern bool opt_experimental_tcache_gc; extern bool opt_zero; extern unsigned opt_narenas; extern zero_realloc_action_t opt_zero_realloc_action; diff --git a/src/ctl.c b/src/ctl.c index ec569d7c..8608f124 100644 --- a/src/ctl.c +++ b/src/ctl.c @@ -131,6 +131,7 @@ CTL_PROTO(opt_zero) CTL_PROTO(opt_utrace) CTL_PROTO(opt_xmalloc) CTL_PROTO(opt_experimental_infallible_new) +CTL_PROTO(opt_experimental_tcache_gc) CTL_PROTO(opt_max_batched_size) CTL_PROTO(opt_remote_free_max) CTL_PROTO(opt_remote_free_max_batch) @@ -494,6 +495,8 @@ static const ctl_named_node_t opt_node[] = { {NAME("xmalloc"), CTL(opt_xmalloc)}, {NAME("experimental_infallible_new"), CTL(opt_experimental_infallible_new)}, + {NAME("experimental_tcache_gc"), + CTL(opt_experimental_tcache_gc)}, {NAME("max_batched_size"), CTL(opt_max_batched_size)}, {NAME("remote_free_max"), CTL(opt_remote_free_max)}, {NAME("remote_free_max_batch"), CTL(opt_remote_free_max_batch)}, @@ -2243,6 +2246,7 @@ CTL_RO_NL_CGEN(config_utrace, opt_utrace, opt_utrace, bool) CTL_RO_NL_CGEN(config_xmalloc, opt_xmalloc, opt_xmalloc, bool) CTL_RO_NL_CGEN(config_enable_cxx, opt_experimental_infallible_new, opt_experimental_infallible_new, bool) +CTL_RO_NL_GEN(opt_experimental_tcache_gc, opt_experimental_tcache_gc, bool) CTL_RO_NL_GEN(opt_max_batched_size, opt_bin_info_max_batched_size, size_t) CTL_RO_NL_GEN(opt_remote_free_max, opt_bin_info_remote_free_max, size_t) diff --git a/src/jemalloc.c b/src/jemalloc.c index 512b3fcc..dc471563 100644 --- a/src/jemalloc.c +++ b/src/jemalloc.c @@ -151,6 +151,7 @@ void (*JET_MUTABLE invalid_conf_abort)(void) = &abort; bool opt_utrace = false; bool opt_xmalloc = false; bool opt_experimental_infallible_new = false; +bool opt_experimental_tcache_gc = false; bool opt_zero = false; unsigned opt_narenas = 0; static fxp_t opt_narenas_ratio = FXP_INIT_INT(4); @@ -1414,6 +1415,8 @@ malloc_conf_init_helper(sc_data_t *sc_data, unsigned bin_shard_sizes[SC_NBINS], "experimental_infallible_new") } + CONF_HANDLE_BOOL(opt_experimental_tcache_gc, + "experimental_tcache_gc") CONF_HANDLE_BOOL(opt_tcache, "tcache") CONF_HANDLE_SIZE_T(opt_tcache_max, "tcache_max", 0, TCACHE_MAXCLASS_LIMIT, CONF_DONT_CHECK_MIN, diff --git a/src/stats.c b/src/stats.c index bcd08ce5..f45b7447 100644 --- a/src/stats.c +++ b/src/stats.c @@ -1600,6 +1600,7 @@ stats_general_print(emitter_t *emitter) { OPT_WRITE_BOOL("utrace") OPT_WRITE_BOOL("xmalloc") OPT_WRITE_BOOL("experimental_infallible_new") + OPT_WRITE_BOOL("experimental_tcache_gc") OPT_WRITE_SIZE_T("max_batched_size") OPT_WRITE_SIZE_T("remote_free_max") OPT_WRITE_SIZE_T("remote_free_max_batch")