Repository navigation
Remove dead call-depth instrumentation from the per-test coverage build - #118370
Conversation
…trumentation 0599d40 replaced the -finstrument-functions shadow stack with an entry call count read from the LLVM profile counters, but WITH_COVERAGE_DEPTH kept injecting -finstrument-functions-after-inlining into the global C and C++ flags. Every function entry and exit in the whole binary, contrib included, therefore still calls two empty stubs in base/base/coverage.cpp that nothing consumes. base/base/CMakeLists.txt compiles base/base with ${COVERAGE_FLAGS}, so the stubs carry their own profile counters: no_instrument_function stops them recursing, it does not stop them being profiled. Their entry counters are incremented once per function entry and once per function exit program-wide, which makes them the two hottest function counters in the process: on a SELECT count() FROM numbers(10000000) they reach 6213755 and 6212763, 5.3x the next hottest function counter and together 23.5% of all counter increments. With -mllvm -runtime-counter-relocation and the %c pattern both effective, those counters live in a MAP_SHARED mapping of the profile pool file, so processes that run concurrently store into the same file-backed words at function-call frequency. The removal cannot change what per-test coverage measures: the hooks are empty, min_depth comes from the entry counter (or from XRay where CLICKHOUSE_XRAY_INSTRUMENT_COVERAGE is defined), and the WITH_COVERAGE_DEPTH macro that compiles in CoverageCollection.cpp, LLVMCoverageMapping.cpp and SYSTEM SET COVERAGE TEST comes from the CMake option, not from this flag. Also correct the option description, the coverage.h min_depth doc and the two build-flag lines in .claude/docs/relevant_tests.md, which all still described the deleted shadow stack.
…verage The per-test coverage job never reads client .profraw files: ci/jobs/functional_tests.py merges them only for the non-per-test coverage job. Under %c a client's counters live in a MAP_SHARED mapping of one of the two merge-pool files, so the clients a test runs concurrently store into the same file-backed pages at counter-update frequency, and the lane pays that for a profile it discards. Measured with the Build (amd_llvm_coverage_per_test) cmake flags, pinned to 8 CPUs (the shape $(nproc) reports on the lane's runner), --collect-per-test-coverage --jobs 1 and randomization off, on a tree that already has the orphaned -finstrument-functions-after-inlining instrumentation removed: 03147_system_columns_access_checks 93.2s -> 34.8s (medians, n=6-7 per arm) 01161_all_system_tables 31.2s -> 14.9s 02475_bson_each_row_format 12.8s -> 12.1s 02475 spawns 115 clients but never two at once, and it does not move: the cost belongs to clients whose lifetimes overlap and therefore share a live mapping, not to client count. The lanes that do consume client profiles keep %c, so the kill-safety property that motivated it there is unchanged.
Internal second-model reviewTwo commits, 5 files, +14/-19. Reviewed cold, then by an independent second model; one fix round
|
|
Workflow [PR], commit [5541335] Summary: ✅
AI ReviewSummaryThis PR removes the obsolete Missing context / blind spots
Final Verdict✅ No new findings. LLVM Coverage ReportMeasured on commit 5541335.
Changed lines: Changed C/C++ lines covered: 0/0 (nothing coverable) · Uncovered code |
|
cc @alexbakharew @fm4v, could you review this? Since 0599d40 replaced the shadow stack with an entry-count read, |
Build profile diff (arm_release)Comparing ✅ No significant changes. Binary sizes
The official master build is compiled with Compile time of recompiled translation units6 translation units recompiled, 4 s compile time in total, 6 of them have a recent master baseline. |
|
A second test on this lane goes red from the same mechanism, and it is the second commit that carries its margin.
At sha Its shape is concurrently live clients plus a per-call bound, so the arm that decides it is the client pattern rather than the stub deletion: under I am not proposing a change to the test. Its 30 s wrapper is a hang detector, and it held for 27 consecutive runs on this lane before 2026-08-28. |
98d3af8
On the per-test coverage lanes every process of the coverage binary merged its counters at exit into a merge-pool file shared by the whole job (`%2m` for stateless clients and the job env, `%4m` for integration containers and host clients), without continuous mode. The exit-time merge maps the pool file, merges it, truncates it and rewrites it from offset 0. A process SIGKILLed during that rewrite (02435's `thread_cancel`, the runner's process-group kill on a timeout) can leave the value-profile records cut inside a record. Every later process whose pool slot (`getpid() % N`) is that file then reads past the mapping in `lprofMergeValueProfData` and dies with SIGSEGV after its output, and the file stays poisoned. NightlyCoverage `Stateless tests (amd_llvm_coverage_per_test, per_test_coverage, 2/8)` on 358b830 lost 251 results this way: all 392 crashing client PIDs were even (pool slot 0), and the 163 sequential tests, which use another pool file, all passed. Those lanes never merge a `.profraw`: per-test coverage is read inside the server from the static counter section and exported from `system.coverage_log`. So point `LLVM_PROFILE_FILE` at `/dev/null` there: no process opens, reads or merges a pool file any more. The other lanes keep their `%c` values, which never merge. Not `%p` (thousands of files, ClickHouse#97020), not `%c` again (the shared-mapping slowdown ClickHouse#118370 removed). Co-Authored-By: Claude Opus 5.5 <[email protected]>
Description
03147_system_columns_access_checksis killed at the 600s per-test cap onStateless tests (amd_llvm_coverage_per_test, per_test_coverage, 5/8)on two consecutive nightlies (2026-09-04, 2026-09-05) after 17 days at 95-130s; the kill lands inside its 1000-table fixture, so its duration oracle asserts nothing there.0599d405a0661f3replaced the-finstrument-functionsshadow stack with an entry call count read from the profile counters, butWITH_COVERAGE_DEPTHstill adds-finstrument-functions-after-inliningto the global C and C++ flags, so every function entry and exit in the binary, contrib included, calls two empty stubs inbase/base/coverage.cpp.base/baseis compiled with${COVERAGE_FLAGS}, so those stubs carry their own counters: onSELECT count() FROM numbers(10000000)they reach 6213755 and 6212763, 5.3x the next hottest function counter and 23.5% of all counter increments. Once continuous mode began working those counters moved into aMAP_SHAREDmapping of a merge-pool file, so concurrent clients store into the same file-backed pages at call frequency.Deleting them cannot change what per-test coverage measures: the hooks are empty,
min_depthcomes from the entry counter or from XRay, and theWITH_COVERAGE_DEPTHmacro comes from the CMake option. Measured,coverageDiag()map_sizedrops by exactly 2, nothing else moves, and the runner's coverage self-test andsystem.coverage_indirect_callsstay green. The second commit stops requesting continuous mode for client profiles this lane discards.Local A/B, the lane's cmake flags, 8 CPUs pinned, randomization off, arms interleaved
Medians;
03147n=6-7 per arm, the others 1-3.03147_system_columns_access_checks01161_all_system_tables02475_bson_each_row_format(115 clients, never two at once)02475is the control: clients that never overlap never share a live mapping, and it does not move. Nothing got slower. Ranges: master 113-199s, deletion 79-130s, both 33-37s. 44 tests on this lane exceed their 17-day maximum by >=1.5x on both failing days.On my host the failing arm runs at 113-199s, not at the cap, so this measures the mechanism's size, not that CI lands under 600s. Everything here sits behind
WITH_COVERAGE_DEPTH, which onlyBuild (amd_llvm_coverage_per_test)sets and onlynightly_coverage.pyschedules, so PR CI neither runs nor builds it; a build break there is this diff's real risk, so I built both arms cold with that job's cmake flags. Owner's call, not taken here: this lane reads no client.profraw, so client profiling could be dropped rather than switched. No related open issue found.Changelog category (leave one):
Changelog entry (a user-readable short description of the changes that goes into CHANGELOG.md):
Drop the orphaned
-finstrument-functions-after-inlininginstrumentation and its two empty__cyg_profile_func_*stubs from theWITH_COVERAGE_DEPTHbuild, and stop requesting LLVM continuous mode for client profiles on the per-test coverage lane.Workflow [PR]
Sync PR [sync-upstream/pr/118370]
Version info
26.9.1.1339(included in26.9and later)