feat: add feature for mimalloc

This commit is contained in:
Ryan 2025-03-10 20:27:20 -04:00
parent c2d1b415aa
commit 6600edabe6
Signed by: ErrorNoInternet
GPG Key ID: 2486BFB7B1E6A4A3
3 changed files with 25 additions and 0 deletions

20
Cargo.lock generated
View File

@ -1467,6 +1467,7 @@ dependencies = [
"hyper", "hyper",
"hyper-util", "hyper-util",
"log", "log",
"mimalloc",
"mlua", "mlua",
"ncr", "ncr",
"parking_lot", "parking_lot",
@ -2205,6 +2206,16 @@ version = "0.2.11"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "8355be11b20d696c8f18f6cc018c4e372165b1fa8126cef092399c9951984ffa" checksum = "8355be11b20d696c8f18f6cc018c4e372165b1fa8126cef092399c9951984ffa"
[[package]]
name = "libmimalloc-sys"
version = "0.1.39"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "23aa6811d3bd4deb8a84dde645f943476d13b248d818edcf8ce0b2f37f036b44"
dependencies = [
"cc",
"libc",
]
[[package]] [[package]]
name = "libz-sys" name = "libz-sys"
version = "1.1.21" version = "1.1.21"
@ -2301,6 +2312,15 @@ version = "2.7.4"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "78ca9ab1a0babb1e7d5695e3530886289c18cf2f87ec19a575a0abdce112e3a3" checksum = "78ca9ab1a0babb1e7d5695e3530886289c18cf2f87ec19a575a0abdce112e3a3"
[[package]]
name = "mimalloc"
version = "0.1.43"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "68914350ae34959d83f732418d51e2427a794055d0b9529f48259ac07af65633"
dependencies = [
"libmimalloc-sys",
]
[[package]] [[package]]
name = "mime" name = "mime"
version = "0.3.17" version = "0.3.17"

View File

@ -32,6 +32,7 @@ http-body-util = "0"
hyper = { version = "1", features = ["server"] } hyper = { version = "1", features = ["server"] }
hyper-util = "0" hyper-util = "0"
log = { version = "0" } log = { version = "0" }
mimalloc = { version = "0", optional = true }
mlua = { version = "0", features = ["async", "luajit", "send"] } mlua = { version = "0", features = ["async", "luajit", "send"] }
ncr = { version = "0", features = ["cfb8", "ecb", "gcm"] } ncr = { version = "0", features = ["cfb8", "ecb", "gcm"] }
parking_lot = "0" parking_lot = "0"
@ -42,3 +43,4 @@ zip = "2"
[features] [features]
console-subscriber = ["dep:console-subscriber"] console-subscriber = ["dep:console-subscriber"]
mimalloc = ["dep:mimalloc"]

View File

@ -33,6 +33,9 @@ use std::{
sync::Arc, sync::Arc,
}; };
#[cfg(feature = "mimalloc")]
#[global_allocator]
static GLOBAL: mimalloc::MiMalloc = mimalloc::MiMalloc;
type ListenerMap = Arc<RwLock<HashMap<String, Vec<(String, Function)>>>>; type ListenerMap = Arc<RwLock<HashMap<String, Vec<(String, Function)>>>>;