From ce744bfee87ab84a38cc9b2a06630a8282f944e0 Mon Sep 17 00:00:00 2001 From: Dominic Grimm Date: Fri, 2 Jun 2023 18:40:49 +0200 Subject: [PATCH] Release opt --- Cargo.lock | 21 +++++++++++++++++++++ Cargo.toml | 8 +++++++- src/main.rs | 6 ++++++ 3 files changed, 34 insertions(+), 1 deletion(-) diff --git a/Cargo.lock b/Cargo.lock index fc92473..8f5fbf6 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -929,6 +929,7 @@ dependencies = [ "juniper_actix", "lazy_static", "log", + "tikv-jemallocator", "tokio", "uuid 1.3.3", "uuid-simd", @@ -1998,6 +1999,26 @@ dependencies = [ "syn 2.0.18", ] +[[package]] +name = "tikv-jemalloc-sys" +version = "0.5.3+5.3.0-patched" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a678df20055b43e57ef8cddde41cdfda9a3c1a060b67f4c5836dfb1d78543ba8" +dependencies = [ + "cc", + "libc", +] + +[[package]] +name = "tikv-jemallocator" +version = "0.5.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "20612db8a13a6c06d57ec83953694185a367e16945f66565e8028d2c0bd76979" +dependencies = [ + "libc", + "tikv-jemalloc-sys", +] + [[package]] name = "time" version = "0.1.45" diff --git a/Cargo.toml b/Cargo.toml index 8ed9864..e0bb858 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -3,7 +3,10 @@ name = "fiddle" version = "0.1.0" edition = "2021" -# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html +[profile.release] +opt-level = 3 +lto = true +codegen-units = 1 [dependencies] actix-cors = "0.6.4" @@ -28,3 +31,6 @@ log = "0.4.18" tokio = { version = "1.28.2", features = ["full"] } uuid-simd = "0.8.0" uuidv7 = { version = "1.3.2", package = "uuid", features = ["serde"] } + +[target.'cfg(not(target_env = "msvc"))'.dependencies] +tikv-jemallocator = "0.5" diff --git a/src/main.rs b/src/main.rs index e08d7a5..626cb58 100644 --- a/src/main.rs +++ b/src/main.rs @@ -5,12 +5,18 @@ use diesel::prelude::*; use std::fs; use std::thread; use std::time::Duration; +#[cfg(not(target_env = "msvc"))] +use tikv_jemallocator::Jemalloc; use uuidv7::Uuid; use juniper_actix::graphql_handler; use fiddle::{api, db, init, prune_job, prune_many, CONFIG}; +#[cfg(not(target_env = "msvc"))] +#[global_allocator] +static GLOBAL: Jemalloc = Jemalloc; + fn tamper_prune() -> Result<()> { let db_conn = &mut db::POOL.get()?;