Repository navigation
Faster Adaptive Aggregator - #123531
Merged
Merged
Faster Adaptive Aggregator#123531
Conversation
…tition buffers and per-bucket spill streams
Contributor
|
Workflow [PR], commit [29df2b4] Summary: ✅
AI ReviewSummaryPR #123531 reworks adaptive aggregation around partitioned records, streamed spills, parallel merges, and bucket top-K pruning. The benchmark evidence supports the performance improvements. No actionable findings remain at Final VerdictStatus: ✅ Approve. |
…`ORDER BY count() DESC LIMIT n` in the adaptive aggregation
… instead of spilling them as parts
…ptive aggregation
This was referenced Nov 1, 2026
This was referenced Nov 4, 2026
Merged
qoega
pushed a commit
to qoega/ClickHouse
that referenced
this pull request
Nov 5, 2026
Since ClickHouse#123531 the numbers_mt 400k-700k queries of this test take one of two run times per run on arm CI (about 6.7 or 9.9 ms for 500k) with the same CPU time. numbers_mt opens floor(N / 65409) streams, so these sizes aggregate in 6-10 streams and then fan out to 12 output streams. With max_threads = 4 every size from 300000 rows on reads, aggregates and outputs in 4 streams. Co-Authored-By: Claude Opus 5.5 <[email protected]>
This was referenced Nov 5, 2026
Merged
This was referenced Nov 14, 2026
Merged
This was referenced Nov 16, 2026
9 of 30 tasks
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Related: #111459
ClickBench
hits(100M rows) on AWSc8a.16xlarge(64 cores, one thread per core),FORMAT NULL. Master already runs Adaptive Aggregator. So, the speedups are on top of the runtime improvements of #111459.GROUP BY RegionID:count(DISTINCT UserID)GROUP BY RegionID:sum,count,avg,count(DISTINCT UserID)GROUP BY SearchPhrase:count, whereSearchPhrase <> ''GROUP BY SearchPhrase:count(DISTINCT UserID), whereSearchPhrase <> ''GROUP BY SearchEngineID, SearchPhrase:count, whereSearchPhrase <> ''GROUP BY UserID:countGROUP BY UserID, SearchPhrase:countGROUP BY UserID, minute(EventTime), SearchPhrase:countGROUP BY SearchEngineID, ClientIP:count,sum,avg, whereSearchPhrase <> ''GROUP BY WatchID, ClientIP:count,sum,avgGROUP BY URL:countGROUP BY 1, URL:countGROUP BY ClientIP, ClientIP - 1, ClientIP - 2, ClientIP - 3:countAdditionally, this PR improves GROUP BY spilling for Adaptive Aggregator path significantly. For the same machine at 64 threads with
max_bytes_before_external_group_by = 500 MiB.GROUP BY RegionID:count(DISTINCT UserID)GROUP BY RegionID:sum,count,avg,count(DISTINCT UserID)GROUP BY SearchPhrase:count, whereSearchPhrase <> ''GROUP BY SearchPhrase:count(DISTINCT UserID), whereSearchPhrase <> ''GROUP BY SearchEngineID, SearchPhrase:count, whereSearchPhrase <> ''GROUP BY UserID:countGROUP BY UserID, SearchPhrase:countGROUP BY UserID, minute(EventTime), SearchPhrase:countGROUP BY SearchEngineID, ClientIP:count,sum,avg, whereSearchPhrase <> ''GROUP BY WatchID, ClientIP:count,sum,avgGROUP BY URL:countGROUP BY 1, URL:countGROUP BY ClientIP, ClientIP - 1, ClientIP - 2, ClientIP - 3:countQ30 does not spill for Adaptive Aggregator because the algorithm uses less memory than 500 MiB.
Changelog category (leave one):
Changelog entry (a user-readable short description of the changes that goes into CHANGELOG.md):
GROUP BYqueries with many distinct keys run faster with the adaptive aggregator (enable_adaptive_aggregator, enabled by default). Across 13 ClickBench aggregation queries, speedups reach 2.9x, with geometric mean speedups of 1.62x at 64 threads and 1.47x at 16 threads. The adaptive aggregator's profile events are reworked to match:AdaptiveAggregationGiveUps,AdaptiveAggregationPressureDrainedRecords,AdaptiveAggregationPressureStandDowns,AdaptiveAggregationPressureSweeps,AdaptiveAggregationResidueReleases,AdaptiveAggregationSealNormalizations,AdaptiveAggregationSealedChunks,AdaptiveAggregationSharedTableSpills,AdaptiveAggregationSpillBacklogSheds,AdaptiveAggregationStagedChunkPiecesOverBound,AdaptiveAggregationStagedChunkSplits,AdaptiveAggregationStagedClaimsClosedAtBoundandAdaptiveAggregationStagedRecordsMergedare removed, andAdaptiveAggregationSpills,AdaptiveAggregationSpilledRecords,AdaptiveAggregationSpilledBytes,AdaptiveAggregationFrozenTableSpills,AdaptiveAggregationMergeUnits,AdaptiveAggregationPrunedUnits,AdaptiveAggregationPrunedRecordsandAdaptiveAggregationCountFirstUnitsare added.Workflow [PR]
Sync PR [sync-upstream/pr/123531]
Version info
26.11.1.794-master(included in26.11and later)