From 7eee8efae0738785f590573509d5bde010fbbd2f Mon Sep 17 00:00:00 2001 From: aumetra Date: Mon, 18 Sep 2023 18:42:24 +0200 Subject: [PATCH] Replace jemalloc with mimalloc (#350) * Replace jemalloc with mimalloc * use mimalloc for job runner --- Cargo.lock | 44 +++++++++++++++---------------- kitsune-job-runner/Cargo.toml | 1 + kitsune-job-runner/src/main.rs | 3 +++ kitsune-search-server/Cargo.toml | 4 +-- kitsune-search-server/src/main.rs | 2 +- kitsune/Cargo.toml | 4 +-- kitsune/src/main.rs | 2 +- 7 files changed, 30 insertions(+), 30 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index c48aee168..5d29701c6 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -3120,6 +3120,7 @@ dependencies = [ "metrics-exporter-prometheus", "metrics-tracing-context", "metrics-util", + "mimalloc", "mime", "mime_guess", "openidconnect", @@ -3138,7 +3139,6 @@ dependencies = [ "strum", "tempfile", "thiserror", - "tikv-jemallocator", "time", "tokio", "tokio-util", @@ -3378,6 +3378,7 @@ dependencies = [ "just-retry", "kitsune-core", "kitsune-db", + "mimalloc", "tokio", "toml 0.8.0", "tracing", @@ -3459,12 +3460,12 @@ dependencies = [ "metrics-exporter-prometheus", "metrics-tracing-context", "metrics-util", + "mimalloc", "prost", "rand", "serde", "tantivy", "tempfile", - "tikv-jemallocator", "time", "tokio", "tonic", @@ -3641,6 +3642,16 @@ version = "0.2.7" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "f7012b1bbb0719e1097c47611d3898568c546d597c2e74d66f6087edd5233ff4" +[[package]] +name = "libmimalloc-sys" +version = "0.1.35" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3979b5c37ece694f1f5e51e7ecc871fdb0f517ed04ee45f88d15d6d553cb9664" +dependencies = [ + "cc", + "libc", +] + [[package]] name = "libnghttp2-sys" version = "0.1.8+1.55.1" @@ -4010,6 +4021,15 @@ dependencies = [ "quote", ] +[[package]] +name = "mimalloc" +version = "0.1.39" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "fa01922b5ea280a911e323e4d2fd24b7fe5cc4042e0d2cda3c40775cdc4bdc9c" +dependencies = [ + "libmimalloc-sys", +] + [[package]] name = "mime" version = "0.3.17" @@ -6296,26 +6316,6 @@ dependencies = [ "once_cell", ] -[[package]] -name = "tikv-jemalloc-sys" -version = "0.5.4+5.3.0-patched" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9402443cb8fd499b6f327e40565234ff34dbda27460c5b47db0db77443dd85d1" -dependencies = [ - "cc", - "libc", -] - -[[package]] -name = "tikv-jemallocator" -version = "0.5.4" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "965fe0c26be5c56c94e38ba547249074803efd52adfb66de62107d95aab3eaca" -dependencies = [ - "libc", - "tikv-jemalloc-sys", -] - [[package]] name = "time" version = "0.3.28" diff --git a/kitsune-job-runner/Cargo.toml b/kitsune-job-runner/Cargo.toml index c769bdbd8..2baf2576b 100644 --- a/kitsune-job-runner/Cargo.toml +++ b/kitsune-job-runner/Cargo.toml @@ -11,6 +11,7 @@ deadpool-redis = "0.12.0" just-retry = { path = "../lib/just-retry" } kitsune-core = { path = "../crates/kitsune-core" } kitsune-db = { path = "../crates/kitsune-db" } +mimalloc = "0.1.39" tokio = { version = "1.32.0", features = ["full"] } toml = "0.8.0" tracing = "0.1.37" diff --git a/kitsune-job-runner/src/main.rs b/kitsune-job-runner/src/main.rs index 009179190..bb0dc2acc 100644 --- a/kitsune-job-runner/src/main.rs +++ b/kitsune-job-runner/src/main.rs @@ -4,6 +4,9 @@ use kitsune_core::{config::Configuration, consts::VERSION}; use std::path::PathBuf; use tokio::fs; +#[global_allocator] +static GLOBAL: mimalloc::MiMalloc = mimalloc::MiMalloc; + /// Dedicated Kitsune job runner #[derive(Parser)] #[command(about, author, version = VERSION)] diff --git a/kitsune-search-server/Cargo.toml b/kitsune-search-server/Cargo.toml index 8f132cf52..5a08c3605 100644 --- a/kitsune-search-server/Cargo.toml +++ b/kitsune-search-server/Cargo.toml @@ -11,14 +11,12 @@ dotenvy = "0.15.7" envy = "0.4.2" futures-util = "0.3.28" human-size = { version = "0.4.3", features = ["serde"] } -tikv-jemallocator = { version = "0.5.4", default-features = false, features = [ - "background_threads", -] } kitsune-search-proto = { path = "proto" } metrics = "0.21.1" metrics-exporter-prometheus = "0.12.1" metrics-tracing-context = "0.14.0" metrics-util = "0.15.1" +mimalloc = "0.1.39" prost = "0.12.1" serde = { version = "1.0.188", features = ["derive"] } tantivy = "0.21.0" diff --git a/kitsune-search-server/src/main.rs b/kitsune-search-server/src/main.rs index dcf6081d1..f670d2ceb 100644 --- a/kitsune-search-server/src/main.rs +++ b/kitsune-search-server/src/main.rs @@ -18,7 +18,7 @@ use tracing::metadata::LevelFilter; use tracing_subscriber::{filter::Targets, layer::SubscriberExt, Layer as _, Registry}; #[global_allocator] -static GLOBAL: tikv_jemallocator::Jemalloc = tikv_jemallocator::Jemalloc; +static GLOBAL: mimalloc::MiMalloc = mimalloc::MiMalloc; const STARTUP_FIGLET: &str = r#" ┏━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━┓ diff --git a/kitsune/Cargo.toml b/kitsune/Cargo.toml index 30b031c4a..f8a04ffa0 100644 --- a/kitsune/Cargo.toml +++ b/kitsune/Cargo.toml @@ -42,12 +42,10 @@ http = "0.2.9" human-panic = "1.2.0" hyper = { version = "0.14.27", features = ["deprecated"] } iso8601-timestamp = "0.2.11" +mimalloc = "0.1.39" mime = "0.3.17" mime_guess = { version = "2.0.4", default-features = false } pkcs8 = "0.10.2" -tikv-jemallocator = { version = "0.5.4", default-features = false, features = [ - "background_threads", -] } kitsune-cache = { path = "../crates/kitsune-cache" } kitsune-captcha = { path = "../crates/kitsune-captcha" } kitsune-core = { path = "../crates/kitsune-core" } diff --git a/kitsune/src/main.rs b/kitsune/src/main.rs index b18b4e87c..382f20865 100644 --- a/kitsune/src/main.rs +++ b/kitsune/src/main.rs @@ -18,7 +18,7 @@ use tracing_subscriber::{filter::Targets, layer::SubscriberExt, Layer, Registry} use url::Url; #[global_allocator] -static GLOBAL: tikv_jemallocator::Jemalloc = tikv_jemallocator::Jemalloc; +static GLOBAL: mimalloc::MiMalloc = mimalloc::MiMalloc; fn install_handlers() -> eyre::Result<()> { let (eyre_panic_hook, eyre_hook) = HookBuilder::new().into_hooks();