From ab1f54bf518bd1f75170eeb08e1ab96516587e55 Mon Sep 17 00:00:00 2001 From: Kavin <20838718+FireMasterK@users.noreply.github.com> Date: Tue, 23 May 2023 04:03:52 +0100 Subject: [PATCH] Use the mimalloc allocator. --- Cargo.lock | 20 ++++++++++++++++++++ Cargo.toml | 1 + src/main.rs | 4 ++++ 3 files changed, 25 insertions(+) diff --git a/Cargo.lock b/Cargo.lock index 10f204b..737bc7a 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -857,6 +857,16 @@ version = "0.2.144" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "2b00cc1c228a6782d0f076e7b232802e0c5689d41bb5df366f2a6b6621cfdfe1" +[[package]] +name = "libmimalloc-sys" +version = "0.1.33" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f4ac0e912c8ef1b735e92369695618dc5b1819f5a7bf3f167301a3ba1cea515e" +dependencies = [ + "cc", + "libc", +] + [[package]] name = "libwebp-sys" version = "0.4.2" @@ -918,6 +928,15 @@ dependencies = [ "autocfg", ] +[[package]] +name = "mimalloc" +version = "0.1.37" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "4e2894987a3459f3ffb755608bd82188f8ed00d0ae077f1edea29c068d639d98" +dependencies = [ + "libmimalloc-sys", +] + [[package]] name = "mime" version = "0.3.17" @@ -1083,6 +1102,7 @@ version = "0.1.0" dependencies = [ "actix-web", "image", + "mimalloc", "once_cell", "qstring", "regex", diff --git a/Cargo.toml b/Cargo.toml index 74ebd99..1635fc3 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -8,6 +8,7 @@ version = "0.1.0" [dependencies] actix-web = "4.3.1" image = "0.24.6" +mimalloc = "0.1.37" once_cell = "1.17.1" qstring = "0.7.2" regex = "1.8.2" diff --git a/src/main.rs b/src/main.rs index 829e1c6..cbd39e9 100644 --- a/src/main.rs +++ b/src/main.rs @@ -4,11 +4,15 @@ use std::error::Error; use actix_web::{App, HttpRequest, HttpResponse, HttpResponseBuilder, HttpServer, web}; use actix_web::http::Method; use image::EncodableLayout; +use mimalloc::MiMalloc; use once_cell::sync::Lazy; use qstring::QString; use regex::Regex; use reqwest::{Client, Request, Url}; +#[global_allocator] +static GLOBAL: MiMalloc = MiMalloc; + #[actix_web::main] async fn main() -> std::io::Result<()> { println!("Running server!");