From 2ae753a14d646fc005353f301bbc76da08fe2423 Mon Sep 17 00:00:00 2001 From: Mikhail Filimonov Date: Mon, 30 Nov 2026 21:26:15 +0100 Subject: [PATCH 1/2] Set malloc_context_size=8 for the MSan server in stateless tests With `poison_in_dtor=1` every destructor stores a call stack in the MSan stack depot. At the default depth of 20 frames almost every stack is unique, the depot (2^20 buckets) fills up, and `StackDepotBase::Put` takes 58-76% of server CPU, growing during the run. MSan stateless shards then hit the 4 hour job timeout. Local measurement on the CI MSan build, same 200 tests before and after 1200 other tests: server CPU 79 s -> 172 s at depth 20, 65 s -> 69 s at depth 8. Use-after-destroy detection stays on; only the "allocated / destroyed here" stack in reports gets shorter. https://s3.amazonaws.com/altinity-build-artifacts/REFs/antalya-26.8/d86c7394783bd27532903f18c7519525a0061307/45729031774/ci_run_report.html Co-Authored-By: Claude Fable 5.2 Signed-off-by: Mikhail Filimonov --- ci/jobs/scripts/clickhouse_proc.py | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/ci/jobs/scripts/clickhouse_proc.py b/ci/jobs/scripts/clickhouse_proc.py index 3b77a71b216d4..b1a90c0b112bc 100644 --- a/ci/jobs/scripts/clickhouse_proc.py +++ b/ci/jobs/scripts/clickhouse_proc.py @@ -577,6 +577,20 @@ def start(self, replica_num=0): ) tsan_options = env["TSAN_OPTIONS"] print(f"TSAN_OPTIONS = {tsan_options}") + # With `poison_in_dtor=1` every destructor stores a stack in the MSan stack + # depot. With the default depth of 20 almost every stack is unique, the + # fixed-size depot fills up, and the server slows down during the run. + env["MSAN_OPTIONS"] = " ".join( + filter( + lambda x: x is not None, + [ + env.get("MSAN_OPTIONS", None), + "malloc_context_size=8", + ], + ) + ) + msan_options = env["MSAN_OPTIONS"] + print(f"MSAN_OPTIONS = {msan_options}") proc = subprocess.Popen( command, stderr=subprocess.STDOUT, From 93c5121e248ea5f1ba4f642dc1a5dd9b2462671f Mon Sep 17 00:00:00 2001 From: Mikhail Filimonov Date: Tue, 1 Dec 2026 11:08:55 +0100 Subject: [PATCH 2/2] Note where the server gets its sanitizer options in CI Co-Authored-By: Claude Fable 5.2 Signed-off-by: Mikhail Filimonov --- tests/clickhouse-test | 2 ++ 1 file changed, 2 insertions(+) diff --git a/tests/clickhouse-test b/tests/clickhouse-test index 8c1c6eee366ae..6f896ee7f96b9 100755 --- a/tests/clickhouse-test +++ b/tests/clickhouse-test @@ -3876,6 +3876,8 @@ class TestCase: log_opt = " --client_logs_file=" + self.fatal_sanitizer_prefix + " " client_options += log_opt + # These apply to processes started by the tests (clients, `clickhouse-local`). + # In CI the server gets its sanitizer options in `ci/jobs/scripts/clickhouse_proc.py`. for env_name in [ "TSAN_OPTIONS", "ASAN_OPTIONS",