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] #[global_allocator]
static HMALLOC: hardened_malloc_rs::HardenedMalloc = hardened_malloc_rs::HardenedMalloc; 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 std::ffi::{c_char, c_void};
use tikv_jemalloc_ctl as mallctl; use tikv_jemalloc_ctl as mallctl;

View file

@ -1,27 +1,17 @@
//! Integration with allocators //! Integration with allocators
// jemalloc // jemalloc
#[cfg(all(not(target_env = "msvc"), feature = "jemalloc", not(feature = "hardened_malloc")))] #[cfg(all(not(target_env = "msvc"), feature = "jemalloc"))]
pub mod je; 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}; pub use je::{memory_stats, memory_usage};
// hardened_malloc #[cfg(all(not(target_env = "msvc"), feature = "hardened_malloc", not(feature = "jemalloc")))]
//#[cfg(all(not(target_env = "msvc"), feature = "hardened_malloc", target_os = pub mod hardened;
//#[cfg(all(not(target_env "linux", not(feature = "jemalloc")))] #[cfg(all(not(target_env = "msvc"), feature = "hardened_malloc", not(feature = "jemalloc")))]
//pub mod hardened; pub use hardened::{memory_stats, memory_usage};
//#[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};
// default, enabled when none or multiple of the above are enabled #[cfg(any(target_env = "msvc", all(not(feature = "hardened_malloc"), not(feature = "jemalloc"))))]
#[cfg(any(
not(any(feature = "jemalloc", feature = "hardened_malloc")),
all(feature = "jemalloc", feature = "hardened_malloc"),
))]
pub mod default; pub mod default;
#[cfg(any( #[cfg(any(target_env = "msvc", all(not(feature = "hardened_malloc"), not(feature = "jemalloc"))))]
not(any(feature = "jemalloc", feature = "hardened_malloc")),
all(feature = "jemalloc", feature = "hardened_malloc"),
))]
pub use default::{memory_stats, memory_usage}; 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") { if cfg!(feature = "hardened_malloc") && cfg!(feature = "jemalloc") {
warn!( warn!("hardened_malloc and jemalloc are both enabled, this causes jemalloc to be used.");
"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."
);
} }
if config.unix_socket_path.is_some() && !cfg!(unix) { if config.unix_socket_path.is_some() && !cfg!(unix) {