From 74420aa016dd1ccfcc9ba7c0ba37d4aa9290e0de Mon Sep 17 00:00:00 2001 From: Oliver Browne Date: Wed, 4 Sep 2024 15:19:31 +0300 Subject: [PATCH] fix(capture-replay): try using jemalloc (#24778) --- rust/Cargo.lock | 21 +++++++++++++++++++++ rust/capture/Cargo.toml | 4 ++++ rust/capture/src/main.rs | 7 +++++++ 3 files changed, 32 insertions(+) diff --git a/rust/Cargo.lock b/rust/Cargo.lock index 55c64258d5ec2..8b577220c3ae0 100644 --- a/rust/Cargo.lock +++ b/rust/Cargo.lock @@ -639,6 +639,7 @@ dependencies = [ "serde_json", "serde_urlencoded", "thiserror", + "tikv-jemallocator", "time", "tokio", "tower", @@ -3980,6 +3981,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.36" diff --git a/rust/capture/Cargo.toml b/rust/capture/Cargo.toml index 55ccddd3a0311..cc551cdac99a1 100644 --- a/rust/capture/Cargo.toml +++ b/rust/capture/Cargo.toml @@ -7,6 +7,10 @@ edition = "2021" workspace = true [dependencies] + +[target.'cfg(not(target_env = "msvc"))'.dependencies] +tikv-jemallocator = "0.6" + anyhow = { workspace = true } async-trait = { workspace = true } axum = { workspace = true } diff --git a/rust/capture/src/main.rs b/rust/capture/src/main.rs index 12b91941c7f6c..14868f059f02b 100644 --- a/rust/capture/src/main.rs +++ b/rust/capture/src/main.rs @@ -16,6 +16,13 @@ use tracing_subscriber::{EnvFilter, Layer}; use capture::config::Config; use capture::server::serve; +#[cfg(not(target_env = "msvc"))] +use tikv_jemallocator::Jemalloc; + +#[cfg(not(target_env = "msvc"))] +#[global_allocator] +static GLOBAL: Jemalloc = Jemalloc; + async fn shutdown() { let mut term = signal::unix::signal(signal::unix::SignalKind::terminate()) .expect("failed to register SIGTERM handler");