Skip to content

Do not instrument the stack trace symbolizer in the LLVM coverage build - #125305

Merged
fm4v merged 4 commits into
ClickHouse:masterfrom
groeneai:no-coverage-instrumentation-for-symbolizer
Oct 14, 2026
Merged

fm4v merged 4 commits into
ClickHouse:masterfrom
groeneai:no-coverage-instrumentation-for-symbolizer

Conversation

@groeneai

@groeneai groeneai commented Oct 12, 2026 •

Copy link
Copy Markdown
Collaborator

Changelog category (leave one):

  • CI Fix or Improvement (changelog entry is not required)

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

The stack trace symbolizer (Common/Dwarf.cpp, Elf.cpp, SymbolIndex.cpp, ...) is no longer instrumented in the LLVM coverage build, so concurrent stack trace symbolization there takes milliseconds instead of tens of seconds.

Description

04907_url_function_no_retry_after_cancel and 05029_url_function_schema_inference_hard_timeout_during_backoff fail on the amd_llvm_coverage jobs: master 4ddbbbd (ParallelReplicas, AsyncInsert) and ae0dac4.

The query is cancelled within 100 ms; the remaining ~20 s go to symbolizing the stack traces of its exception, with every CPU sample in Dwarf::findDebugInfoOffset, a linear scan of .debug_aranges. In the coverage build that loop increments profile counters on every iteration, so when several threads symbolize at once the counter cache lines bounce between cores and one trace takes ~10 s instead of tens of ms.

Common/{Elf,Dwarf,MachO,SymbolIndex,ThreadFuzzer}.cpp are meant to be built without coverage (#44569), but b88d0a2 moved that block under CMAKE_BUILD_TYPE=Debug, and the CI coverage build is RelWithDebInfo. This PR keeps -O2 Debug-only and appends -fno-profile-instr-generate -fno-coverage-mapping to these five files in every other WITH_COVERAGE build; all other builds get identical compile commands. The five files drop out of the coverage reports and of the per-test coverage used for test selection, as in Debug coverage builds.

Validation on a local build with the CI coverage flags: of 30 different failing queries started at once, the slowest takes 149 s before and 97 ms after. Under 16 concurrent addressToLine loops, 04907 and 05029 fail 10/10 before with the CI messages and pass 10/10 after. PR CI does not run the coverage jobs. #121512 and #121874 worked around the same cost in other tests.

🤖 Generated with Claude Code


Workflow [PR]
Sync PR [sync-upstream/pr/125305]

Version info

  • Merged into: 26.10.1.2389-master (included in 26.10 and later)

`Common/{Elf,Dwarf,MachO,SymbolIndex,ThreadFuzzer}.cpp` are compiled without
coverage instrumentation because it slows down stack trace printing too much
(ClickHouse#44569, 70e3dd8). Since b88d0a2 ("Don't apply O2 on release
builds") the whole block is gated on `CMAKE_BUILD_TYPE=Debug`, so the exclusion
no longer applies to the CI `amd_llvm_coverage` build, which is
`CMAKE_BUILD_TYPE=None` (RelWithDebInfo) with `WITH_COVERAGE=ON`.

There `Dwarf::findDebugInfoOffset`, a linear scan of `.debug_aranges` (1.4 M
entries, ~20 M entries read per 32-frame stack trace), increments
process-global profile counters on every iteration. When several server
threads symbolize at once, the counter cache lines bounce between cores and a
single stack trace costs ~10 s instead of tens of ms. On master 4ddbbbd,
04907 failed this way in two coverage jobs and 05029 in one of them: the query
was cancelled within 100 ms, then spent ~20 s symbolizing the two stack traces
of its exception (every trace_log sample of the query is in
`findDebugInfoOffset`).

Keep `-O2` Debug-only, and for every other `WITH_COVERAGE` build append
`-fno-profile-instr-generate -fno-coverage-mapping` to these files through
`COMPILE_OPTIONS`, so that `ThreadFuzzer.cpp` keeps its
`-fomit-frame-pointer -momit-leaf-frame-pointer` `COMPILE_FLAGS`. Builds
without coverage, and Debug builds, get identical compile commands.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
@groeneai groeneai added can be tested Allows running workflows for external contributors groeneai-origin-ci-master PR origin: master/nightly CI monitoring finding labels Oct 12, 2026
@groeneai

Copy link
Copy Markdown
Collaborator Author
Internal second-model review: adjudication log (click to expand)

Pre-publication review by an independent model (engine: codex; 0 findings) plus my own review (2 nits).

# Sev Finding Verdict Evidence / action
1 💡 The PR description did not say that the five files also drop out of the per-test coverage used for test selection (PER_TEST_COVERAGE is also WITH_COVERAGE=ON, non-Debug) AGREE Description updated
2 💡 ci/jobs/scripts/coverage_ignore_paths.sh does not list the newly uninstrumented files; the only effect is the diff-coverage outcome label for a PR that changes only them AGREE Not changed, to keep this a one-hunk CMake fix

Severity: ❌ blocker / ⚠️ major / 💡 nit.

Session id: cron:clickhouse-review-slot-8:20261012-025700

@groeneai

Copy link
Copy Markdown
Collaborator Author
Pre-PR validation gate (click to expand)
# Question Answer
a Deterministic repro? Yes. Local coverage build with the CI flags: 30 different failing queries started at once take 131-149 s each (3/3 runs, base). With 16 concurrent addressToLine loops, 04907 and 05029 fail 10/10 each with the CI messages (the cancellation waited 98824-198342 ms, the time limit waited 122-186 seconds).
b Root cause explained? Yes. The symbolizer exclusion in src/CMakeLists.txt is Debug-only since b88d0a2, the CI coverage build is RelWithDebInfo, so Dwarf::findDebugInfoOffset (linear .debug_aranges scan) increments profile counters per entry; concurrent symbolizers contend on those cache lines and one trace takes seconds to minutes, past the tests' 15 s bounds.
c Fix matches root cause? Yes. The five symbolizer files are built with -fno-profile-instr-generate -fno-coverage-mapping in every WITH_COVERAGE build; no test bound is widened, no test is tagged.
d Test intent preserved / new tests added? Tests unchanged, so they still catch a backoff that is not interrupted. No new test: a CMake change for a CI-only build flavour, validated on that flavour locally; the two tests are the oracles.
e Both directions demonstrated? Yes. Base 10/10 + 10/10 FAIL, fix 10/10 + 10/10 OK under the same load; 30 concurrent failing queries 149 s -> 97 ms; fix binary 50/50 + 50/50 OK without load.
f Fix is general across code paths? Yes. All five files of the existing list, every non-Debug WITH_COVERAGE build (incl. per-test coverage); addressToLine* go through the same Dwarf::findAddress. Object check: 0 __llvm_profile_counter_bias references in the five objects (base: 24-103).
g Fix generalizes across inputs (params/datatypes/wrappers)? N/A for data types (build flags). Build matrix: Debug and non-coverage builds have 0 changed compile commands (18156 / 17498 entries compared); coverage build changes in the five files only.
h Backward compatible? (maintainer-approved exception only) Yes. No setting, format or runtime behaviour change; coverage reports no longer include these five files, as in Debug coverage builds.
i Invariants and contracts preserved? Yes. ThreadFuzzer.cpp keeps -fomit-frame-pointer -momit-leaf-frame-pointer (flags are appended, not assigned); the -fno-* pair comes after the directory-level coverage flags; the build links and runs.

Session id: cron:clickhouse-impl-slot-5:20261012-000200

@clickhouse-gh

clickhouse-gh Bot commented Oct 12, 2026 •

Copy link
Copy Markdown
Contributor

Workflow [PR], commit [b4de31c]

Summary: ✅


AI Review

Summary

PR #125305, reviewed at b4de31c5d981f341b075cb5627ef4bd7b123d21e, extends the existing symbolizer instrumentation exclusions to non-Debug WITH_COVERAGE builds, preventing excessive delays during concurrent exception stack trace symbolization. The author's reported before/after validation exercises the existing cancellation and timeout regression tests without relaxing their assertions. The loss of per-test coverage is a documented tradeoff explicitly accepted in the prior review thread. No new actionable findings.

Final Verdict

✅ Approve

@clickhouse-gh clickhouse-gh Bot added the pr-ci label Oct 12, 2026
@groeneai
groeneai requested a review from Algunenano October 12, 2026 03:32
@clickhouse-gh clickhouse-gh Bot added the comp-build-system Build system (CMake, compilation, platform builds). label Oct 12, 2026
@clickhouse-gh

clickhouse-gh Bot commented Oct 12, 2026 •

Copy link
Copy Markdown
Contributor

Build profile diff (arm_release)

Commit b4de31c5d981f341b075cb5627ef4bd7b123d21e was not compared: the CI logs cluster did not answer (every POST attempt failed with an exception; stopped retrying after the 1250 s read budget).

See the job log for details.

@fm4v

fm4v commented Oct 12, 2026

Copy link
Copy Markdown
Member

@groeneai pull master

…entation-for-symbolizer

Co-Authored-By: Claude Opus 5.5 <[email protected]>
@groeneai

Copy link
Copy Markdown
Collaborator Author

Merged master (80e3849) into the branch, new head 01cc0ed. No conflicts, and the PR diff is unchanged (src/CMakeLists.txt only). A coverage-build configure of the merged tree still gives the 5 symbolizer TUs -fno-profile-instr-generate -fno-coverage-mapping.

Comment thread src/CMakeLists.txt Resolved
@groeneai

Copy link
Copy Markdown
Collaborator Author

CI finish ledger - 01cc0ed

Every failure below has an owner: a fixing PR (mine or external), or a full-effort fix task
whose fixing-PR link will be posted here when it opens. Only CH Inc sync is exempt.

Check / test Reason Owner / fixing PR
Integration tests (arm_binary, 1/4) / test_storage_iceberg_concurrent/test_concurrent_reads.py::test_concurrent_reads not from this PR (it only changes the coverage flags of five symbolizer files in src/CMakeLists.txt): Code 107, the Iceberg metadata file of the table Spark had just created does not exist in this module's MinIO. That is one of the two signatures #125448 fixes (a reused Spark JVM kept another module's s3a:// filesystem); the fix merged after this run's merge commit was built. The test failed on 58 PRs and 24 master runs in 30 days #125448 (mine, merged)
Mergeable Check, PR praktika rollups of the row above #125448 (mine, merged)

CIDB has no other FAIL or ERROR row on this head.

Session id: cron:our-pr-ci-monitor:20261013-033012

@alexbakharew

Copy link
Copy Markdown
Contributor

@groeneai please merge latest master

@groeneai

Copy link
Copy Markdown
Collaborator Author

Merged the latest master (b26f4c3) into the branch, new head b4de31c. No conflicts, and the PR diff is unchanged (src/CMakeLists.txt only).

@fm4v
fm4v added this pull request to the merge queue Oct 14, 2026
Merged via the queue into ClickHouse:master with commit f9a06cc Oct 14, 2026
176 checks passed
@robot-clickhouse robot-clickhouse added the pr-synced-to-cloud The PR is synced to the cloud repo label Oct 14, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

can be tested Allows running workflows for external contributors comp-build-system Build system (CMake, compilation, platform builds). groeneai-origin-ci-master PR origin: master/nightly CI monitoring finding pr-ci pr-synced-to-cloud The PR is synced to the cloud repo

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants