diff --git a/Cargo.toml b/Cargo.toml index 6d00889695e8fce5df7ee0c19221c63a02644bd9..6f4ada7cb7eba1d6e0885420dea8e18674396e85 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -400,17 +400,17 @@ version = "0.34.0" git = "https://github.com/girlbossceo/jemallocator" rev = "c32af15f3b440ae5e46c3404f78b19093bbd5294" default-features = false -features = ["stats", "unprefixed_malloc_on_supported_platforms"] +features = ["unprefixed_malloc_on_supported_platforms"] [workspace.dependencies.tikv-jemallocator] git = "https://github.com/girlbossceo/jemallocator" rev = "c32af15f3b440ae5e46c3404f78b19093bbd5294" default-features = false -features = ["stats", "unprefixed_malloc_on_supported_platforms"] +features = ["unprefixed_malloc_on_supported_platforms"] [workspace.dependencies.tikv-jemalloc-ctl] git = "https://github.com/girlbossceo/jemallocator" rev = "c32af15f3b440ae5e46c3404f78b19093bbd5294" default-features = false -features = ["stats", "use_std"] +features = ["use_std"] [workspace.dependencies.console-subscriber] version = "0.4" diff --git a/nix/pkgs/main/default.nix b/nix/pkgs/main/default.nix index 66d60b7765f0e68c83fa5f07b88da87f54032198..47b984324eeeeea30daf12281ac38384d247a21b 100644 --- a/nix/pkgs/main/default.nix +++ b/nix/pkgs/main/default.nix @@ -57,7 +57,9 @@ rust-jemalloc-sys' = (rust-jemalloc-sys.override { # we dont need cxx/C++ integration [ "--disable-cxx" ] ++ # tikv-jemalloc-sys/profiling feature - lib.optional (featureEnabled "jemalloc_prof") "--enable-prof"; + lib.optional (featureEnabled "jemalloc_prof") "--enable-prof" ++ + # tikv-jemalloc-sys/stats feature + (if (featureEnabled "jemalloc_stats") then [ "--enable-stats" ] else [ "--disable-stats" ]); }); buildDepsOnlyEnv = diff --git a/src/core/Cargo.toml b/src/core/Cargo.toml index a5c379e9c6bd189bb2289c698955aa11c5f12486..87943e6033d0a9fa28c652eb88bfaca2da3e891d 100644 --- a/src/core/Cargo.toml +++ b/src/core/Cargo.toml @@ -32,6 +32,11 @@ jemalloc = [ jemalloc_prof = [ "tikv-jemalloc-sys/profiling", ] +jemalloc_stats = [ + "tikv-jemalloc-sys/stats", + "tikv-jemalloc-ctl/stats", + "tikv-jemallocator/stats", +] hardened_malloc = [ "dep:hardened_malloc-rs" ] diff --git a/src/core/alloc/je.rs b/src/core/alloc/je.rs index 08bfc49ada7f29320fc17d5b562ad056ce994453..7561eb9595d51c90ef1831255e6d53393c2229f8 100644 --- a/src/core/alloc/je.rs +++ b/src/core/alloc/je.rs @@ -2,7 +2,6 @@ use std::ffi::{c_char, c_void}; -use tikv_jemalloc_ctl as mallctl; use tikv_jemalloc_sys as ffi; use tikv_jemallocator as jemalloc; @@ -10,8 +9,10 @@ static JEMALLOC: jemalloc::Jemalloc = jemalloc::Jemalloc; #[must_use] +#[cfg(feature = "jemalloc_stats")] pub fn memory_usage() -> Option<String> { use mallctl::stats; + use tikv_jemalloc_ctl as mallctl; let mibs = |input: Result<usize, mallctl::Error>| { let input = input.unwrap_or_default(); @@ -33,6 +34,10 @@ pub fn memory_usage() -> Option<String> { )) } +#[must_use] +#[cfg(not(feature = "jemalloc_stats"))] +pub fn memory_usage() -> Option<String> { None } + #[must_use] pub fn memory_stats() -> Option<String> { const MAX_LENGTH: usize = 65536 - 4096; diff --git a/src/main/Cargo.toml b/src/main/Cargo.toml index c002c12552000df6d1427ac606e706ec11c65d48..424bfad726bd040e41d91edb2522fdc69cd1b2dc 100644 --- a/src/main/Cargo.toml +++ b/src/main/Cargo.toml @@ -87,6 +87,9 @@ jemalloc = [ jemalloc_prof = [ "conduit-core/jemalloc_prof", ] +jemalloc_stats = [ + "conduit-core/jemalloc_stats", +] perf_measurements = [ "dep:opentelemetry", "dep:tracing-flame",