From 6600edabe6736f636dbde856069a65872a3f0978 Mon Sep 17 00:00:00 2001 From: ErrorNoInternet Date: Mon, 10 Mar 2025 20:27:20 -0400 Subject: [PATCH] feat: add feature for mimalloc --- Cargo.lock | 20 ++++++++++++++++++++ Cargo.toml | 2 ++ src/main.rs | 3 +++ 3 files changed, 25 insertions(+) diff --git a/Cargo.lock b/Cargo.lock index 0d7904f..f026f39 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -1467,6 +1467,7 @@ dependencies = [ "hyper", "hyper-util", "log", + "mimalloc", "mlua", "ncr", "parking_lot", @@ -2205,6 +2206,16 @@ version = "0.2.11" source = "registry+https://github.com/rust-lang/crates.io-index" 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]] name = "libz-sys" version = "1.1.21" @@ -2301,6 +2312,15 @@ version = "2.7.4" source = "registry+https://github.com/rust-lang/crates.io-index" 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]] name = "mime" version = "0.3.17" diff --git a/Cargo.toml b/Cargo.toml index b1610fb..3b87463 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -32,6 +32,7 @@ http-body-util = "0" hyper = { version = "1", features = ["server"] } hyper-util = "0" log = { version = "0" } +mimalloc = { version = "0", optional = true } mlua = { version = "0", features = ["async", "luajit", "send"] } ncr = { version = "0", features = ["cfb8", "ecb", "gcm"] } parking_lot = "0" @@ -42,3 +43,4 @@ zip = "2" [features] console-subscriber = ["dep:console-subscriber"] +mimalloc = ["dep:mimalloc"] diff --git a/src/main.rs b/src/main.rs index 0ea12f9..685ee09 100644 --- a/src/main.rs +++ b/src/main.rs @@ -33,6 +33,9 @@ use std::{ sync::Arc, }; +#[cfg(feature = "mimalloc")] +#[global_allocator] +static GLOBAL: mimalloc::MiMalloc = mimalloc::MiMalloc; type ListenerMap = Arc>>>;