diff --git a/Cargo.lock b/Cargo.lock index d607638..ea46a8a 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -1195,6 +1195,16 @@ version = "0.2.139" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "201de327520df007757c1f0adce6e827fe8562fbc28bfd9c15571c66ca1f5f79" +[[package]] +name = "libmimalloc-sys" +version = "0.1.28" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "04d1c67deb83e6b75fa4fe3309e09cfeade12e7721d95322af500d3814ea60c9" +dependencies = [ + "cc", + "libc", +] + [[package]] name = "link-cplusplus" version = "1.0.8" @@ -1265,6 +1275,15 @@ version = "2.5.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "2dffe52ecf27772e601905b7522cb4ef790d2cc203488bbd0e2fe85fcb74566d" +[[package]] +name = "mimalloc" +version = "0.1.32" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9b2374e2999959a7b583e1811a1ddbf1d3a4b9496eceb9746f1192a59d871eca" +dependencies = [ + "libmimalloc-sys", +] + [[package]] name = "mime" version = "0.3.16" @@ -1970,6 +1989,7 @@ dependencies = [ "itertools", "jsonwebtoken", "log", + "mimalloc", "mime", "mime_guess", "num_enum", diff --git a/Cargo.toml b/Cargo.toml index f6fcf13..8143460 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -29,6 +29,7 @@ indexmap = "1.9.2" itertools = "0.10.5" jsonwebtoken = "8.2.0" log = "0.4.17" +mimalloc = { version = "0.1.32", default-features = false, optional = true } mime = "0.3.16" mime_guess = "2.0.4" num_enum = "0.5.7" diff --git a/Dockerfile b/Dockerfile index ec1f8de..01e05d1 100644 --- a/Dockerfile +++ b/Dockerfile @@ -63,6 +63,7 @@ COPY Cargo.toml Cargo.lock ./ RUN cargo build \ --features ui \ + --features mimalloc \ --release diff --git a/src/main.rs b/src/main.rs index 9ce101a..06720af 100644 --- a/src/main.rs +++ b/src/main.rs @@ -1,4 +1,12 @@ #![forbid(unsafe_code)] + +#[cfg(feature = "mimalloc")] +use mimalloc::MiMalloc; + +#[cfg(feature = "mimalloc")] +#[global_allocator] +static GLOBAL: MiMalloc = MiMalloc; + #[cfg(feature = "cli")] use std::process::{ExitCode, Termination};