Skip to content

Add ARM SVE infrastructure and SVE-optimized paths for min/max aggregation - #122860

Merged
rienath merged 11 commits into
ClickHouse:masterfrom
chiranmoyf:sve-enablement-and-optimization
Oct 28, 2026
Merged

rienath merged 11 commits into
ClickHouse:masterfrom
chiranmoyf:sve-enablement-and-optimization

Conversation

@chiranmoyf

@chiranmoyf chiranmoyf commented Sep 29, 2026 •

Copy link
Copy Markdown
Contributor

Changelog category (leave one):

  • Performance Improvement

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

Improve performance of min, max, argMin, argMax and their -If variants on AArch64 CPUs with SVE (e.g., AWS Graviton3/Graviton4) via runtime-dispatched SVE implementations.

Description

  1. Add DECLARE_ARM_SVE_SPECIFIC_CODE for AArch64. It compiles the enclosed block with SVE enabled, and its usage is guarded by USE_ARM_MULTITARGET_CODE. SVE is detected at runtime and enabled only on Linux and FreeBSD (Darwin does not support SVE).

  2. Add MULTITARGET_FUNCTION_ARM_SVE and extend MULTITARGET_FUNCTION_X86_V4_V3 to MULTITARGET_FUNCTION_X86_V4_V3_ARM_SVE, and MULTITARGET_FUNCTION_X86_V4 to MULTITARGET_FUNCTION_X86_V4_ARM_SVE, so these functions also get an SVE version on AArch64.

  3. Add SVE dispatchers for findExtreme (min/max aggregation). Performance results on c8g.4xlarge using the arithmetic_operations_in_aggr_func test: pastila.

  4. Non-SVE AArch64 CPUs and x86 builds are unaffected.

Related: #116581
Related: #97473

This PR is a joint contribution by:

Abhishek Jain (@abhijain1204fujitsu)


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

Version info

  • Merged into: 26.11.1.848-master (included in 26.11 and later)

@chiranmoyf

Copy link
Copy Markdown
Contributor Author

@rienath Apologies for the delay. GitHub Enterprise account doesn't allow granting edit rights to maintainers, so we couldn't give you commit access on #97473. This PR is opened from a personal fork, so you should have edit rights here.

@clickhouse-gh

clickhouse-gh Bot commented Sep 29, 2026 •

Copy link
Copy Markdown
Contributor

Workflow [PR], commit [3617848]

Summary: ✅


AI Review

Summary

Adds runtime SVE detection and target-specific compilation helpers, then dispatches findExtreme to an SVE-enabled implementation on supported AArch64 systems. The supplied Graviton4 benchmark reports 25.9–34.3% lower execution times for the affected min/max queries. No actionable findings remain; the previous bot finding is addressed by the explicit x86-only macro and documentation.

Missing context / blind spots
  • ⚠️ ARM builds, functional tests, and performance comparisons for head 3617848098600a1cdd624626b39b4fc60e8d033e are still running or pending in the current CI report. The earlier 69e078c10c1724d4e388e5a3975e97ffd3b90f83 run includes a Some queries hung failure in ARM parallel-replica tests; its cause was not established in this review. Successful head results or a diagnosis of that failure would close this verification gap.
  • ⚠️ No local compilation or runtime tests were performed: this checkout has no configured build or ClickHouse executable. Runtime validation relies on CI and the supplied benchmark.
Final Verdict

Status: ✅ Approve — no source changes requested. Current-head CI validation remains outstanding.

@clickhouse-gh clickhouse-gh Bot added the pr-performance Pull request with some performance improvements label Sep 29, 2026
@rienath rienath added the can be tested Allows running workflows for external contributors label Sep 29, 2026
@clickhouse-gh clickhouse-gh Bot added the comp-aggregate-functions Aggregate function implementations (sum, avg, count, quantile, combinators, etc.). label Sep 29, 2026
@chiranmoyf

Copy link
Copy Markdown
Contributor Author

Changes from #97473:

  1. #97473 had SVE dispatchers for unary arithmetic functions. Since #116164 already covers most of what they were addressing, we have removed them from this PR. We will evaluate whether the dispatchers are still worth adding.
  2. #97473 also had an SVE-optimized ColumnVector filter for 4-byte data types. We are working on extending it to 1/2/8-byte types and will submit it separately. Ref: review
  3. Other PRs, such as #122871, depend on the infrastructure introduced here.

Comment thread src/Common/TargetSpecific.h Resolved
@clickhouse-gh

clickhouse-gh Bot commented Sep 29, 2026 •

Copy link
Copy Markdown
Contributor

Build profile diff (arm_release)

Comparing 361784809 with master 00b79c605 (stripped binary size, per-symbol sizes and ThinLTO time; compile times per translation unit against the most recent warmup build that recompiled it).

✅ No significant changes.

Binary sizes

programs/clickhouse-stripped: smaller than the master baseline by the known offset between the two builds, so the difference is not shown. A delta that differs from the offset by more than 50% of it is shown, in either direction.

The official master build is compiled with -g and a pull request build is not, and XRay counts debug instructions towards its instrumentation threshold, so master instruments thousands of functions more and its binary is ~0.4% larger no matter what the pull request does.

Object file sizes

10 object files changed (+87.08 KiB total), 0 added.

Object file Master PR Δ
src/CMakeFiles/clickhouse_common_io.dir/Common/findExtreme.cpp.o 237.93 KiB 317.12 KiB +79.19 KiB (+33.28%)

719 more object files are built by the master warmup baseline only (it builds every object-file target, a pull request build only clickhouse-bundle) and not compared.

Compile time of recompiled translation units

230 translation units recompiled, 1472 s compile time in total, 230 of them have a recent master baseline.

Median compile-time ratio to the baselines is ×1.07 (machine-speed difference or a change affecting every TU); per-TU deltas below are relative to that ratio.
The matched translation units cost +109.6 s (+8%) in total before that adjustment.

Job report

@clickhouse-gh

clickhouse-gh Bot commented Sep 29, 2026

Copy link
Copy Markdown
Contributor

📊 Cloud Performance Report

✅ AI verdict: no_change — no significant changes across 35 queries analysed

no significant changes detected. K_source=6 K_base=30 flagged=0/65

clickbench

🟢 No significant changes

tpch_adapted_1_official

🟢 No significant changes

Debug info
  • StressHouse run: 97e3f144-84d7-4775-898b-b6767ff02807
  • MIRAI run: 1a463878-5bbf-447d-8e48-d4d1d7b83fd3
  • PR check IDs:
    • clickbench_2404202_1790693643
    • clickbench_2404208_1790693643
    • clickbench_2404214_1790693643
    • tpch_adapted_1_official_2404225_1790693643
    • tpch_adapted_1_official_2404258_1790693643
    • tpch_adapted_1_official_2404272_1790693644

@clickhouse-gh clickhouse-gh Bot added the external Author is not a member of the ClickHouse organization label Sep 30, 2026
On AArch64, the default copy is used. SVE versions of these kernels were measured and showed no improvement over NEON, except for some hash functions in `src/Functions/FunctionsHashing.h`.
@chiranmoyf

Copy link
Copy Markdown
Contributor Author

@rienath, the AI bot has approved, and the performance numbers are back in the dashboard.

@rienath rienath 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.

A few nits, but otherwise looks good. Thanks for taking the effort to reopen it after such long time!

@groeneai once this PR merges, please create a follow-up that rename USE_MULTITARGET_CODE to USE_X86_64_MULTITARGET_CODE and ping me. Not doing this in current PR to prevent unnecessary conflicts

Comment thread src/Common/CPUID.h Resolved
Comment thread src/Common/TargetSpecific.cpp Resolved
@groeneai

Copy link
Copy Markdown
Collaborator

Will do: once this merges, I will open the USE_MULTITARGET_CODE -> USE_X86_64_MULTITARGET_CODE rename and ping you there.

@chiranmoyf
chiranmoyf requested a review from rienath October 19, 2026 18:41
@chiranmoyf

Copy link
Copy Markdown
Contributor Author

@rienath CH Inc sync is failing, but I can't view the logs. Could you check from your end and let me know if anything needs fixing on my side?

@rienath
rienath added this pull request to the merge queue Oct 28, 2026
Merged via the queue into ClickHouse:master with commit b15aa99 Oct 28, 2026
178 checks passed
@robot-ch-test-poll3 robot-ch-test-poll3 added the pr-synced-to-cloud The PR is synced to the cloud repo label Oct 28, 2026
@groeneai

Copy link
Copy Markdown
Collaborator

Opened #128073 for the rename.

opensource-fork-sync Bot pushed a commit to cla7aye15I4nd/opensource-ClickHouse__ClickHouse that referenced this pull request Oct 29, 2026
Since ClickHouse#122860 the macro is 1 only on x86_64, and AArch64 has its own
`USE_ARM_MULTITARGET_CODE`. Whole-word rename, no other change.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
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-aggregate-functions Aggregate function implementations (sum, avg, count, quantile, combinators, etc.). external Author is not a member of the ClickHouse organization 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.

5 participants