jemalloc and triomphe

This commit is contained in:
Michael Sproul
2022-02-02 16:01:34 +11:00
parent b2063c3e21
commit bda90573fa
6 changed files with 61 additions and 3 deletions

View File

@@ -0,0 +1,2 @@
#[global_allocator]
static ALLOC: jemallocator::Jemalloc = jemallocator::Jemalloc;

View File

@@ -24,18 +24,27 @@
//! detecting `glibc` are best-effort. If this crate throws errors about undefined external
//! functions, then try to compile with the `not_glibc_interface` module.
#[cfg(all(target_os = "linux", not(target_env = "musl")))]
#[cfg(all(
target_os = "linux",
not(any(target_env = "musl", feature = "jemalloc"))
))]
mod glibc;
#[cfg(feature = "jemalloc")]
mod jemalloc;
pub use interface::*;
#[cfg(all(target_os = "linux", not(target_env = "musl")))]
#[cfg(all(
target_os = "linux",
not(any(target_env = "musl", feature = "jemalloc"))
))]
mod interface {
pub use crate::glibc::configure_glibc_malloc as configure_memory_allocator;
pub use crate::glibc::scrape_mallinfo_metrics as scrape_allocator_metrics;
}
#[cfg(any(not(target_os = "linux"), target_env = "musl"))]
#[cfg(any(not(target_os = "linux"), target_env = "musl", feature = "jemalloc"))]
mod interface {
#[allow(dead_code, clippy::unnecessary_wraps)]
pub fn configure_memory_allocator() -> Result<(), String> {