From 47f884d310110960095fb171db35349086469beb Mon Sep 17 00:00:00 2001 From: Louis-Vincent Boudreault Date: Tue, 13 Jan 2026 16:10:43 +0000 Subject: [PATCH] 00004: use jemalloc and fix recv_mmmsg batch size hist metric --- Cargo.lock | 21 +++++++++++++++++++++ Cargo.toml | 1 + proxy/Cargo.toml | 3 +++ proxy/src/main.rs | 7 +++++++ proxy/src/prom.rs | 2 +- 5 files changed, 33 insertions(+), 1 deletion(-) diff --git a/Cargo.lock b/Cargo.lock index 0eaea59..9b3f306 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -2841,6 +2841,7 @@ dependencies = [ "solana-sdk", "solana-streamer", "thiserror 2.0.17", + "tikv-jemallocator", "tiny_http", "tokio", "tonic 0.13.1", @@ -9251,6 +9252,26 @@ dependencies = [ "syn 2.0.106", ] +[[package]] +name = "tikv-jemalloc-sys" +version = "0.6.1+5.3.0-1-ge13ca993e8ccb9ba9847cc330696e02839f328f7" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "cd8aa5b2ab86a2cefa406d889139c162cbb230092f7d1d7cbc1716405d852a3b" +dependencies = [ + "cc", + "libc", +] + +[[package]] +name = "tikv-jemallocator" +version = "0.6.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0359b4327f954e0567e69fb191cf1436617748813819c94b8cd4a431422d053a" +dependencies = [ + "libc", + "tikv-jemalloc-sys", +] + [[package]] name = "time" version = "0.3.44" diff --git a/Cargo.toml b/Cargo.toml index b72a26d..13eeab8 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -46,6 +46,7 @@ tiny_http = "0.12.0" tokio = "1" tonic = { version = "0.13", features = ["tls-webpki-roots"] } tonic-build = "0.13" +tikv-jemallocator = "0.6" [profile.release] # thin has minimal overhead vs none (default): https://blog.llvm.org/2016/06/thinlto-scalable-and-incremental-lto.html diff --git a/proxy/Cargo.toml b/proxy/Cargo.toml index 163260b..5f8defe 100644 --- a/proxy/Cargo.toml +++ b/proxy/Cargo.toml @@ -42,3 +42,6 @@ thiserror = { workspace = true } tiny_http = { workspace = true } tokio = { workspace = true } tonic = { workspace = true } + +[target.'cfg(not(target_env = "msvc"))'.dependencies] +tikv-jemallocator = { workspace = true } \ No newline at end of file diff --git a/proxy/src/main.rs b/proxy/src/main.rs index d04e333..23891b6 100644 --- a/proxy/src/main.rs +++ b/proxy/src/main.rs @@ -32,6 +32,13 @@ mod server; mod token_authenticator; mod prom; +#[cfg(not(target_env = "msvc"))] +use tikv_jemallocator::Jemalloc; + +#[cfg(not(target_env = "msvc"))] +#[global_allocator] +static GLOBAL: Jemalloc = Jemalloc; + #[derive(Clone, Debug, Parser)] #[clap(author, version, about, long_about = None)] // https://docs.rs/clap/latest/clap/_derive/_cookbook/git_derive/index.html diff --git a/proxy/src/prom.rs b/proxy/src/prom.rs index 4ad4391..32f88e0 100644 --- a/proxy/src/prom.rs +++ b/proxy/src/prom.rs @@ -26,7 +26,7 @@ lazy_static::lazy_static! { static ref RECV_PACKET_COUNT_HIST: Histogram = Histogram::with_opts( HistogramOpts::new("shredstream_recv_packet_count", "Number of packets in incoming batch (before dedup)") - .buckets(vec![1.0, 5.0, 10.0, 20.0, 50.0, 100.0, 200.0, 500.0, 1000.0]) + .buckets(vec![1.0, 2.0, 3.0, 5.0, 10.0, 20.0, 30.0, 40.0, 50.0, 64.0, 100.0]) ).unwrap(); static ref PACKETS_RECEIVED_TOTAL: Counter = Counter::new(