From 90e472054c46be9d42ea36aea5683d87b1f11420 Mon Sep 17 00:00:00 2001 From: Dennis Felsing Date: Wed, 15 Jan 2025 16:27:50 +0000 Subject: [PATCH] DNM: Try out jemalloc leak profiling Motiviation is to find memory leaks in CI, want to evaluate if this works at all first See https://github.com/jemalloc/jemalloc/wiki/Use-Case%3A-Leak-Checking --- ci/plugins/mzcompose/hooks/command | 2 ++ ci/plugins/mzcompose/hooks/pre-exit | 4 ++++ misc/python/materialize/cli/ci_annotate_errors.py | 1 + src/prof/src/jemalloc.rs | 3 ++- 4 files changed, 9 insertions(+), 1 deletion(-) diff --git a/ci/plugins/mzcompose/hooks/command b/ci/plugins/mzcompose/hooks/command index 7086c52327b92..7fbf19210e060 100644 --- a/ci/plugins/mzcompose/hooks/command +++ b/ci/plugins/mzcompose/hooks/command @@ -45,6 +45,8 @@ if [ -n "${CI_COVERAGE_ENABLED:-}" ]; then find . -name '*.profraw' -delete # Remove remaining profraw files from coverage runs fi +find . -name 'jeprof*.heap' -delete + ci_collapsed_heading ":docker: Purging all existing docker containers and volumes, regardless of origin" docker ps --all --quiet | xargs --no-run-if-empty docker rm --force --volumes rm -f services.log diff --git a/ci/plugins/mzcompose/hooks/pre-exit b/ci/plugins/mzcompose/hooks/pre-exit index 5153e85197d18..90a2173821169 100755 --- a/ci/plugins/mzcompose/hooks/pre-exit +++ b/ci/plugins/mzcompose/hooks/pre-exit @@ -132,6 +132,10 @@ if [ -n "${CI_COVERAGE_ENABLED:-}" ] && [ -z "${BUILDKITE_MZCOMPOSE_PLUGIN_SKIP_ fi fi +find . -name 'jeprof*.heap' | while read -r i; do + buildkite-agent artifact upload "$i" +done + if [ "$CI_ANNOTATE_ERRORS_RESULT" -ne 0 ]; then echo "+++ ci-annotate-errors failed, which indicates that an unknown error was found" exit "$CI_ANNOTATE_ERRORS_RESULT" diff --git a/misc/python/materialize/cli/ci_annotate_errors.py b/misc/python/materialize/cli/ci_annotate_errors.py index 53b7fc82d272b..0c1c404e16401 100644 --- a/misc/python/materialize/cli/ci_annotate_errors.py +++ b/misc/python/materialize/cli/ci_annotate_errors.py @@ -101,6 +101,7 @@ | (FAIL|TIMEOUT)\s+\[\s*\d+\.\d+s\] # parallel-workload | worker_.*\ still\ running: [\s\S]* Threads\ have\ not\ stopped\ within\ 5\ minutes,\ exiting\ hard + | Leak\ approximation\ summary: ) .* $ """, diff --git a/src/prof/src/jemalloc.rs b/src/prof/src/jemalloc.rs index c02c035325113..4b33abe7eb6ee 100644 --- a/src/prof/src/jemalloc.rs +++ b/src/prof/src/jemalloc.rs @@ -26,7 +26,8 @@ use tikv_jemalloc_ctl::{epoch, stats}; #[allow(non_upper_case_globals)] #[export_name = "malloc_conf"] -pub static malloc_conf: &[u8] = b"prof:true,prof_active:true,lg_prof_sample:19\0"; +pub static malloc_conf: &[u8] = + b"prof_leak:true,prof_final:true,prof:true,prof_active:true,lg_prof_sample:19\0"; #[derive(Copy, Clone, Debug)] pub struct JemallocProfMetadata {