only enable profiling if env variable is present

This commit is contained in:
Ruben Fiszel
2024-05-20 18:57:26 +02:00
parent f451748faa
commit da091cbad7
2 changed files with 6 additions and 5 deletions

View File

@@ -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"]

View File

@@ -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