From a6b1b0ff76ab2d9fe514e4f9dd9b66fc732e35ef Mon Sep 17 00:00:00 2001 From: Jef Roosens Date: Fri, 3 Sep 2021 16:31:06 +0200 Subject: [PATCH] Added mimalloc as allocator --- Cargo.lock | 19 +++++++++++++++++++ Cargo.toml | 3 ++- src/main.rs | 3 +++ 3 files changed, 24 insertions(+), 1 deletion(-) diff --git a/Cargo.lock b/Cargo.lock index 92643bd..b10ec77 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -648,6 +648,15 @@ version = "0.2.99" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "a7f823d141fe0a24df1e23b4af4e3c7ba9e5966ec514ea068c93024aa7deb765" +[[package]] +name = "libmimalloc-sys" +version = "0.1.22" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1d1b8479c593dba88c2741fc50b92e13dbabbbe0bd504d979f244ccc1a5b1c01" +dependencies = [ + "cc", +] + [[package]] name = "linked-hash-map" version = "0.5.4" @@ -712,6 +721,15 @@ dependencies = [ "syn", ] +[[package]] +name = "mimalloc" +version = "0.1.26" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "fb74897ce508e6c49156fd1476fc5922cbc6e75183c65e399c765a09122e5130" +dependencies = [ + "libmimalloc-sys", +] + [[package]] name = "mime" version = "0.3.16" @@ -1201,6 +1219,7 @@ dependencies = [ "figment", "hmac", "jwt", + "mimalloc", "openssl", "rand", "rocket", diff --git a/Cargo.toml b/Cargo.toml index 5b80483..c6f71fa 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -36,8 +36,9 @@ chrono = { version = "*", features = [ "serde" ] } base64 = "0.13.0" # Reading in configuration files figment = { version = "*", features = [ "yaml" ] } +mimalloc = { version = "0.1.26", default_features = false } [profile.release] -lto = true +lto = "fat" panic = "abort" codegen-units = 1 diff --git a/src/main.rs b/src/main.rs index d4ee778..2819e79 100644 --- a/src/main.rs +++ b/src/main.rs @@ -28,6 +28,9 @@ pub mod errors; pub mod guards; pub(crate) mod schema; +#[global_allocator] +static GLOBAL: mimalloc::MiMalloc = mimalloc::MiMalloc; + #[database("postgres_rb")] pub struct RbDbConn(diesel::PgConnection);