diff --git a/rust/Cargo.lock b/rust/Cargo.lock index 8d6ed013b..5458035cc 100644 --- a/rust/Cargo.lock +++ b/rust/Cargo.lock @@ -2216,6 +2216,7 @@ dependencies = [ "futures-bounded", "ip-packet", "ip_network", + "jemallocator", "libc", "moka", "nix 0.29.0", @@ -2422,6 +2423,7 @@ dependencies = [ "futures", "hex", "hex-display", + "jemallocator", "mio", "once_cell", "opentelemetry", @@ -3643,6 +3645,26 @@ dependencies = [ "system-deps", ] +[[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 = "jni" version = "0.21.1" diff --git a/rust/Cargo.toml b/rust/Cargo.toml index ca12c20de..23fbca50e 100644 --- a/rust/Cargo.toml +++ b/rust/Cargo.toml @@ -81,6 +81,7 @@ firezone-tunnel = { path = "connlib/tunnel" } flume = { version = "0.11.1", features = ["async"] } futures = { version = "0.3.31" } futures-bounded = "0.2.1" +gat-lending-iterator = "0.1.6" glob = "0.3.2" hex = "0.4.3" hex-display = "0.3.0" @@ -90,6 +91,7 @@ ip-packet = { path = "ip-packet" } ip_network = { version = "0.4", default-features = false } ip_network_table = { version = "0.2", default-features = false } itertools = "0.13" +jemallocator = "0.5.4" jni = "0.21.1" keyring = "3.6.1" known-folders = "1.2.0" @@ -120,7 +122,6 @@ proptest = "1.6.0" proptest-state-machine = "0.3.1" quinn-udp = { version = "0.5.8", features = ["fast-apple-datapath"] } rand = "0.8.5" -gat-lending-iterator = "0.1.6" rand_core = "0.6.4" rangemap = "1.5.1" rayon = "1.10.0" @@ -183,9 +184,9 @@ trackable = "1.3.0" tun = { path = "tun" } url = "2.5.2" uuid = "1.16.0" +which = "4.4.2" windows = "0.58.0" winreg = "0.52.0" -which = "4.4.2" zbus = "5.5.0" zip = { version = "2", default-features = false } diff --git a/rust/gateway/Cargo.toml b/rust/gateway/Cargo.toml index 357613b75..9ea1a88e6 100644 --- a/rust/gateway/Cargo.toml +++ b/rust/gateway/Cargo.toml @@ -49,6 +49,7 @@ uuid = { workspace = true, features = ["v4"] } [target.'cfg(target_os = "linux")'.dependencies] caps = { workspace = true } +jemallocator = { workspace = true } [dev-dependencies] serde_json = { workspace = true, features = ["std"] } diff --git a/rust/gateway/src/main.rs b/rust/gateway/src/main.rs index a32d98de9..fb2453718 100644 --- a/rust/gateway/src/main.rs +++ b/rust/gateway/src/main.rs @@ -1,3 +1,7 @@ +#[cfg(unix)] +#[cfg_attr(unix, global_allocator)] +static GLOBAL: jemallocator::Jemalloc = jemallocator::Jemalloc; + use crate::eventloop::{Eventloop, PHOENIX_TOPIC}; use anyhow::{Context, Result}; use backoff::ExponentialBackoffBuilder; diff --git a/rust/relay/server/Cargo.toml b/rust/relay/server/Cargo.toml index 4486b36f1..ad6075d3b 100644 --- a/rust/relay/server/Cargo.toml +++ b/rust/relay/server/Cargo.toml @@ -53,6 +53,7 @@ uuid = { workspace = true, features = ["v4"] } [target.'cfg(target_os = "linux")'.dependencies] aya = { workspace = true, features = ["tokio"] } aya-log = { workspace = true } +jemallocator = { workspace = true } [dev-dependencies] difference = { workspace = true } diff --git a/rust/relay/server/src/main.rs b/rust/relay/server/src/main.rs index 7613aae7f..0836900bf 100644 --- a/rust/relay/server/src/main.rs +++ b/rust/relay/server/src/main.rs @@ -1,5 +1,9 @@ #![cfg_attr(test, allow(clippy::unwrap_used))] +#[cfg(unix)] +#[cfg_attr(unix, global_allocator)] +static GLOBAL: jemallocator::Jemalloc = jemallocator::Jemalloc; + use anyhow::{Context, Result, bail}; use backoff::ExponentialBackoffBuilder; use clap::Parser;