From e9e162e6c313760f353884e348fd73325c2e07ef Mon Sep 17 00:00:00 2001 From: Ti Chi Robot Date: Mon, 17 Feb 2025 10:38:27 +0800 Subject: [PATCH] Re-enable jemalloc's background thread by default (#9813) (#9822) ref pingcap/tiflash#9722, close pingcap/tiflash#9812 Re-enable jemalloc's background thread by default Signed-off-by: ti-chi-bot Signed-off-by: JaySon-Huang Co-authored-by: Calvin Neo Co-authored-by: JaySon-Huang Co-authored-by: JaySon --- dbms/src/Server/Server.cpp | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/dbms/src/Server/Server.cpp b/dbms/src/Server/Server.cpp index 5c9ab0a07a2..54fdf14eba7 100644 --- a/dbms/src/Server/Server.cpp +++ b/dbms/src/Server/Server.cpp @@ -477,8 +477,10 @@ void UpdateMallocConfig([[maybe_unused]] const LoggerPtr & log) LOG_INFO(log, "Got jemalloc config: opt.background_thread {}, opt.max_background_threads {}", old_b, old_max_thd); - if (!malloc_conf && !old_b) + bool not_config_bg = !malloc_conf || strstr(malloc_conf, "background_thread") == nullptr; + if (not_config_bg && !old_b) { + // If the user doesn't explicitly set the background_thread opt, and it is actually false, then set it to true. LOG_INFO(log, "Try to use background_thread of jemalloc to handle purging asynchronously"); RUN_FAIL_RETURN(je_mallctl("max_background_threads", nullptr, nullptr, (void *)&new_max_thd, sz_st));