Skip to content

Use clang-22 - #108400

Merged
thevar1able merged 55 commits into
masterfrom
use-clang-22
Aug 10, 2026
Merged

thevar1able merged 55 commits into
masterfrom
use-clang-22

Conversation

@thevar1able

@thevar1able thevar1able commented Jun 24, 2026 •

Copy link
Copy Markdown
Member

Changelog category (leave one):

  • Build/Testing/Packaging Improvement

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

Use clang-22 in CI.

@clickhouse-gh

clickhouse-gh Bot commented Jun 24, 2026 •

Copy link
Copy Markdown
Contributor

Workflow [PR], commit [39a2c49]

Summary: ❌

job_name test_name status info comment
Stress test (amd_debug) FAIL
Logical error: Sizes of nested column and null map of Nullable column are not equal after deserialization (null map size = A, nested column size = B) (STID: 6726-6673) FAIL cidb IGNORED
Stress test (amd_tsan) FAIL
Logical error: Sizes of nested column and null map of Nullable column are not equal after deserialization (null map size = A, nested column size = B) (STID: 6726-6444) FAIL cidb IGNORED

AI Review

Summary

This PR switches CI and the bundled toolchain/docs from clang-21 to clang-22, updates the LLVM coverage tool selection, and adds a few source-level workarounds for clang-22 codegen/tidy fallout. The current head fixes most earlier review points and CI is green, but four remaining gaps still leave sibling vector kernels, two coverage jobs, and one stateless reference out of sync with the compiler-upgrade contract.

Findings

⚠️ Majors

  • [src/Functions/array/arrayNorm.cpp:364] normalizeBatchImpl still uses the same outer-i += unroll_count / inner-s accumulation loop that now needs _Pragma("clang loop vectorize(disable)") in normBatchImpl at [src/Functions/array/arrayNorm.cpp:167]. That means arrayL1Normalize / arrayL2Normalize / arrayLpNormalize / arrayLinfNormalize are still exposed to the clang-22 slow strided-gather codegen this PR is explicitly working around. Suggested fix: apply the same pragma here or factor the shared accumulation loop so the norm and normalize paths cannot drift again.
  • [src/Functions/array/arrayDotProduct.cpp:50] [src/Functions/array/arrayDotProduct.cpp:88] The same unrolled loop shape is still present in both dotProductBatchImpl and dotProductConstBatchImpl, even though this PR already had to patch the sibling array*Norm / array*Distance kernels for clang-22 misvectorization. Leaving arrayDotProduct on the old pattern means one of the main vector-search primitives can still regress under the global compiler switch with no focused evidence that these two kernels are unaffected. Suggested fix: add the same pragma here, or provide a focused benchmark/codegen check showing both dot-product kernels still compile to the contiguous-load path under clang-22.
  • [ci/jobs/functional_tests.py:1429] [ci/jobs/integration_test_job.py:1005] The LLVM coverage fallback lists are still out of order: they probe 18 before 19. If an image carries LLVM 18 and 19 but not 20+ during a future transition, these jobs will pick the older tool and recreate the same cross-major llvm-profdata mismatch this PR is trying to eliminate. Suggested fix: make both lists strictly descending (22, 21, 20, 19, 18, 17, 16, "") to match ci/jobs/unit_tests_job.py and ci/jobs/scripts/merge_llvm_coverage.sh.
  • [tests/queries/0_stateless/02417_opentelemetry_insert_on_distributed_table.reference:11] The updated reference is still asserting the compiler-specific __PRETTY_FUNCTION__ spelling of the lambda created in [src/Storages/Distributed/DistributedSink.cpp:379]. The only behavior change here is clang-22 printing (lambda) instead of (anonymous class), so the test is now pinned to a toolchain detail rather than to any tracing invariant. Suggested fix: normalize the lambda spelling in the query output, or assert only stable span properties instead of the raw operation_name text.
Final Verdict
  • Status: ⚠️ Request changes
  • Minimum required actions: cover the remaining clang-22 vector-kernel gaps (normalizeBatchImpl and arrayDotProduct), fix the misordered llvm-profdata fallback lists, and stop asserting compiler-specific lambda spellings in the OpenTelemetry reference.

LLVM Coverage Report

Metric Baseline Current Δ
Lines 86.60% 86.60% +0.00%
Functions 91.90% 92.00% +0.10%
Branches 78.80% 78.80% +0.00%

Changed lines: Changed C/C++ lines covered: 15/15 (100.00%) · Uncovered code

Full report · Diff report

@clickhouse-gh clickhouse-gh Bot added the pr-performance Pull request with some performance improvements label Jun 24, 2026
Comment thread ci/defs/defs.py Resolved
Comment thread ci/jobs/build_toolchain.py Resolved
@clickhouse-gh

This comment was marked as low quality.

@thevar1able thevar1able added the ci-performance performance only label Jun 29, 2026
@thevar1able thevar1able removed the ci-performance performance only label Jun 30, 2026
Replace .find(needle) != npos / .find(needle) == npos patterns with
.contains(needle) / !.contains(needle) across 37 source and test files.

This resolves the remaining readability-container-contains clang-tidy
warnings from the clang-22 migration (PR #108400).

Files touched: programs/server, src/Analyzer, src/Backups/tests,
src/Client, src/Common, src/Databases, src/Disks, src/Functions,
src/IO/tests, src/Interpreters, src/Parsers/Kusto, src/Processors,
src/Server, src/Storages (Kafka, MergeTree, ObjectStorage, MongoDB, URL)

Assisted-by: Claude Opus 4.6 via GitHub Copilot
Signed-off-by: Konstantin Bogdanov <[email protected]>
Comment thread base/base/shift10.cpp Resolved
@Algunenano Algunenano self-assigned this Aug 3, 2026

@Algunenano Algunenano left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM. We should update docs/en too if possible, but we can do it in another PR (or in this one if you need to push other changes as well)

Comment thread docs/en/development/build.md Resolved
thevar1able and others added 3 commits August 3, 2026 15:27
The Clang install snippet still called `llvm.sh 21` right above an
example using `CC=clang-22`/`CXX=clang++-22`, left over from the
toolchain's move to LLVM 22 in `ci/jobs/build_toolchain.py`.

Co-Authored-By: Claude Sonnet 5 <[email protected]>
===3===
{"operation_name":"auto DB::DistributedSink::runWritingJob(JobReplica &, const Block &, size_t)::(anonymous class)::operator()() const","cluster":"test_cluster_two_shards_localhost","shard":"1","rows":"1","bytes":"8"}
{"operation_name":"auto DB::DistributedSink::runWritingJob(JobReplica &, const Block &, size_t)::(anonymous class)::operator()() const","cluster":"test_cluster_two_shards_localhost","shard":"2","rows":"1","bytes":"8"}
{"operation_name":"auto DB::DistributedSink::runWritingJob(JobReplica &, const Block &, size_t)::(lambda)::operator()() const","cluster":"test_cluster_two_shards_localhost","shard":"1","rows":"1","bytes":"8"}

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This reference is still asserting the compiler-specific __PRETTY_FUNCTION__ spelling of the lambda in DistributedSink::runWritingJob (src/Storages/Distributed/DistributedSink.cpp:377). The only reason these lines changed from (anonymous class) to (lambda) is the clang-21 -> clang-22 pretty-printer difference, so the next toolchain or demangler change will churn this reference again without any tracing regression.

Can we normalize the lambda portion in the query output, or assert a stable span property instead of the exact operation_name text?

const size_t unrolled_end = count / unroll_count * unroll_count;

/// Keep this outer loop scalar: `clang-22` otherwise vectorizes it into a slow strided gather instead of letting the unrolled inner loop SLP-vectorize into contiguous loads (worst for `Linf`/`BFloat16`).
_Pragma("clang loop vectorize(disable)")

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This loop-shape fix is still incomplete for the global clang-22 switch. src/Functions/array/arrayDotProduct.cpp uses the same outer-i += unroll_count / inner-s pattern in both dotProductBatchImpl (:48-52) and dotProductConstBatchImpl (:87-90), so arrayDotProduct is still exposed to the same slow strided-gather codegen even after array*Norm / array*Distance are patched here.

Please either apply the same _Pragma("clang loop vectorize(disable)") there or add a focused benchmark showing the dot-product kernels are unaffected.

@clickhouse-gh clickhouse-gh Bot added the pr-build Pull request with build/testing/packaging improvement label Aug 5, 2026
# Auto-detect available LLVM profdata tool
llvm_profdata = None
for ver in ["21", "20", "18", "19", "17", "16", ""]:
for ver in ["22", "21", "20", "18", "19", "17", "16", ""]:

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This fallback is still out of order: it probes llvm-profdata-18 before llvm-profdata-19, and ci/jobs/integration_test_job.py:1005 has the same list. If an image carries LLVM 18 and 19 but not 20+ during a future toolchain transition, these coverage jobs will pick the older tool and recreate the same cross-major mismatch this PR is trying to remove. Please make both lists strictly descending (22, 21, 20, 19, 18, 17, 16, "") to match unit_tests_job.py and merge_llvm_coverage.sh.

@thevar1able
thevar1able added this pull request to the merge queue Aug 10, 2026
Merged via the queue into master with commit 64cb4e8 Aug 10, 2026
177 of 180 checks passed
@thevar1able
thevar1able deleted the use-clang-22 branch August 10, 2026 17:33
@robot-clickhouse-ci-1 robot-clickhouse-ci-1 added the pr-synced-to-cloud The PR is synced to the cloud repo label Aug 10, 2026
alexey-milovidov pushed a commit that referenced this pull request Aug 11, 2026
Build (arm_tidy) is red on master:

  src/Databases/DatabaseRemote.cpp:1058:26: error: use 'contains' to check
  for membership [readability-container-contains,-warnings-as-errors]

clang-tidy runs as warnings-as-errors there, so the single diagnostic aborts
the build and every PR that merges master inherits the red.

The line is not an authoring mistake. readability-container-contains under
clang-tidy-21 flags the find(...) != end() container form but not
std::string::find(char) != npos; clang-tidy-22 flags both. The compiler bump
landed in #108400 at 2026-08-10 17:33 UTC and the branch carrying this line
merged at ~00:15 UTC, so the TU entered master's tidy build already diagnosed
by a checker that had not diagnosed it during the branch's own 12 green runs.

String is std::string and the project builds at C++23, so contains is
available and exactly equivalent. Verified by asserting
(s.find(':') != npos) == s.contains(':'), and the full guard including
!starts_with('['), over 13 inputs covering empty, ":", "::", leading and
trailing ':', bare and bracketed IPv6, non-IPv6 hosts and an embedded NUL.
No behaviour change.

The last green master commit already contained the clang-22 bump, so any
other new violation of this check must lie in the green-to-red range. Sweeping
that range's added lines for all three forms the check recognises yields
exactly this one line.

Related: #110975
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

pr-build Pull request with build/testing/packaging improvement pr-performance Pull request with some performance improvements 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.

3 participants