Skip to content

Remove the sharded aggregator in favor of the adaptive aggregator - #116532

Merged
nihalzp merged 5 commits into
ClickHouse:masterfrom
nihalzp:remove-sharded-aggregator
Aug 29, 2026
Merged

nihalzp merged 5 commits into
ClickHouse:masterfrom
nihalzp:remove-sharded-aggregator

Conversation

@nihalzp

@nihalzp nihalzp commented Aug 26, 2026 •

Copy link
Copy Markdown
Member

Related: #111459

Removes the sharded aggregator (enable_sharding_aggregator, off by default): since the adaptive aggregator (enable_adaptive_aggregator) arrived, there is no workload left where sharding wins. Both attack the same cost - every thread aggregating every key - but the adaptive aggregator routes only the rare keys, keeps the frequent keys in thread-local tables, and handles skew, low cardinality, and external aggregation, which the sharded exchange never supported.

The setting is retired as obsolete rather than deleted: SET enable_sharding_aggregator = ... and profiles carrying it keep working with no effect (is_obsolete = 1 in system.settings), and a SettingsChangesHistory entry documents the removal and points to enable_adaptive_aggregator. Nothing about this feature was ever serialized in query plans or gated by a protocol revision, so mixed-version clusters are unaffected; an older peer sending the setting hits a known, inert name. In the other direction the standard obsolete-setting semantics apply, as for every retired setting: a changed value is still forwarded by name, so an older worker that still has the feature keeps honoring it there until it is upgraded - results are identical either way.

Removed with the feature: BufferedShardByHashTransform, the AggregatingStep scatter pipeline with its Scatter/AggregatingSharded stages, the admission logic, and the feature's ten test suites. Tests that only pinned the setting off (adaptive suites, several integration tests carrying a now-impossible TODO) lose the pins; 04278_parallel_replicas_coordinator_mode_collision stays, reworked without the sharded arm, because the parallel-replicas settings-scope fix it pins survives this change and its companion tests reference it. IColumn::computeHashInto and its benchmark stay - the parallel-window scatter and hash joins use the same kernel - with comments repointed to ScatterByPartitionTransform.

Changelog category (leave one):

  • Backward Incompatible Change

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

Removed the sharded GROUP BY aggregation (setting enable_sharding_aggregator, disabled by default) in favor of the adaptive aggregation (enable_adaptive_aggregator, enabled by default), which targets the same high cardinality workloads without the weaknesses on skewed or low-cardinality keys and with external-aggregation support. The setting is kept as obsolete: setting it is still accepted and has no effect.


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

Version info

  • Merged into: 26.9.1.310 (included in 26.9 and later)

@clickhouse-gh

clickhouse-gh Bot commented Aug 26, 2026 •

Copy link
Copy Markdown
Contributor

Workflow [PR], commit [8b9edfb]

Summary: ✅


AI Review

Summary

This PR removes the sharded GROUP BY aggregation path, deletes BufferedShardByHashTransform, and keeps enable_sharding_aggregator as an obsolete no-op setting. The mechanical removal is mostly straightforward, but two review concerns remain: the replacement contract is still broader than the code actually implements, and one rewritten regression test no longer reproduces the coordinator-mode bug it claims to guard. Final verdict: ⚠️ Request changes.

PR Metadata
  • Changelog category is correct.
  • Changelog entry is user-readable, but it overstates the replacement. The current code still does not engage adaptive aggregation for some shapes, so "in favor of the adaptive aggregation ... which targets the same high cardinality workloads" is too broad as written.
  • Exact replacement text: Removed the sharded GROUP BY aggregation path. The enable_sharding_aggregator setting is now obsolete: SET enable_sharding_aggregator = ... is still accepted but has no effect on upgraded servers. enable_adaptive_aggregator remains the supported parallel GROUP BY strategy.
Findings

⚠️ Majors

  • [src/Processors/QueryPlan/AggregatingStep.cpp:360-379, tests/queries/0_stateless/04603_adaptive_aggregator.sql:84-106] [dismissed by author -- https://github.com/ClickHouse/ClickHouse/pull/116532#discussion_r3865732367] The PR still presents adaptive aggregation as the full replacement for sharded aggregation, but the admission logic explicitly rejects shapes that the deleted sharded path used to accept: both two-level thresholds at 0, and Nullable / LowCardinality keys. The updated tests even relabel those cases as "not admitted". That means users who explicitly relied on enable_sharding_aggregator = 1 for those query shapes do see a behavioral change beyond "same workload, better algorithm". Either restore support for the remaining shapes, keep a fallback for them, or narrow the PR/changelog/settings text to the exact admitted surface.
  • [tests/queries/0_stateless/04278_parallel_replicas_coordinator_mode_collision.sql:17-31] [dismissed by author -- https://github.com/ClickHouse/ClickHouse/pull/116532#discussion_r3873040431] The rewritten regression no longer exercises the Coordination mode mismatch failure from #106039. Both scalar subqueries now have the same shape and the same inner SETTINGS, so if outer optimize_aggregation_in_order = 1 leaked into both again they would both announce the same mode and ParallelReplicasReadingCoordinator::getOrCreateCoordinator would not throw. The test has become a plain result-correctness query and can pass while the original bug regresses. Please restore one branch that stays Default while the other would become WithOrder under leaked settings, or replace this with a focused EXPLAIN PIPELINE assertion on the read mode.
Final Verdict
  • Status: ⚠️ Request changes
  1. Narrow the replacement claim in the PR/changelog/settings text, or restore coverage for the remaining query shapes that adaptive still rejects.
  2. Restore a focused regression for 04278 that actually fails on a coordinator-mode mismatch.

LLVM Coverage Report

Measured on commit 8b9edfb.

Metric Baseline Current Δ
Lines 88.40% 88.40% +0.00%
Functions 92.00% 92.00% +0.00%
Branches 80.80% 80.80% +0.00%

Changed lines: Changed C/C++ lines covered: 104/106 (98.11%) · Uncovered code

Full report · Diff report

@clickhouse-gh clickhouse-gh Bot added the pr-backward-incompatible Pull request with backwards incompatible changes label Aug 26, 2026
Comment thread src/Core/Settings.cpp Resolved
@clickhouse-gh

clickhouse-gh Bot commented Aug 26, 2026 •

Copy link
Copy Markdown
Contributor

Build profile diff (arm_release)

Comparing 8b9edfb67 with master fbc782498 (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
Binary Master PR Δ
programs/clickhouse-stripped 710.06 MiB 706.97 MiB -3.09 MiB (-0.43%)

Only the stripped binary is compared: the official master build keeps debug symbols while PR builds strip them, so the other binaries differ by construction.

Object file sizes

27 object files changed (-25.38 KiB total), 0 added.

Object file Master PR Δ
src/CMakeFiles/dbms.dir/Processors/QueryPlan/AggregatingStep.cpp.o 531.79 KiB 506.95 KiB -24.84 KiB (-4.67%)

738 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

50 translation units recompiled, 452 s compile time in total, 50 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 +32.1 s (+8%) in total before that adjustment.

Job report

@nihalzp
nihalzp added this pull request to the merge queue Aug 29, 2026
@nihalzp
nihalzp removed this pull request from the merge queue due to a manual request Aug 29, 2026
@nihalzp
nihalzp added this pull request to the merge queue Aug 29, 2026
Merged via the queue into ClickHouse:master with commit b9cec81 Aug 29, 2026
175 checks passed
@nihalzp
nihalzp deleted the remove-sharded-aggregator branch August 29, 2026 02:52
@robot-ch-test-poll3 robot-ch-test-poll3 added the pr-synced-to-cloud The PR is synced to the cloud repo label Aug 29, 2026
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

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Shard-queue cap bypass buffers the whole input on a plain GROUP BY (40x memory)

3 participants