Skip to content

Enable query profiler under sanitizers - #100242

Merged
nickitat merged 24 commits into
masterfrom
enable_query_profiler_under_sanitizers
May 28, 2026
Merged

nickitat merged 24 commits into
masterfrom
enable_query_profiler_under_sanitizers

Conversation

@nickitat

@nickitat nickitat commented Mar 20, 2026 •

Copy link
Copy Markdown
Member

Linked issues

Changelog category (leave one):

  • Performance Improvement

Changelog entry (a user-readable short description of the changes that goes into CHANGELOG.md):

To run tests


Note

Medium Risk
Touches signal-handler stack unwinding and trace pipe shutdown coordination; mistakes here can cause hangs/crashes that are hard to debug, but changes are gated to sanitizer/TSan-specific paths and add safety checks.

Overview
Enables the query profiler in sanitizer builds, switching TSan to frame-pointer-based unwinding (abseil) and adjusting QueryProfiler/StackTrace behavior to avoid ucontext_t/libunwind races while keeping crash-signal unwinding on libunwind.

Build and runtime support is updated to require frame pointers (-fno-omit-frame-pointer), propagate that into bundled compiler-rt, and link absl::stacktrace. Server startup logic is adjusted so profiler/trace collection no longer depends on PHDR cache under TSan.

Hardens trace collection shutdown by adding TraceSender in-flight/shutdown atomics and making TraceCollector drain senders and close the pipe safely; also tweaks TSan sleep behavior, makes several MemoryTracker sampling knobs atomic, and updates tests/config (disable in-flush symbolization under sanitizer builds, retag/adjust profiler tests and expectations).

Reviewed by Cursor Bugbot for commit ad3b8ca. Bugbot is set up for automated code reviews on this repo. Configure here.

Version info

  • Merged into: 26.6.1.219

@clickhouse-gh

clickhouse-gh Bot commented Mar 20, 2026 •

Copy link
Copy Markdown
Contributor

Workflow [PR], commit [fa1098d]

Summary: ✅


AI Review

Summary

This PR enables QueryProfiler in sanitizer builds, with TSan using frame-pointer unwinding through absl, and reworks TraceCollector shutdown plus sanitizer test coverage. The main flow looks coherent, but one unresolved MemoryTracker race can still make the allocation path divide by zero, and the PR metadata/changelog text is not publishable as written.

PR Metadata
  • The selected Performance Improvement category does not match the actual user-facing change: this enables profiler support in sanitizer/test builds rather than improving production query performance. Suggested category: Improvement or Build/Testing/Packaging Improvement.
  • The changelog entry is required for the selected category and To run tests is not a valid user-readable entry. Suggested replacement: Enabled the query profiler in sanitizer builds, using TSan-compatible frame-pointer stack unwinding and safer trace pipe shutdown.
Findings

⚠️ Majors

  • [src/Common/MemoryTracker.cpp:333] allocImpl still assumes profiler_step is non-zero after it only checked a separately loaded profiler_limit. A concurrent setProfilerStep with value 0 stores profiler_step = 0 before setOrRaiseProfilerLimit clears profiler_limit, so an allocator can observe old non-zero current_profiler_limit, new zero step, and execute (will_be + step - 1) / step. Guard step == 0 before this expression, or update/read profiler_step and profiler_limit as one coherent state.

💡 Nits

  • [ci/jobs/scripts/check_style/check_cpp.sh:243] The new comment filter still skips //, ///, and continuation * lines, but not the first line of a block comment starting with /*. A close( mention in that form can still trigger the false positive this change is trying to prevent. Include /\* in the excluded prefixes.
Tests
  • ⚠️ Please add focused coverage for disabling memory_profiler_step while allocation profiling state is active, or otherwise prove the profiler_step == 0 interleaving cannot happen once the code is fixed.
Final Verdict

Status: ⚠️ Request changes

Minimum required actions: fix the MemoryTracker zero-step race and replace the PR changelog metadata with a category and entry that describe the actual change. The check_cpp.sh filter issue is small but still worth fixing while this PR is open.

@clickhouse-gh clickhouse-gh Bot added the pr-not-for-changelog This PR should not be mentioned in the changelog label Mar 20, 2026
@nickitat
nickitat force-pushed the enable_query_profiler_under_sanitizers branch 2 times, most recently from efbb3ca to 608696b Compare March 25, 2026 23:02
Comment thread src/Interpreters/TraceCollector.cpp Resolved
@nickitat
nickitat force-pushed the enable_query_profiler_under_sanitizers branch from f887045 to 6ede5c4 Compare March 26, 2026 15:43
Comment thread src/Interpreters/TraceCollector.cpp Resolved
Comment thread programs/server/Server.cpp Resolved
Comment thread src/Common/QueryProfiler.cpp Resolved
@alexey-milovidov

Copy link
Copy Markdown
Member

The Stress test (arm_msan) failure is fixed by #101239, which should be merged first. After it is merged, please update the branch to include the fix.

@alexey-milovidov

Copy link
Copy Markdown
Member

The flaky check failure is fixed in #102148, let's update the branch.

Comment thread programs/server/Server.cpp Resolved
nickitat and others added 10 commits May 4, 2026 16:02
The query profiler was disabled under sanitizers because libunwind's
async stack unwinding interferes with sanitizer internals — sanitizers
modify %rbp during their own frame-walking, and a profiling signal
arriving mid-unwind would crash in libunwind.

Replace libunwind with abseil's frame-pointer-based stack unwinding
under sanitizers. Abseil's `GetStackTrace` / `GetStackTraceWithContext`
use `NO_SANITIZE_ADDRESS/MEMORY/THREAD` attributes and are safe.

Key changes:

  StackTrace.cpp: use `absl::GetStackTrace[WithContext]` under SANITIZER
  instead of `unw_backtrace` / libunwind.

  QueryProfiler.cpp: remove the SANITIZER throw guards that disabled the
  profiler. Skip `hasPHDRCache` check under sanitizers (not needed for
  frame-pointer unwinding). Skip `sigsetjmp` protection under sanitizers
  (TSan wraps signal delivery, making `siglongjmp` across its frames
  unsafe).

  Server.cpp: bypass `hasPHDRCache` for `TraceCollector` init under
  sanitizers. Under TSan the PHDR cache is not created (TSan intercepts
  `dl_iterate_phdr`), but frame-pointer unwinding does not need it.

  Defines.h, SettingsQuirks.cpp: enable profiler default sample rate and
  remove the quirk that force-zeroed profiler settings under sanitizers.

  build_clang_builtin.cmake: build compiler-rt with
  `-fno-omit-frame-pointer` and `-DCOMPILER_RT_HAS_FOMIT_FRAME_POINTER_FLAG=OFF`
  so that sanitizer runtime frames (e.g. TSan interceptors) have frame
  pointers, allowing abseil's walker to traverse them.

  sleep.cpp: under TSan, use `nanosleep` instead of `clock_nanosleep`.
  TSan intercepts `nanosleep` (setting `in_blocking_func`), which causes
  profiling signals to be delivered immediately rather than deferred.
  Without this, TSan defers the signal and the saved `ucontext_t` may
  point to stale stack memory.

  Tests: remove no-tsan/no-asan/no-ubsan/no-msan tags from query
  profiler tests. Add a real-time profiler test using `numbers_mt` which
  reliably produces meaningful traces under TSan.

Co-Authored-By: Claude Opus 4.6 (1M context) <[email protected]>
The abseil StackTrace() path (no ucontext) only produces correct traces
when TSan defers the signal — abseil walks from the current stack which
happens to include the interrupted code at TSan's interceptor boundary.

Under ASan/MSan/UBSan, signals are delivered synchronously, so abseil
only captures signal handler frames, missing the interrupted code
(e.g. FunctionSleep). Use libunwind with sigsetjmp protection for
these sanitizers, same as non-sanitizer builds.

The original libunwind crash issue (sanitizer modifying %rbp mid-unwind)
is specific to TSan which does concurrent frame-pointer walking.
ASan/MSan/UBSan do not have this problem.

Co-Authored-By: Claude Opus 4.6 (1M context) <[email protected]>
@nickitat
nickitat force-pushed the enable_query_profiler_under_sanitizers branch from b3e6348 to 80f3dc2 Compare May 4, 2026 16:13
@clickhouse-gh clickhouse-gh Bot added the submodule changed At least one submodule changed in this PR. label May 4, 2026
nickitat and others added 2 commits May 5, 2026 12:01
TSan reported a data race on `optional<TraceCollector>::has_value`:
the TraceCollector ctor (called inside `optional::emplace`) starts a
worker via `ThreadFromGlobalPool`, whose lambda runs
`ThreadStatus::initGlobalProfiler` before the actual function. That
calls `Context::hasTraceCollector()`, which reads the optional's
engaged byte while `emplace` is still in the middle of setting it on
main.

Switch the thread to `ThreadFromGlobalPoolWithoutTraceCollector`,
which is provided by `ThreadPool.h` for exactly this case (it skips
`initGlobalProfiler`). Profiling the trace collector worker itself is
pointless anyway.

Co-Authored-By: Claude Opus 4.7 (1M context) <[email protected]>
TSan flagged a data race on the trace pipe fd: the destructor called
`tryClosePipe()` (which closes both ends) before joining the worker
thread, so main's `close()` on the read fd raced with the worker's
`read()` on the same fd.

Move `tryClosePipe()` to after `thread.join()`. The stop byte written
earlier in the destructor makes the worker exit normally; only after
the worker has exited do we close the fds.

Co-Authored-By: Claude Opus 4.7 (1M context) <[email protected]>
Comment thread src/Common/QueryProfiler.cpp Resolved
The check that requires checking the return value of `close` greps
for ` close(...fd` / ` ::close(` and currently flags any line that
mentions those literally — including comments that use them as
prose, e.g. "without racing on close() and read() on the same fd".

Add a comment filter so lines whose match site is inside a `//`,
`///`, or `*` comment are excluded.

See https://s3.amazonaws.com/clickhouse-test-reports/PRs/100242/21da94994d3511d3511c781b558a8e60c218a049/style_check/job.log
@nickitat nickitat added the pr-performance Pull request with some performance improvements label May 27, 2026
@clickhouse-gh

clickhouse-gh Bot commented May 27, 2026

Copy link
Copy Markdown
Contributor

LLVM Coverage Report

Metric Baseline Current Δ
Lines 84.10% 84.20% +0.10%
Functions 91.40% 91.40% +0.00%
Branches 76.50% 76.60% +0.10%

Changed lines: 94.74% (90/95) | lost baseline coverage: 4 line(s) · Uncovered code

Full report · Diff report

@nickitat

Copy link
Copy Markdown
Member Author

Perf tests (ones with red queries):

Analysis:

● Final output — gaps filled

  PR #100242 @ fa1098d on AMD, 5 runs/query, all 4 needed datasets loaded (hits_10m, hits_100m, hits_v1→test.hits, tpcds, ~30 GB):

  ========================================================================================================================
  Local double-check vs. CI report
  ========================================================================================================================
  TEST                              Q#  CI@        CI old   CI new     CI Δ |    L old    L new      L Δ   pval  RESULT
  ------------------------------------------------------------------------------------------------------------------------
  agg_functions_min_max_any         48  amd        33.5ms   35.2ms    +5.0% |   29.0ms   29.3ms    +1.4%  0.016  NOT REPRODUCED (slower in CI)
  aggregation_in_order_2             1  arm-only   28.3ms   26.9ms    -5.1% |   21.4ms   21.7ms    +1.4%  0.118  NOT REPRODUCED on amd
  and_function                       0  arm-only   40.5ms   64.5ms   +59.0% |   59.9ms   60.0ms    +0.2%  0.495  NOT REPRODUCED on amd
  arithmetic_operations_in_aggr…     2  arm-only   29.9ms   27.8ms    -7.2% |   13.6ms   13.6ms    -0.1%  0.956  NOT REPRODUCED on amd
  array_index_low_cardinality…       9  amd       923.9ms  992.3ms    +7.4% |  632.0ms  620.7ms    -1.8%  0.382  NOT REPRODUCED (slower in CI)
  avg                                0  arm-only  552.7ms  516.3ms    -6.6% |  217.4ms  218.8ms    +0.7%  0.583  NOT REPRODUCED on amd
  clickbench                        22  amd       805.6ms  761.5ms    -5.5% |  497.3ms  498.7ms    +0.3%  0.866  NOT REPRODUCED (faster in CI)
  coalesce                           0  arm-only   1.981s   1.798s    -9.3% |  739.3ms  740.7ms    +0.2%  0.968  NOT REPRODUCED on amd
  complex_array_creation             0  amd       110.1ms  104.0ms    -5.7% |  102.5ms  100.4ms    -2.1%  0.946  NOT REPRODUCED (faster in CI)
  complex_array_creation             1  amd       133.5ms  125.0ms    -6.4% |  107.8ms  107.9ms    +0.1%  0.780  NOT REPRODUCED (faster in CI)
  count_from_formats                 1  arm-only   16.9ms   14.9ms   -11.4% |   17.2ms   17.5ms    +2.0%  0.008  NOT REPRODUCED on amd
  format_readable                    0  arm-only  390.7ms  369.7ms    -5.4% |  275.5ms  290.2ms    +5.4%  0.023  NOT REPRODUCED on amd
  fuse_sumcount                      0  arm-only  555.3ms  516.8ms    -7.0% |  215.0ms  217.0ms    +0.9%  0.138  NOT REPRODUCED on amd
  fuse_sumcount                      1  arm-only  546.1ms  515.3ms    -5.7% |  215.1ms  216.7ms    +0.8%  0.183  NOT REPRODUCED on amd
  fuse_sumcount                      2  arm-only  570.5ms  521.4ms    -8.7% |  216.4ms  215.6ms    -0.4%  0.935  NOT REPRODUCED on amd
  fuse_sumcount                      4  arm-only  753.1ms  705.7ms    -6.3% |  264.0ms  265.0ms    +0.4%  0.790  NOT REPRODUCED on amd
  h3_functions                       6  arm-only   24.4ms   25.9ms    +6.2% |   20.9ms   20.9ms    +0.2%  0.946  NOT REPRODUCED on amd
  if_array_num                       2  amd       128.3ms  121.0ms    -5.8% |  118.2ms  119.0ms    +0.7%  0.221  NOT REPRODUCED (faster in CI)
  join_lazy_indexing                 4  amd       379.2ms  351.2ms    -7.4% |  275.7ms  272.3ms    -1.2%  0.224  NOT REPRODUCED (faster in CI)
  join_main_loop                     0  arm-only   93.3ms   88.8ms    -5.0% |   34.9ms   35.2ms    +0.9%  0.130  NOT REPRODUCED on amd
  join_main_loop                     2  arm-only   93.6ms   88.8ms    -5.2% |   35.2ms   35.1ms    -0.4%  0.089  NOT REPRODUCED on amd
  join_reserve                       0  arm-only  300.2ms  284.0ms    -5.5% |  116.8ms  116.5ms    -0.3%  0.504  NOT REPRODUCED on amd
  join_runtime_filter                2  amd       117.1ms  106.6ms    -9.0% |   81.4ms   81.8ms    +0.4%  0.634  NOT REPRODUCED (faster in CI)
  like_perfect_affix_rewrite         1  amd        85.6ms   81.0ms    -5.5% |   72.1ms   71.3ms    -1.0%  0.557  NOT REPRODUCED (faster in CI)
  limit_by_partitions                3  amd       250.3ms  278.3ms   +11.1% |  240.5ms  244.0ms    +1.5%  0.916  NOT REPRODUCED (slower in CI)
  logical_functions_large            4  arm-only  200.2ms  189.2ms    -5.5% |   92.0ms   91.1ms    -1.0%  0.146  NOT REPRODUCED on amd
  logical_functions_medium           3  arm-only   24.4ms   22.2ms    -9.2% |   13.0ms   13.2ms    +1.1%  0.016  NOT REPRODUCED on amd
  logical_functions_small            0  arm-only  244.1ms  227.7ms    -6.8% |  158.7ms  159.7ms    +0.6%  0.723  NOT REPRODUCED on amd
  math                               9  amd       420.3ms  442.2ms    +5.2% |  321.3ms  321.6ms    +0.1%  0.511  NOT REPRODUCED (slower in CI)
  min_max_index_with_cast            0  arm-only   1.311s   1.634s   +24.6% |  665.5ms  673.0ms    +1.1%  0.066  NOT REPRODUCED on amd
  modulo                             0  arm-only  195.8ms  184.6ms    -5.8% |  112.2ms  114.1ms    +1.7%  0.107  NOT REPRODUCED on amd
  or_null_default                    0  arm-only   59.1ms   54.2ms    -8.4% |   24.2ms   24.4ms    +0.9%  0.158  NOT REPRODUCED on amd
  parallel_index                     2  amd        10.7ms   11.8ms   +10.4% |    9.1ms    9.2ms    +1.4%  0.377  NOT REPRODUCED (slower in CI)
  rand                               2  arm-only    6.9ms    6.3ms    -8.3% |    3.6ms    3.6ms    +0.4%  0.223  NOT REPRODUCED on amd
  round_methods                     14  amd        58.7ms   54.3ms    -7.6% |   42.6ms   42.7ms    +0.4%  0.896  NOT REPRODUCED (faster in CI)
  string_bytes_functions             0  amd       102.4ms  130.6ms   +27.4% |  131.0ms  131.6ms    +0.5%  0.950  NOT REPRODUCED (slower in CI)
  sum                                0  arm-only   58.6ms   53.8ms    -8.1% |   24.0ms   24.1ms    +0.4%  0.568  NOT REPRODUCED on amd
  tpcds                             80  amd        59.1ms   65.8ms   +11.4% |   51.4ms   51.7ms    +0.6%  0.108  NOT REPRODUCED (slower in CI)
  unary_arithmetic_functions        88  arm-only   95.4ms   89.9ms    -5.8% |   81.8ms   79.6ms    -2.6%  0.180  NOT REPRODUCED on amd
  unary_logical_functions            0  arm-only  616.2ms  579.8ms    -5.9% |  283.4ms  289.8ms    +2.3%  0.076  NOT REPRODUCED on amd
  unary_logical_functions            1  arm-only  747.2ms  708.4ms    -5.2% |  381.8ms  373.7ms    -2.1%  0.229  NOT REPRODUCED on amd
  unary_logical_functions            2  arm-only  703.8ms  668.0ms    -5.1% |  389.4ms  387.4ms    -0.5%  0.506  NOT REPRODUCED on amd
  unary_logical_functions            5  arm-only  758.1ms  718.0ms    -5.3% |  375.0ms  374.4ms    -0.2%  0.480  NOT REPRODUCED on amd
  unary_logical_functions            6  arm-only  694.3ms  647.9ms    -6.7% |  391.5ms  385.7ms    -1.5%  0.157  NOT REPRODUCED on amd
  unary_logical_functions            8  arm-only  874.5ms  826.4ms    -5.5% |  586.5ms  596.0ms    +1.6%  0.044  NOT REPRODUCED on amd
  uniq_without_key                  19  arm-only   65.1ms   61.9ms    -5.0% |   63.3ms   63.6ms    +0.4%  0.752  NOT REPRODUCED on amd
  url_hits                           5  amd       697.0ms  659.2ms    -5.5% |  489.8ms  492.1ms    +0.5%  0.816  NOT REPRODUCED (faster in CI)

@nickitat
nickitat added this pull request to the merge queue May 28, 2026
Merged via the queue into master with commit 4044b47 May 28, 2026
327 of 328 checks passed
@nickitat
nickitat deleted the enable_query_profiler_under_sanitizers branch May 28, 2026 13:44
@robot-ch-test-poll1 robot-ch-test-poll1 added the pr-synced-to-cloud The PR is synced to the cloud repo label May 28, 2026
@watson-ch

watson-ch Bot commented Jul 10, 2026

Copy link
Copy Markdown

Backport labels have been automatically added based on https://github.com/clickhouse/clickhouse-core-incidents/issues/1929

Labels added:

  • v26.2-must-backport

These labels ensure backport PRs are properly created for each affected release version. The release automation will create backport PRs as needed based on these labels.

@watson-ch

watson-ch Bot commented Jul 10, 2026

Copy link
Copy Markdown

Backport labels have been automatically added based on https://github.com/clickhouse/clickhouse-core-incidents/issues/1929

Labels added:

  • v26.2-must-backport

These labels ensure backport PRs are properly created for each affected release version. The release automation will create backport PRs as needed based on these labels.

@alexey-milovidov

Copy link
Copy Markdown
Member

@nickitat @azat, a bug was found ^

@azat

azat commented Aug 10, 2026

Copy link
Copy Markdown
Member

Probably can be resolved by #112008

pull Bot pushed a commit to Mu-L/ClickHouse that referenced this pull request Sep 5, 2026
Every `MemorySanitizer` report produced in CI since 2026-05-28 is truncated
to a single line:

    ==117==WARNING: MemorySanitizer: use-of-uninitialized-value
    MemorySanitizer: nested bug in the same thread, aborting.

There is no stack trace, no `SUMMARY` and no origin, so the underlying bug
cannot be located. In the CI database, `msan` checks recorded 1009 reports
with a usable stack in 2026-04 and 0 in 2026-07; `asan`, `tsan` and `ubsan`
reports are unaffected and still carry full stacks.

The regression window matches ClickHouse#100242 (merged 2026-05-28), which enabled the
sampling query profiler for sanitizer builds. Printing an MSan report takes
the sanitizer runtime seconds, because it symbolizes every frame through an
`llvm-symbolizer` subprocess, and it holds `ScopedErrorReportLock` for the
whole time. A profiler signal delivered to that thread meanwhile runs
instrumented code in the handler and trips a second MSan check; compiler-rt
treats a same-thread re-entry into the report lock as unrecoverable, writes
`nested bug in the same thread, aborting.` with `CatastrophicErrorWrite` and
calls `internal__exit`, so the report that was already being written to
`MSAN_OPTIONS=log_path` stops after its header line.

Reproduced with the `arm_msan` binary from master `3885f7b7bbf1`, running the
same query against the same server three times and forcing a sanitizer report
with `max_allocation_size_mb=32 allocator_may_return_null=0`:

- profiler on (default `global_profiler_real_time_period_ns`): `nested bug in
  the same thread, aborting.`, 1-line report;
- `<trace_log remove="1"/>` (no profiler at all): full 31-line report;
- `trace_log` on but `global_profiler_*_period_ns = 0` and the per-query
  profiler off: full 31-line report.

So it is the profiler timer signals, not the trace collector.

Turn `QUERY_PROFILER_SUPPORTED` off under MSan, next to the existing
TSan-on-macOS exclusion. The trace collector stays enabled: the memory
profiler, `trace_profile_events` and `SYSTEM INSTRUMENT` all feed it from
ordinary code rather than from a signal handler, and other sanitizers keep the
profiler because their checks fire only on genuinely invalid accesses, which
the handler does not perform.

`00974_query_profiler` and `01569_query_profiler_big_query_id` assert that
samples reach `system.trace_log`, so they get `no-msan` back.

This does not fix the uninitialized read that the `BuzzHouse (amd_msan)` run
below hit - that one is unidentifiable as reported. It makes the next
occurrence diagnosable.

CI report:
https://s3.amazonaws.com/clickhouse-test-reports/json.html?REF=master&sha=3885f7b7bbf1b8791021e1c97ca2e4eea132de04&name_0=MasterCI&name_1=BuzzHouse%20%28amd_msan%29

Related: ClickHouse#100242
Related: ClickHouse#106591

Co-Authored-By: Claude Fable 5 <[email protected]>
UnamedRus pushed a commit to UnamedRus/ClickHouse that referenced this pull request Sep 12, 2026
Stateless jobs on amd_llvm_coverage lose whole runs to
`Timeout exceeded (180 s) while flushing system log
'DB::SystemLogQueue<DB::TraceLogElement>'`. Six different tests died on this
signature inside a single coverage job run on 2026-09-05, so it is a job-wide
trace_log drain stall rather than a property of any one test.

trace_log.symbolize defaults to true, and in-flush symbolization
(SymbolIndex::findSymbol + tryDemangle + AddressToLineCache::get, per frame in
TraceLogElement::appendToBlock) is what the single flusher thread spends the
hardcoded 180 s of SystemLogQueue::waitFlush on. ClickHouse#100242 already fixed that by
shipping tests/config/config.d/trace_log_no_symbolize.xml, but its gate probes
CXX_FLAGS LIKE '%-DSANITIZER%' and the else arm removes the file again. A
coverage build is configured -DSANITIZE= ... -DWITH_COVERAGE=ON, so it carries
no -DSANITIZER: coverage was the one stateless flavour left symbolizing at full
cost.

Probe the dedicated WITH_COVERAGE row of system.build_options instead. Plain
-DWITH_COVERAGE never reaches CXX_FLAGS (cmake/sanitize.cmake adds it only
under WITH_COVERAGE_DEPTH; the coverage compile flags are applied
per-directory), which is why build_option_flag cannot be reused and why
tests/clickhouse-test keys off the same row. The new helper keeps the
fail-closed contract of its neighbour: a renamed or missing row aborts the
install rather than reading as "not a coverage build", and every probe is
resolved before any file is touched, so a failing probe cannot leave a
half-adjusted config directory.

Measured on a debug build, a fresh server per arm (AddressToLineCache is a
process-wide static, so a warmed process understates the cost) and an identical
workload, timing the first SYSTEM FLUSH LOGS trace_log: 0.35 s with
symbolize=false, 0 of 13226 rows symbolized, versus 3.12 s with symbolize=true,
13388 of 13388 symbolized. That is 8.9x, i.e. symbolization is ~89% of flush
cost; ClickHouse#100242 measured up to 2.5 minutes for ~180k entries on an instrumented
build. This removes the dominant per-row cost without making the 180 s budget
unconditional, and deliberately does not touch that constant: raising it is the
shape ClickHouse#105484 was closed for.

The tests that assert a non-empty symbols or lines column
(03150_trace_log_add_build_id, 03150_trace_log_source_lines) already carry
no-llvm-coverage, and 00974_query_profiler resolves symbols on read, so nothing
regresses; the comments naming the affected flavours are updated to match.

One consumer did not resolve on read: the MemoryAllocatedWithoutCheck advisory
in tests/clickhouse-test suggests a diagnostic query grouped by the symbols
column. Those rows reach trace_log through MemoryTracker -> TraceSender ->
TraceCollector, which stamps every row with the config's symbolize value, so
the suggested query has collapsed every stack into a single empty bucket on all
sanitizer builds since 2026-05-08. It now resolves symbols on read with
addressToSymbol, which repairs the guidance for both flavours.

Co-Authored-By: Claude Opus 5 <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

pr-backports-created Backport PRs are successfully created, it won't be processed by CI script anymore pr-must-backport-synced The `*-must-backport` labels are synced into the cloud Sync PR pr-performance Pull request with some performance improvements pr-synced-to-cloud The PR is synced to the cloud repo submodule changed At least one submodule changed in this PR. v26.2-must-backport

Projects

None yet

Development

Successfully merging this pull request may close these issues.

6 participants