fix(allocator): switch global allocator from tikv-jemallocator to mimalloc

This commit is contained in:
2026-02-25 00:12:41 +00:00
parent f592bf627f
commit 7e5fe2bec3
6 changed files with 34 additions and 26 deletions

41
rust/Cargo.lock generated
View File

@@ -612,6 +612,16 @@ version = "0.2.180"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "bcc35a38544a891a5f7c865aca548a982ccb3b8650a5b06d0fd33a10283c56fc"
[[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 = "lock_api"
version = "0.4.14"
@@ -642,6 +652,15 @@ version = "2.8.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "f8ca58f447f06ed17d5fc4043ce1b10dd205e060fb3ce5b979b8ed8e59ff3f79"
[[package]]
name = "mimalloc"
version = "0.1.48"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "e1ee66a4b64c74f4ef288bcbb9192ad9c3feaad75193129ac8509af543894fd8"
dependencies = [
"libmimalloc-sys",
]
[[package]]
name = "mio"
version = "1.1.1"
@@ -924,6 +943,7 @@ dependencies = [
"http-body-util",
"hyper",
"hyper-util",
"mimalloc",
"rcgen",
"rustls",
"rustproxy-config",
@@ -936,7 +956,6 @@ dependencies = [
"rustproxy-tls",
"serde",
"serde_json",
"tikv-jemallocator",
"tokio",
"tokio-rustls",
"tokio-util",
@@ -1299,26 +1318,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.47"

View File

@@ -91,8 +91,8 @@ libc = "0.2"
# Socket-level options (keepalive, etc.)
socket2 = { version = "0.5", features = ["all"] }
# jemalloc allocator (prevents glibc fragmentation / slow RSS growth)
tikv-jemallocator = "0.6"
# mimalloc allocator (prevents glibc fragmentation / slow RSS growth)
mimalloc = "0.1"
# Internal crates
rustproxy-config = { path = "crates/rustproxy-config" }

View File

@@ -39,7 +39,7 @@ hyper = { workspace = true }
hyper-util = { workspace = true }
http-body-util = { workspace = true }
bytes = { workspace = true }
tikv-jemallocator = { workspace = true }
mimalloc = { workspace = true }
[dev-dependencies]
rcgen = { workspace = true }

View File

@@ -1,5 +1,5 @@
#[global_allocator]
static GLOBAL: tikv_jemallocator::Jemalloc = tikv_jemallocator::Jemalloc;
static GLOBAL: mimalloc::MiMalloc = mimalloc::MiMalloc;
use clap::Parser;
use tracing_subscriber::EnvFilter;