default to jemalloc when both hardened_malloc and jemalloc enabled.

Signed-off-by: Jason Volk <jason@zemos.net>
This commit is contained in:
Jason Volk 2024-06-22 19:28:26 +00:00
parent 3a51e18ce6
commit 0e46b750a0
4 changed files with 13 additions and 22 deletions

View file

@ -1,3 +1,5 @@
//! hmalloc allocator
#[global_allocator]
static HMALLOC: hardened_malloc_rs::HardenedMalloc = hardened_malloc_rs::HardenedMalloc;

View file

@ -1,3 +1,5 @@
//! jemalloc allocator
use std::ffi::{c_char, c_void};
use tikv_jemalloc_ctl as mallctl;

View file

@ -1,27 +1,17 @@
//! Integration with allocators
// jemalloc
#[cfg(all(not(target_env = "msvc"), feature = "jemalloc", not(feature = "hardened_malloc")))]
#[cfg(all(not(target_env = "msvc"), feature = "jemalloc"))]
pub mod je;
#[cfg(all(not(target_env = "msvc"), feature = "jemalloc", not(feature = "hardened_malloc")))]
#[cfg(all(not(target_env = "msvc"), feature = "jemalloc"))]
pub use je::{memory_stats, memory_usage};
// hardened_malloc
//#[cfg(all(not(target_env = "msvc"), feature = "hardened_malloc", target_os =
//#[cfg(all(not(target_env "linux", not(feature = "jemalloc")))]
//pub mod hardened;
//#[cfg(all(not(target_env = "msvc"), feature = "hardened_malloc", target_os =
//#[cfg(all(not(target_env "linux", not(feature = "jemalloc")))]
//pub use hardened::{memory_stats, memory_usage};
#[cfg(all(not(target_env = "msvc"), feature = "hardened_malloc", not(feature = "jemalloc")))]
pub mod hardened;
#[cfg(all(not(target_env = "msvc"), feature = "hardened_malloc", not(feature = "jemalloc")))]
pub use hardened::{memory_stats, memory_usage};
// default, enabled when none or multiple of the above are enabled
#[cfg(any(
not(any(feature = "jemalloc", feature = "hardened_malloc")),
all(feature = "jemalloc", feature = "hardened_malloc"),
))]
#[cfg(any(target_env = "msvc", all(not(feature = "hardened_malloc"), not(feature = "jemalloc"))))]
pub mod default;
#[cfg(any(
not(any(feature = "jemalloc", feature = "hardened_malloc")),
all(feature = "jemalloc", feature = "hardened_malloc"),
))]
#[cfg(any(target_env = "msvc", all(not(feature = "hardened_malloc"), not(feature = "jemalloc"))))]
pub use default::{memory_stats, memory_usage};

View file

@ -14,10 +14,7 @@ pub fn check(config: &Config) -> Result<(), Error> {
}
if cfg!(feature = "hardened_malloc") && cfg!(feature = "jemalloc") {
warn!(
"hardened_malloc and jemalloc were built together, this causes neither to be used. Conduwuit will still \
function, but consider rebuilding and pick one as this is now no-op."
);
warn!("hardened_malloc and jemalloc are both enabled, this causes jemalloc to be used.");
}
if config.unix_socket_path.is_some() && !cfg!(unix) {