diff --git a/Cargo.lock b/Cargo.lock index 55e53db..7abc050 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -531,6 +531,7 @@ dependencies = [ "futures", "http 1.2.0", "hyper", + "jemallocator", "k8s-openapi", "kube", "opentelemetry", @@ -1409,6 +1410,26 @@ version = "1.0.14" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "d75a2a4b1b190afb6f5425f10f6a8f959d2ea0b9c2b1d79553551850539e4674" +[[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.32" diff --git a/Cargo.toml b/Cargo.toml index 3624609..a066fb3 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -45,6 +45,9 @@ thiserror = "2.0.11" anyhow = "1.0.95" prometheus-client = "0.23.1" +[target.'cfg(target_os = "linux")'.dependencies] +jemallocator = "0.5" + [dev-dependencies] assert-json-diff = "2.0.2" http = "1" diff --git a/src/main.rs b/src/main.rs index b572ffe..5306edd 100644 --- a/src/main.rs +++ b/src/main.rs @@ -1,7 +1,10 @@ -#![allow(unused_imports, unused_variables)] use actix_web::{get, middleware, web::Data, App, HttpRequest, HttpResponse, HttpServer, Responder}; pub use controller::{self, telemetry, State}; +#[cfg(all(target_os = "linux", target_arch = "x86_64"))] +#[global_allocator] +static GLOBAL: jemallocator::Jemalloc = jemallocator::Jemalloc; + #[get("/metrics")] async fn metrics(c: Data, _req: HttpRequest) -> impl Responder { let metrics = c.metrics();