Skip to content

Revert "Change default x86 build target from x86-64-v2 (SSE4.2) to x86-64-v3 (AVX2)"#104971

Merged
Algunenano merged 2 commits into
ClickHouse:masterfrom
Algunenano:revert-90043-x86v3
May 15, 2026
Merged

Revert "Change default x86 build target from x86-64-v2 (SSE4.2) to x86-64-v3 (AVX2)"#104971
Algunenano merged 2 commits into
ClickHouse:masterfrom
Algunenano:revert-90043-x86v3

Conversation

@Algunenano
Copy link
Copy Markdown
Member

@Algunenano Algunenano commented May 14, 2026

Revert PR #90043 due to performance regressions in the MSan build.

Reference: #104947 (comment)

Note: a post-merge follow-up commit (9df07df5a0a, "Pass nm/ar/objcopy paths from CMake to localize_rust_c_symbols.sh") added an NM_PATH lookup in cmake/tools.cmake for the now-removed cmake/localize_rust_c_symbols.sh helper. The lookup is left in place by this revert; it is unused but harmless and can be cleaned up separately.

Closes #104866
Closes #104873
Closes #104874

Changelog category (leave one):

  • Backward Incompatible Change

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

Revert the default x86 build target back to x86-64-v2 (SSE4.2). The previous switch to x86-64-v3 (AVX2) is being rolled back.

…6-64-v3 (AVX2)"

This reverts PR ClickHouse#90043 (merge commit e21a84e) due to performance
regressions observed in the MSan build.

Note: a post-merge follow-up commit (9df07df, "Pass nm/ar/objcopy
paths from CMake to localize_rust_c_symbols.sh") added an `NM_PATH`
lookup in `cmake/tools.cmake` for the now-removed
`cmake/localize_rust_c_symbols.sh` helper. The lookup is left in place
by this revert; it is unused but harmless and can be cleaned up
separately.
@Algunenano Algunenano enabled auto-merge May 14, 2026 17:34
@clickhouse-gh
Copy link
Copy Markdown
Contributor

clickhouse-gh Bot commented May 14, 2026

Workflow [PR], commit [d66039c]

Summary:

job_name test_name status info comment
Stress test (arm_asan_ubsan) FAIL
Hung check failed, possible deadlock found FAIL cidb IGNORED

AI Review

Summary

This PR reverts #90043 to move the default x86 target back to x86-64-v2 and restores older CPU-dispatch wiring across multiple components. I found one blocker in the newly reintroduced llvm-libc runtime dispatch logic: x86_64_v3 is selected using only FMA, which is weaker than the full x86_64_v3 contract and can route execution to unsupported instructions.

Findings

❌ Blockers

  • [contrib/libllvmlibc-cmake/llvmlibc_dispatch.cpp:12] cpu_has_fma is used as the only predicate for dispatching to __llvm_libc__x86_64_v3::*. The x86_64_v3 build requires a broader feature set (including AVX2 and others), so this can select the v3 path on CPUs that do not satisfy full v3 requirements, causing illegal-instruction faults at runtime.
  • Suggested fix: gate v3 dispatch on the same full capability check used elsewhere (for example isArchSupported(TargetArch::x86_64_v3)), and keep x86_64_v2 as the fallback.
Final Verdict

❌ Changes requested

@clickhouse-gh clickhouse-gh Bot added pr-backward-incompatible Pull request with backwards incompatible changes submodule changed At least one submodule changed in this PR. labels May 14, 2026
Comment thread src/Functions/mortonEncode.cpp Outdated
Comment thread src/Functions/mortonDecode.cpp Outdated
The reverted Morton encode/decode files still referenced
`DECLARE_AVX2_SPECIFIC_CODE`, a macro that was renamed to
`DECLARE_X86_64_V3_SPECIFIC_CODE` in an earlier refactor and never
restored. With the default `X86_ARCH_LEVEL=2` build the offending
block is preprocessed away (`__BMI2__` is undefined), but configuring
with `-DX86_ARCH_LEVEL=3` or higher would fail to compile.

Switch both call sites to the existing `DECLARE_X86_64_V3_SPECIFIC_CODE`
macro so the BMI2 multitarget block compiles correctly when enabled.
__attribute__((always_inline))
inline bool cpu_has_fma()
{
static const bool has_fma = DB::CPU::haveFMA();
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.

cpu_has_fma is not a sufficient gate for the x86_64_v3 math implementation. The x86_64_v3 variant is built with AVX2-level requirements, but this check only tests FMA, so a host that has FMA but lacks some x86_64_v3 features can still be routed to __llvm_libc__x86_64_v3::* and hit illegal-instruction faults at runtime.

Please gate this on the full x86_64_v3 capability check (for example isArchSupported(TargetArch::x86_64_v3)), with x86_64_v2 as fallback.

@clickhouse-gh
Copy link
Copy Markdown
Contributor

clickhouse-gh Bot commented May 14, 2026

LLVM Coverage Report

Metric Baseline Current Δ
Lines 84.10% 84.10% +0.00%
Functions 92.00% 90.90% -1.10%
Branches 76.50% 76.60% +0.10%

Changed lines: 75.49% (465/616) | lost baseline coverage: 18 line(s) · Uncovered code

Full report · Diff report

@Algunenano Algunenano added this pull request to the merge queue May 15, 2026
Merged via the queue into ClickHouse:master with commit 741871e May 15, 2026
165 of 167 checks passed
@Algunenano Algunenano deleted the revert-90043-x86v3 branch May 15, 2026 08:57
@robot-ch-test-poll2 robot-ch-test-poll2 added the pr-synced-to-cloud The PR is synced to the cloud repo label May 15, 2026
@groeneai groeneai mentioned this pull request May 17, 2026
1 task
alexey-milovidov added a commit that referenced this pull request May 19, 2026
PR #90043 set the default x86 build target to x86-64-v3 (AVX2); PR #104971
reverted it in the same release range. Neither change is visible in the
26.5 release, so per the edit-changelog skill rule both entries are
removed.
groeneai added a commit to groeneai/ClickHouse that referenced this pull request May 20, 2026
… WasmEdge MSan CI

Algunenano's PR ClickHouse#104971 reverts the x86v3 default; that fixed the chronic
DB::SystemLogQueue<DB::QueryLogElement>::waitFlush 180s timeout family
on Stateless tests (amd_msan, WasmEdge, *) which was the only failing
check on this PR's prior CI run (2026-05-15 02:15 UTC).

Master WasmEdge MSan SystemLog flush timeouts dropped from 33/day
(2026-05-13) to 0/day (2026-05-16+) after PR ClickHouse#104971 merged at
2026-05-15 08:57 UTC. Merging master to re-trigger CI on the post-revert
build so PR ClickHouse#104968 can be evaluated cleanly.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

pr-backward-incompatible Pull request with backwards incompatible changes pr-synced-to-cloud The PR is synced to the cloud repo submodule changed At least one submodule changed in this PR.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Flaky test: 01721_join_implicit_cast_long_oldanalyzer Flaky test: 00945_bloom_filter_index Flaky test: 04039_merge_tree_snapshot_teardown_race

2 participants