From a86f8e59407fca9777ab0a7e4a3ba8f27cad97c0 Mon Sep 17 00:00:00 2001 From: Fabrizio Sestito Date: Wed, 22 May 2024 15:33:52 +0200 Subject: [PATCH] fix: configure jemalloc in lib.rs Signed-off-by: Fabrizio Sestito --- src/lib.rs | 11 +++++++++++ src/main.rs | 11 ----------- 2 files changed, 11 insertions(+), 11 deletions(-) diff --git a/src/lib.rs b/src/lib.rs index 7fe3ebda..b7ffc8fa 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -50,6 +50,17 @@ use crate::evaluation::{ use crate::policy_downloader::{Downloader, FetchedPolicies}; use config::Config; +use tikv_jemallocator::Jemalloc; + +#[global_allocator] +static GLOBAL: Jemalloc = Jemalloc; + +#[allow(non_upper_case_globals)] +#[export_name = "malloc_conf"] +/// Prioritize memory usage, then enable features request by pprof but do not activate them by +/// default. When pprof is activate there's a CPU overhead. +pub static malloc_conf: &[u8] = b"background_thread:true,tcache_max:4096,dirty_decay_ms:5000,muzzy_decay_ms:5000,abort_conf:true,prof:true,prof_active:false,lg_prof_sample:19\0"; + pub struct PolicyServer { router: Router, callback_handler: CallbackHandler, diff --git a/src/main.rs b/src/main.rs index f51e41ae..590c3b8d 100644 --- a/src/main.rs +++ b/src/main.rs @@ -10,17 +10,6 @@ use policy_server::metrics::setup_metrics; use policy_server::tracing::setup_tracing; use policy_server::PolicyServer; -use tikv_jemallocator::Jemalloc; - -#[global_allocator] -static GLOBAL: Jemalloc = Jemalloc; - -#[allow(non_upper_case_globals)] -#[export_name = "malloc_conf"] -/// Prioritize memory usage, then enable features request by pprof but do not activate them by -/// default. When pprof is activate there's a CPU overhead. -pub static malloc_conf: &[u8] = b"background_thread:true,tcache_max:4096,dirty_decay_ms:5000,muzzy_decay_ms:5000,abort_conf:true,prof:true,prof_active:false,lg_prof_sample:19\0"; - #[tokio::main] async fn main() -> Result<()> { let matches = cli::build_cli().get_matches();