diff --git a/Cargo.lock b/Cargo.lock index 40b32494f..c24389dc9 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -7209,6 +7209,7 @@ dependencies = [ "serde_json", "serde_urlencoded", "shadow-rs", + "tikv-jemallocator", "time", "tokio", "tokio-rustls", @@ -8319,6 +8320,26 @@ dependencies = [ "ordered-float", ] +[[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.41" diff --git a/rustfs/Cargo.toml b/rustfs/Cargo.toml index 7da1010e6..ff8b5971e 100644 --- a/rustfs/Cargo.toml +++ b/rustfs/Cargo.toml @@ -81,6 +81,9 @@ uuid = { workspace = true } [target.'cfg(target_os = "linux")'.dependencies] libsystemd.workspace = true +[target.'cfg(all(target_os = "linux", target_env = "gnu"))'.dependencies] +tikv-jemallocator = "0.6" + [build-dependencies] prost-build.workspace = true tonic-build.workspace = true diff --git a/rustfs/src/main.rs b/rustfs/src/main.rs index 15c76f20b..5348b6e5a 100644 --- a/rustfs/src/main.rs +++ b/rustfs/src/main.rs @@ -54,6 +54,10 @@ use tonic::{metadata::MetadataValue, Request, Status}; use tower_http::cors::CorsLayer; use tracing::{debug, error, info, info_span, warn}; +#[cfg(all(target_os = "linux", target_env = "gnu"))] +#[global_allocator] +static GLOBAL: tikv_jemallocator::Jemalloc = tikv_jemallocator::Jemalloc; + fn check_auth(req: Request<()>) -> Result, Status> { let token: MetadataValue<_> = "rustfs rpc".parse().unwrap();