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

Generated
+19 -7
View File
@@ -991,7 +991,6 @@ dependencies = [
"figment",
"futures",
"governor",
"hardened_malloc-rs",
"http",
"http-body-util",
"hyper-util",
@@ -1001,6 +1000,7 @@ dependencies = [
"libloading 0.9.1",
"lock_api 0.5.0",
"maplit",
"mimalloc",
"nix",
"num-traits",
"openidconnect",
@@ -2395,12 +2395,6 @@ dependencies = [
"tokio-util",
]
[[package]]
name = "hardened_malloc-rs"
version = "0.1.2+12"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "647deb1583b14d160f85f3ff626f20b6edd366e3852c9843b06077388f794cb6"
[[package]]
name = "hashbrown"
version = "0.12.3"
@@ -3256,6 +3250,15 @@ version = "0.2.16"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "b6d2cec3eae94f9f509c767b45932f1ada8350c4bdb85af2fcab4a3c14807981"
[[package]]
name = "libmimalloc-sys"
version = "0.1.49"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "6a45a52f43e1c16f667ccfe4dd8c85b7f7c204fd5e3bf46c5b0db9a5c3c0b8e9"
dependencies = [
"cc",
]
[[package]]
name = "libz-sys"
version = "1.1.32"
@@ -3429,6 +3432,15 @@ dependencies = [
"walkdir",
]
[[package]]
name = "mimalloc"
version = "0.1.52"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "2d4139bb28d14ad1facf21d5eb8825051b326e172d216b39f6d31df53cc97862"
dependencies = [
"libmimalloc-sys",
]
[[package]]
name = "mime"
version = "0.3.18"
+3 -9
View File
@@ -522,15 +522,6 @@ features = ["resource"]
version = "0.5.0"
default-features = false
[workspace.dependencies.hardened_malloc-rs]
version = "0.1.2"
default-features = false
features = [
"static",
"gcc",
"light",
]
[workspace.dependencies.rustyline-async]
version = "0.4.9"
default-features = false
@@ -610,6 +601,9 @@ features = ["unstable-msc4188"]
[workspace.dependencies.serde_urlencoded]
version = "0.7.1"
[workspace.dependencies.mimalloc]
version = "0.1.52"
#
# Patches
#
+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."
);
}
+3 -4
View File
@@ -70,7 +70,6 @@ standard = [
]
full = [
"standard",
# "hardened_malloc", # Conflicts with jemalloc
"jemalloc_prof",
"perf_measurements",
"tokio_console",
@@ -96,9 +95,6 @@ gzip_compression = [
"conduwuit-router/gzip_compression",
"conduwuit-service/gzip_compression",
]
hardened_malloc = [
"conduwuit-core/hardened_malloc",
]
http3 = [
"conduwuit-service/http3"
]
@@ -116,6 +112,9 @@ jemalloc = [
"conduwuit-core/jemalloc",
"conduwuit-service/jemalloc",
]
mimalloc = [
"conduwuit-core/mimalloc"
]
jemalloc_prof = [
"conduwuit-core/jemalloc_prof",
]