diff --git a/Cargo.lock b/Cargo.lock index 9f9da1d..8daa5d6 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -239,6 +239,7 @@ dependencies = [ "rand", "serde", "serde_with", + "tikv-jemallocator", "tokio", "tokio-stream", "tokio-util", @@ -1166,6 +1167,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 b5badd6..60de99d 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -3,6 +3,9 @@ name = "breeze" version = "0.2.9" edition = "2021" +[profile.dev.package] +tikv-jemalloc-sys = { opt-level = 3 } + [dependencies] axum-extra = { version = "0.10.0", default-features = false, features = [ "tracing", @@ -34,3 +37,6 @@ argh = "0.1.12" dashmap = { version = "6.1.0", features = ["inline"] } 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 e8cba56..8d581cc 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 {