Repository navigation
Adaptive Aggregator - #111459
Adaptive Aggregator#111459
Conversation
…threshold` settings
…terpreterSelectQuery`
…m` and `LazyReadReplacingFinalSource`
|
Workflow [PR], commit [cac8fe0] Summary: ✅
AI ReviewSummaryThis PR adds the adaptive Final Verdict✅ No new actionable findings in the current revision. LLVM Coverage Report
Changed lines: Changed C/C++ lines covered: 1580/1936 (81.61%) · Uncovered code |
|
📊 Cloud Performance Report 🔴 AI verdict: This PR rewrites the string hash-table dispatch to reuse a canonical hash across find/emplace/prefetch and adds adaptive aggregation plus bucket-local Top-K, all in the GROUP BY hot path. That lines up cleanly with the results: nine string-keyed aggregation queries improved (ClickBench Q13/Q16/Q17/Q18/Q30/Q31/Q34 by 6-23%, and TPC-H Q7 ×8.0 faster and Q8 ×2.1 faster), each backed by a matching CPU-time reduction. The lone regression, ClickBench Q28 at +5.4%, is small and consistent with adaptive-aggregation staging overhead on that key distribution. No flagged query is off-path, so nothing was downgraded. clickbench🔴 1 regressed · 🟢 8 improved Flagged queries (9 of 43)
Change = percent below ×2; the ratio of medians (×N faster/slower) beyond, where percent understates the scale. q-value = BH-FDR adjusted p; smaller is stronger evidence. MIRAI flags a query when q < fdr_q (default 0.10) — the value the verdict is based on. tpch_adapted_1_official🟢 2 improved Flagged queries (2 of 22)
Change = percent below ×2; the ratio of medians (×N faster/slower) beyond, where percent understates the scale. q-value = BH-FDR adjusted p; smaller is stronger evidence. MIRAI flags a query when q < fdr_q (default 0.10) — the value the verdict is based on. Debug info
|
alexey-milovidov
left a comment
There was a problem hiding this comment.
🕵 Confirmed the remaining feedback is addressed in the current head.
|
@nihalzp @alexey-milovidov — ClickGap found the following in this PR:
Close anything that's wrong or already addressed. |
…ation seal Aggregator::sealPendingChunks coalesces staged mini-chunks by cloning its destination from the first source and then calling prepareForSquashing and insertRangeFrom, both of which assert_cast every source to the destination's class. That assumes all minis share one physical representation per aggregate argument position, and only ColumnConst was stripped. Lazy column replication is decided per block: HashJoinResult materializes the blocks whose replication does not grow the output and leaves the others wrapped in ColumnReplicated. The staging path preserves the wrapper (recursiveRemoveSparse keeps it and ColumnReplicated::index returns a ColumnReplicated), and the frozen kernel receives the raw block columns rather than the unwrapped copies prepareAggregateInstructions builds. So one stream legitimately mixes wrapped and dense columns at the same position and the cast aborts: Bad cast from type DB::ColumnReplicated to DB::ColumnString Received signal Aborted (6) Two sites abort, both reproduced: prepareForSquashing for String, Nullable, Array, Map, Tuple, Variant, Dynamic and Object, and insertRangeFrom for the numeric vectors, which do not override prepareForSquashing. Normalizing the whole sources vector including the front, before the destination is cloned, covers both and keeps destination and sources drawn from the same normalized set. The structureEquals gate leaves the homogeneous case allocation-free, so lazy replication keeps its benefit wherever it is uniform. This mirrors the treatment Squashing already applies to the identical hazard. In a release build assert_cast degrades to static_cast, so the same input reads a ColumnReplicated through a ColumnVector layout and copies from a bogus data pointer instead of failing loudly. Found by CI in Stress test (arm_msan) on an unrelated pull request. The aborting file was added to master by ClickHouse#111459 and is on no release branch, so no backport applies.
`AggregatingTransform::initGenerate` used `many_data->variants.size()` as the
number of producers to wait for on the finish barrier. That vector is sized at
construction and used to be immutable afterwards, but the adaptive aggregation
made the last finisher append the early-drain routing table to it, so the
vector grows while the producers that are still arriving read its size:
Write of size 8 ... by thread T1033:
ClickHouse#7 DB::AggregatingTransform::initGenerate() src/Processors/Transforms/AggregatingTransform.cpp:1375
Previous read of size 8 ... by thread T1187:
ClickHouse#1 DB::AggregatingTransform::initGenerate() src/Processors/Transforms/AggregatingTransform.cpp:1319
Count the producers with `ManyAggregatedData::num_producers`, fixed at
construction time, so the barrier never reads the vector that the last
finisher grows. The barrier's outcome is unchanged: only the finisher whose
`fetch_add` returns `num_producers - 1` proceeds, and it is the only thread
that touches `variants` afterwards.
CI report:
https://s3.amazonaws.com/clickhouse-test-reports/json.html?REF=master&sha=ed4df189fc08473dd6cee5c84b4fce89d49ca640&name_0=MasterCI&name_1=Stress%20test%20%28arm_tsan%29
Caused by: ClickHouse#111459
GROUP BY dies on max_memory_usage inside the adaptive aggregator's own memory valve
#117879
Improved version in: #123531
Changelog category (leave one):
Changelog entry (a user-readable short description of the changes that goes into CHANGELOG.md):
New adaptive algorithm for parallel
GROUP BY(controlled via settingenable_adaptive_aggregator, enabled by default): each thread aggregates into its own hash table until it holdsadaptive_aggregator_freeze_thresholdkeys and then freezes it, so frequent keys keep updating the small cache-resident tables with no coordination, while rare keys are routed by their hash into per-bucket backlogs and aggregated exactly once, inside the bucket-parallel merge.Version info
26.8.1.1465(included in26.8and later)