make jemalloc stats an optional feature
Signed-off-by: strawberry <strawberry@puppygock.gay>
This commit is contained in:
parent
867050df9e
commit
23690fd837
5 changed files with 20 additions and 5 deletions
|
@ -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"
|
||||
|
|
|
@ -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 =
|
||||
|
|
|
@ -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"
|
||||
]
|
||||
|
|
|
@ -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 @@ use tikv_jemallocator as jemalloc;
|
|||
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;
|
||||
|
|
|
@ -87,6 +87,9 @@ jemalloc = [
|
|||
jemalloc_prof = [
|
||||
"conduit-core/jemalloc_prof",
|
||||
]
|
||||
jemalloc_stats = [
|
||||
"conduit-core/jemalloc_stats",
|
||||
]
|
||||
perf_measurements = [
|
||||
"dep:opentelemetry",
|
||||
"dep:tracing-flame",
|
||||
|
|
Loading…
Add table
Reference in a new issue