Repository navigation
Refactor Adaptive Aggregator - #120335
Refactor Adaptive Aggregator#120335nihalzp wants to merge 31 commits into
Conversation
…ublishing transforms
|
Workflow [PR], commit [1ca9ad2] Summary: ❌
AI ReviewSummaryThis PR factors adaptive aggregation into a dedicated staging pipeline and adds coverage around completion, spilling, and lifecycle edges. The direction looks reasonable, but the current branch still leaves an already-open pressure/backpressure correctness gap in the coalescing and publisher handshake, and two of the new regression tests do not yet give reliable proof for the refactor, so I would not merge it yet. PR Metadata
Findings
Tests
Final VerdictStatus: Minimum required actions:
|
| current_chunk.clear(); | ||
| has_input = false; | ||
| const auto threshold = params->params.max_bytes_before_external_group_by; | ||
| flush_pending = !coalescer.empty() && threshold && getCurrentQueryMemoryUsage() > static_cast<Int64>(threshold); |
There was a problem hiding this comment.
This re-checks current query memory instead of honoring the producer's earlier under_pressure decision. Aggregator::executeOnBlock forwards a block when under_pressure && adaptive->has_buffered_staging specifically so the coalescer flushes its hidden tail before resumeAdaptiveBlock runs the pressure drain. By the time this code runs the forwarded block's columns may already be released, so getCurrentQueryMemoryUsage() can fall back under the threshold and leave pending_chunks buffered. The producer has already cleared has_buffered_staging on that path, so the subsequent drain sees an empty backlog and those staged bytes stay invisible until another miss or end of input. That weakens max_bytes_before_external_group_by after transient spikes.\n\nPlease latch a force_flush bit from the producer-side pressure decision and flush pending chunks here whenever that bit is set, instead of re-sampling memory after acknowledgement.
| block_size=65536 | ||
| fi | ||
|
|
||
| for payload in count general; do |
There was a problem hiding this comment.
This split-path regression only covers count() and a general aggregate payload. The refactor also changes the zero-column carrier used by GROUP BY k with no aggregates: it still goes through StagedChunk::cut, publishAdaptiveChunk, and the params.aggregates_size == 0 drain fast path, but none of the assertions here would fail if that shape dropped or misrouted keys under pressure splitting.
Please add a third key_only arm that forces AdaptiveAggregationStagedChunkSplits and verifies the exact key set survives.
| 'AdaptiveAggregationPublishTransform') | ||
| AND q.type = 'QueryFinish' | ||
| AND q.current_database = currentDatabase() | ||
| AND q.event_date >= yesterday() AND q.event_time >= now() - 600 |
There was a problem hiding this comment.
The final log assertion groups rows by four fixed log_comment values over a 10-minute sliding window. If this test is retried on the same server within that window, old query_log and processors_profile_log rows from the previous attempt will be folded into the same groups, so the counts stop proving this run's input-port accounting.
Please anchor the query to a per-run watermark or unique suffix instead of event_time >= now() - 600 together with LIKE 'adaptive_input_port_%'.
Build profile diff (arm_release)Comparing Binary sizes
The official master build is compiled with Object file sizes
|
| Object file | Master | PR | Δ |
|---|---|---|---|
src/CMakeFiles/dbms.dir/Interpreters/AdaptiveAggregation/AdaptiveAggregationKernels.cpp.o |
new | 710.38 KiB | +710.38 KiB |
src/CMakeFiles/dbms.dir/Interpreters/AdaptiveAggregation/AdaptiveAggregationDrain.cpp.o |
new | 547.28 KiB | +547.28 KiB |
src/CMakeFiles/dbms.dir/Interpreters/AdaptiveAggregation/AdaptiveAggregation.cpp.o |
new | 257.90 KiB | +257.90 KiB |
src/CMakeFiles/dbms.dir/Interpreters/AdaptiveAggregation/AdaptiveAggregationStaging.cpp.o |
new | 216.97 KiB | +216.97 KiB |
src/CMakeFiles/dbms.dir/Interpreters/AdaptiveAggregation/AdaptiveAggregationPressure.cpp.o |
new | 165.23 KiB | +165.23 KiB |
src/CMakeFiles/dbms.dir/Processors/Transforms/AdaptiveAggregationCoalescingTransform.cpp.o |
new | 91.15 KiB | +91.15 KiB |
src/CMakeFiles/dbms.dir/Processors/Transforms/AdaptiveAggregationPublishTransform.cpp.o |
new | 84.35 KiB | +84.35 KiB |
src/CMakeFiles/dbms.dir/Processors/Transforms/AdaptiveAggregationPartitionTransform.cpp.o |
new | 69.96 KiB | +69.96 KiB |
src/CMakeFiles/dbms.dir/Processors/Transforms/AggregatingTransform.cpp.o |
521.87 KiB | 568.27 KiB | +46.40 KiB (+8.89%) |
src/CMakeFiles/dbms.dir/Interpreters/Aggregator.cpp.o |
20.34 MiB | 20.31 MiB | -35.04 KiB (-0.17%) |
718 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
85 translation units recompiled, 737 s compile time in total, 77 of them have a recent master baseline.
Translation units without a recent master baseline:
src/Interpreters/AdaptiveAggregation/AdaptiveAggregationDrain.cpp: 7.3 ssrc/Interpreters/AdaptiveAggregation/AdaptiveAggregationKernels.cpp: 7.1 ssrc/Interpreters/AdaptiveAggregation/AdaptiveAggregation.cpp: 6.2 ssrc/Processors/Transforms/AdaptiveAggregationPublishTransform.cpp: 5.4 ssrc/Processors/Transforms/AdaptiveAggregationCoalescingTransform.cpp: 5.4 ssrc/Interpreters/AdaptiveAggregation/AdaptiveAggregationPressure.cpp: 5.4 ssrc/Processors/Transforms/AdaptiveAggregationPartitionTransform.cpp: 5.3 s
Symbol sizes
| Binary | Symbol | Master | PR | Δ |
|---|---|---|---|---|
programs/clickhouse-keeper |
DB::Aggregator::executeFrozen(std::__1::vector<COW<DB::IColumn>::immutable_ptr<DB::IColumn>, std::_… |
166.81 KiB | removed | -166.81 KiB (-100.00%) |
programs/clickhouse |
DB::Aggregator::executeFrozen(std::__1::vector<COW<DB::IColumn>::immutable_ptr<DB::IColumn>, std::_… |
166.81 KiB | removed | -166.81 KiB (-100.00%) |
programs/clickhouse |
DB::Aggregator::executeFrozen(unsigned long, unsigned long, DB::AggregatedDataVariants&, std::__1::… |
new | 158.36 KiB | +158.36 KiB |
programs/clickhouse-keeper |
DB::Aggregator::executeFrozen(unsigned long, unsigned long, DB::AggregatedDataVariants&, std::__1::… |
new | 158.36 KiB | +158.36 KiB |
|
The problems are addressed by |
Changelog category (leave one):
Changelog entry (a user-readable short description of the changes that goes into CHANGELOG.md):
...
Workflow [PR]
Sync PR [sync-upstream/pr/120335]