refactor: drop jemalloc in favor of mimalloc for musl targets (#587)

This commit is contained in:
Jose Quintana
2025-11-28 01:38:35 +01:00
committed by GitHub
parent ee4b049d3b
commit afddfd6e58
3 changed files with 23 additions and 31 deletions

41
Cargo.lock generated
View File

@@ -1360,6 +1360,16 @@ dependencies = [
"pkg-config",
]
[[package]]
name = "libmimalloc-sys"
version = "0.1.44"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "667f4fec20f29dfc6bc7357c582d91796c169ad7e2fce709468aefeb2c099870"
dependencies = [
"cc",
"libc",
]
[[package]]
name = "libredox"
version = "0.1.10"
@@ -1452,6 +1462,15 @@ version = "2.7.6"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "f52b00d39961fc5b2736ea853c9cc86238e165017a493d1d5c8eac6bdc4cc273"
[[package]]
name = "mimalloc"
version = "0.1.48"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "e1ee66a4b64c74f4ef288bcbb9192ad9c3feaad75193129ac8509af543894fd8"
dependencies = [
"libmimalloc-sys",
]
[[package]]
name = "mime"
version = "0.3.17"
@@ -2138,6 +2157,7 @@ dependencies = [
"hyper",
"listenfd",
"maud",
"mimalloc",
"mime_guess",
"mini-moka",
"percent-encoding",
@@ -2152,7 +2172,6 @@ dependencies = [
"shadow-rs",
"signal-hook",
"signal-hook-tokio",
"tikv-jemallocator",
"tokio",
"tokio-metrics-collector",
"tokio-rustls",
@@ -2271,26 +2290,6 @@ dependencies = [
"cfg-if",
]
[[package]]
name = "tikv-jemalloc-sys"
version = "0.6.1+5.3.0-1-ge13ca993e8ccb9ba9847cc330696e02839f328f7"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "cd8aa5b2ab86a2cefa406d889139c162cbb230092f7d1d7cbc1716405d852a3b"
dependencies = [
"cc",
"libc",
]
[[package]]
name = "tikv-jemallocator"
version = "0.6.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "0359b4327f954e0567e69fb191cf1436617748813819c94b8cd4a431422d053a"
dependencies = [
"libc",
"tikv-jemalloc-sys",
]
[[package]]
name = "time"
version = "0.3.44"

View File

@@ -99,8 +99,8 @@ toml = "0.9"
tracing = { version = "0.1", default-features = false, features = ["std"] }
tracing-subscriber = { version = "0.3", default-features = false, features = ["smallvec", "registry", "parking_lot", "fmt", "ansi", "tracing-log"] }
[target.'cfg(all(target_env = "musl", target_pointer_width = "64"))'.dependencies.tikv-jemallocator]
version = "0.6"
[target.'cfg(all(target_env = "musl", target_pointer_width = "64"))'.dependencies.mimalloc]
version = "0.1.48"
[target.'cfg(unix)'.dependencies]
signal-hook = { version = "0.3", features = ["extended-siginfo"] }
@@ -142,10 +142,3 @@ pre-build = [
"cp /tmp/netbsd/usr/lib/libexecinfo.so /usr/local/x86_64-unknown-netbsd/lib",
"rm -rf base.tar.xz /tmp/netbsd",
]
# Cross: Linux ARM64 Musl only
[package.metadata.cross.target.aarch64-unknown-linux-musl.env]
# workaround for jemalloc on ARM64 (musl) by using 64KB pagesize by default (max value)
# - https://github.com/static-web-server/static-web-server/issues/440
# - https://github.com/jemalloc/jemalloc/issues/467
passthrough = ["JEMALLOC_SYS_WITH_LG_PAGE=16"]

View File

@@ -10,7 +10,7 @@
#[cfg(all(target_env = "musl", target_pointer_width = "64"))]
#[global_allocator]
static GLOBAL: tikv_jemallocator::Jemalloc = tikv_jemallocator::Jemalloc;
static GLOBAL: mimalloc::MiMalloc = mimalloc::MiMalloc;
use static_web_server::{
Result, Settings,