From eb7d893c8675f955fa770c8ae6f1c32a2394284c Mon Sep 17 00:00:00 2001 From: Jason Volk Date: Wed, 29 Jan 2025 06:36:14 +0000 Subject: [PATCH] fix malloc_conf feature-awareness Signed-off-by: Jason Volk --- src/core/alloc/je.rs | 31 +++++++++++++++++++------------ 1 file changed, 19 insertions(+), 12 deletions(-) diff --git a/src/core/alloc/je.rs b/src/core/alloc/je.rs index 6bdf8b33..57143e85 100644 --- a/src/core/alloc/je.rs +++ b/src/core/alloc/je.rs @@ -8,6 +8,7 @@ use std::{ }; use arrayvec::ArrayVec; +use const_str::concat_bytes; use tikv_jemalloc_ctl as mallctl; use tikv_jemalloc_sys as ffi; use tikv_jemallocator as jemalloc; @@ -20,18 +21,24 @@ use crate::{ #[cfg(feature = "jemalloc_conf")] #[unsafe(no_mangle)] -pub static malloc_conf: &[u8] = b"\ -metadata_thp:always\ -,percpu_arena:percpu\ -,background_thread:true\ -,max_background_threads:-1\ -,lg_extent_max_active_fit:4\ -,oversize_threshold:16777216\ -,tcache_max:2097152\ -,dirty_decay_ms:16000\ -,muzzy_decay_ms:144000\ -,prof_active:false\ -\0"; +pub static malloc_conf: &[u8] = concat_bytes!( + "lg_extent_max_active_fit:4", + ",oversize_threshold:16777216", + ",tcache_max:2097152", + ",dirty_decay_ms:16000", + ",muzzy_decay_ms:144000", + ",percpu_arena:percpu", + ",metadata_thp:always", + ",background_thread:true", + ",max_background_threads:-1", + MALLOC_CONF_PROF, + 0 +); + +#[cfg(all(feature = "jemalloc_conf", feature = "jemalloc_prof"))] +const MALLOC_CONF_PROF: &str = ",prof_active:false"; +#[cfg(all(feature = "jemalloc_conf", not(feature = "jemalloc_prof")))] +const MALLOC_CONF_PROF: &str = ""; #[global_allocator] static JEMALLOC: jemalloc::Jemalloc = jemalloc::Jemalloc;