From da091cbad77d91cab4d6e3dc921cdaddfaad8a4f Mon Sep 17 00:00:00 2001 From: Ruben Fiszel Date: Mon, 20 May 2024 18:57:26 +0200 Subject: [PATCH] only enable profiling if env variable is present --- Dockerfile | 2 -- backend/src/monitor.rs | 9 ++++++--- 2 files changed, 6 insertions(+), 5 deletions(-) diff --git a/Dockerfile b/Dockerfile index c7cd51db68..fc9a64048c 100644 --- a/Dockerfile +++ b/Dockerfile @@ -185,8 +185,6 @@ RUN ln -s ${APP}/windmill /usr/local/bin/windmill RUN windmill cache -ENV _RJEM_MALLOC_CONF=prof:true,prof_active:false,lg_prof_interval:30,lg_prof_sample:21,prof_prefix:/tmp/jeprof - EXPOSE 8000 CMD ["windmill"] diff --git a/backend/src/monitor.rs b/backend/src/monitor.rs index 60be1e837d..9df04f23c3 100644 --- a/backend/src/monitor.rs +++ b/backend/src/monitor.rs @@ -203,9 +203,12 @@ pub async fn load_metrics_debug_enabled(db: &DB) -> error::Result<()> { match metrics_enabled { Ok(Some(serde_json::Value::Bool(t))) => { METRICS_DEBUG_ENABLED.store(t, Ordering::Relaxed); + //_RJEM_MALLOC_CONF=prof:true,prof_active:false,lg_prof_interval:30,lg_prof_sample:21,prof_prefix:/tmp/jeprof #[cfg(all(not(target_env = "msvc"), feature = "jemalloc"))] - if let Err(e) = set_prof_active(t) { - tracing::error!("Error setting jemalloc prof_active: {e:?}"); + if std::env::var("_RJEM_MALLOC_CONF").is_ok() { + if let Err(e) = set_prof_active(t) { + tracing::error!("Error setting jemalloc prof_active: {e:?}"); + } } }, _ => (), @@ -223,7 +226,7 @@ fn set_prof_active(new_value: bool) -> Result<(), MallctlError> { tracing::info!("Setting jemalloc prof_active to {}", new_value); let result = unsafe { - + tikv_jemalloc_sys::mallctl( option_name.as_ptr(), // const char *name std::ptr::null_mut(), // void *oldp