feat: Add mimalloc support, drop hardened_malloc

This commit is contained in:
timedout authored and Jade Ellis committed 2026-11-21 15:21:54 +00:00
1 parent 68068574d3
commit d4ac77a023
8 files changed
+44 -68

No files matched your search

+5 -7
View File
@@ -26,14 +26,14 @@ conduwuit_mods = [
gzip_compression = [
"reqwest/gzip",
]
hardened_malloc = [
"dep:hardened_malloc-rs"
]
jemalloc = [
"dep:tikv-jemalloc-sys",
"dep:tikv-jemalloc-ctl",
"dep:tikv-jemallocator",
]
mimalloc = [
"dep:mimalloc",
]
jemalloc_conf = []
jemalloc_prof = [
"tikv-jemalloc-sys/profiling",
@@ -118,14 +118,12 @@ lock_api.workspace = true
hyper-util.workspace = true
resolvematrix.workspace = true
openidconnect.workspace = true
mimalloc.optional = true
mimalloc.workspace = true
[target.'cfg(unix)'.dependencies]
nix.workspace = true
[target.'cfg(all(not(target_env = "msvc"), target_os = "linux"))'.dependencies]
hardened_malloc-rs.workspace = true
hardened_malloc-rs.optional = true
[dev-dependencies]
maplit.workspace = true
opentelemetry_sdk.workspace = true
-18
View File
@@ -1,18 +0,0 @@
//! hmalloc allocator
#[global_allocator]
static HMALLOC: hardened_malloc_rs::HardenedMalloc = hardened_malloc_rs::HardenedMalloc;
pub fn trim<I: Into<Option<usize>>>(_: I) -> crate::Result { Ok(()) }
#[must_use]
//TODO: get usage
pub fn memory_usage() -> Option<String> { None }
#[must_use]
pub fn memory_usage_stats() -> Option<[(&'static str, usize); 6]> { None }
#[must_use]
pub fn memory_stats(_opts: &str) -> Option<String> {
Some("Extended statistics are not available from hardened_malloc.".to_owned())
}
+4
View File
@@ -0,0 +1,4 @@
use mimalloc::MiMalloc;
#[global_allocator]
static GLOBAL: MiMalloc = MiMalloc;
+7 -20
View File
@@ -1,27 +1,14 @@
//! Integration with allocators
// jemalloc
#[cfg(all(not(target_env = "msvc"), feature = "jemalloc"))]
pub mod default;
#[cfg(feature = "jemalloc")]
pub mod je;
#[cfg(all(not(target_env = "msvc"), feature = "jemalloc"))]
#[cfg(feature = "jemalloc")]
pub use je::{memory_stats, memory_usage, memory_usage_stats, trim};
#[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, memory_usage_stats, trim};
#[cfg(all(feature = "mimalloc", not(feature = "jemalloc")))]
pub mod mimalloc;
#[cfg(any(
target_env = "msvc",
all(not(feature = "hardened_malloc"), not(feature = "jemalloc"))
))]
pub mod default;
#[cfg(any(
target_env = "msvc",
all(not(feature = "hardened_malloc"), not(feature = "jemalloc"))
))]
#[cfg(not(feature = "jemalloc"))]
pub use default::{memory_stats, memory_usage, memory_usage_stats, trim};
+3 -3
View File
@@ -43,10 +43,10 @@ pub fn check(config: &Config) -> Result {
));
}
if cfg!(all(feature = "hardened_malloc", feature = "jemalloc", not(target_env = "msvc"))) {
if cfg!(all(feature = "mimalloc", feature = "jemalloc")) {
debug_warn!(
"hardened_malloc and jemalloc compile-time features are both enabled, this causes \
jemalloc to be used."
"mimalloc and jemalloc compile-time features are both enabled, this causes jemalloc \
to be used."
);
}