From 015aee89b8519ce94a603d5cd58f1c54ec3ac718 Mon Sep 17 00:00:00 2001 From: min Date: Mon, 13 Jan 2025 18:52:43 -0500 Subject: [PATCH] switch to jemalloc --- Cargo.lock | 21 +++++++++++++++++++++ Cargo.toml | 6 ++++++ src/main.rs | 7 +++++++ 3 files changed, 34 insertions(+) diff --git a/Cargo.lock b/Cargo.lock index e77e7e0..866ce6f 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -240,6 +240,7 @@ dependencies = [ "rayon", "serde", "serde_with", + "tikv-jemallocator", "tokio", "tokio-stream", "tokio-util", @@ -1240,6 +1241,26 @@ dependencies = [ "once_cell", ] +[[package]] +name = "tikv-jemalloc-sys" +version = "0.6.0+5.3.0-1-ge13ca993e8ccb9ba9847cc330696e02839f328f7" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "cd3c60906412afa9c2b5b5a48ca6a5abe5736aec9eb48ad05037a677e52e4e2d" +dependencies = [ + "cc", + "libc", +] + +[[package]] +name = "tikv-jemallocator" +version = "0.6.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "4cec5ff18518d81584f477e9bfdf957f5bb0979b0bac3af4ca30b5b3ae2d2865" +dependencies = [ + "libc", + "tikv-jemalloc-sys", +] + [[package]] name = "time" version = "0.3.37" diff --git a/Cargo.toml b/Cargo.toml index 953ad85..df3824f 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -3,6 +3,9 @@ name = "breeze" version = "0.2.8" edition = "2021" +[profile.dev.package] +tikv-jemalloc-sys = { opt-level = 3 } + [dependencies] axum-extra = { version = "0.10.0", default-features = false, features = [ "tracing", @@ -29,3 +32,6 @@ dashmap = { version = "6.1.0", features = ["rayon", "inline"] } rayon = "1.8" atomic-time = "0.1.4" img-parts = "0.3" + +[target.'cfg(not(target_env = "msvc"))'.dependencies] +tikv-jemallocator = "0.6" diff --git a/src/main.rs b/src/main.rs index b3275db..9de38e4 100644 --- a/src/main.rs +++ b/src/main.rs @@ -18,6 +18,13 @@ mod index; mod new; mod view; +#[cfg(not(target_env = "msvc"))] +use tikv_jemallocator::Jemalloc; + +#[cfg(not(target_env = "msvc"))] +#[global_allocator] +static GLOBAL: Jemalloc = Jemalloc; + /// breeze file server. #[derive(FromArgs, Debug)] struct Args {