diff --git a/rust/Cargo.lock b/rust/Cargo.lock index e1e82c090..9a2cf8ca3 100644 --- a/rust/Cargo.lock +++ b/rust/Cargo.lock @@ -1367,6 +1367,26 @@ version = "1.0.8" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "62b02a5381cc465bd3041d84623d0fa3b66738b52b8e2fc3bab8ad63ab032f4a" +[[package]] +name = "jemalloc-sys" +version = "0.5.4+5.3.0-patched" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ac6c1946e1cea1788cbfde01c993b52a10e2da07f4bac608228d1bed20bfebf2" +dependencies = [ + "cc", + "libc", +] + +[[package]] +name = "jemallocator" +version = "0.5.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a0de374a9f8e63150e6f5e8a60cc14c668226d7a347d8aee1a45766e3c4dd3bc" +dependencies = [ + "jemalloc-sys", + "libc", +] + [[package]] name = "jobserver" version = "0.1.30" @@ -1947,6 +1967,7 @@ dependencies = [ "google-cloud-pubsub", "hex", "itertools 0.12.1", + "jemallocator", "kanal", "native-tls", "num_cpus", diff --git a/rust/Cargo.toml b/rust/Cargo.toml index acb5faa09..50206a411 100644 --- a/rust/Cargo.toml +++ b/rust/Cargo.toml @@ -60,6 +60,10 @@ google-cloud-googleapis = "0.10.0" google-cloud-pubsub = "0.18.0" hex = "0.4.3" itertools = "0.12.1" +jemallocator = { version = "0.5.0", features = [ + "profiling", + "unprefixed_malloc_on_supported_platforms", +] } kanal = { version = "0.1.0-pre8", features = ["async"] } once_cell = "1.10.0" num_cpus = "1.16.0" diff --git a/rust/processor/Cargo.toml b/rust/processor/Cargo.toml index c5ac7981f..36853359e 100644 --- a/rust/processor/Cargo.toml +++ b/rust/processor/Cargo.toml @@ -60,6 +60,9 @@ native-tls = { workspace = true } postgres-native-tls = { workspace = true } tokio-postgres = { workspace = true } +[target.'cfg(unix)'.dependencies] +jemallocator = { workspace = true } + [features] libpq = ["diesel/postgres"] # When using the default features we enable the diesel/postgres feature. We configure diff --git a/rust/processor/src/main.rs b/rust/processor/src/main.rs index 3e4b6cfdf..f26edb921 100644 --- a/rust/processor/src/main.rs +++ b/rust/processor/src/main.rs @@ -6,6 +6,10 @@ use clap::Parser; use processor::IndexerGrpcProcessorConfig; use server_framework::ServerArgs; +#[cfg(unix)] +#[global_allocator] +static ALLOC: jemallocator::Jemalloc = jemallocator::Jemalloc; + const RUNTIME_WORKER_MULTIPLIER: usize = 2; fn main() -> Result<()> {