fix malloc_conf feature-awareness

Signed-off-by: Jason Volk <jason@zemos.net>
This commit is contained in:
Jason Volk 2025-01-29 06:36:14 +00:00
parent 936161d89e
commit eb7d893c86

View file

@ -8,6 +8,7 @@ use std::{
}; };
use arrayvec::ArrayVec; use arrayvec::ArrayVec;
use const_str::concat_bytes;
use tikv_jemalloc_ctl as mallctl; use tikv_jemalloc_ctl as mallctl;
use tikv_jemalloc_sys as ffi; use tikv_jemalloc_sys as ffi;
use tikv_jemallocator as jemalloc; use tikv_jemallocator as jemalloc;
@ -20,18 +21,24 @@ use crate::{
#[cfg(feature = "jemalloc_conf")] #[cfg(feature = "jemalloc_conf")]
#[unsafe(no_mangle)] #[unsafe(no_mangle)]
pub static malloc_conf: &[u8] = b"\ pub static malloc_conf: &[u8] = concat_bytes!(
metadata_thp:always\ "lg_extent_max_active_fit:4",
,percpu_arena:percpu\ ",oversize_threshold:16777216",
,background_thread:true\ ",tcache_max:2097152",
,max_background_threads:-1\ ",dirty_decay_ms:16000",
,lg_extent_max_active_fit:4\ ",muzzy_decay_ms:144000",
,oversize_threshold:16777216\ ",percpu_arena:percpu",
,tcache_max:2097152\ ",metadata_thp:always",
,dirty_decay_ms:16000\ ",background_thread:true",
,muzzy_decay_ms:144000\ ",max_background_threads:-1",
,prof_active:false\ MALLOC_CONF_PROF,
\0"; 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] #[global_allocator]
static JEMALLOC: jemalloc::Jemalloc = jemalloc::Jemalloc; static JEMALLOC: jemalloc::Jemalloc = jemalloc::Jemalloc;