Repository navigation
Conversation
|
Workflow [PR], commit [af50e9d] Summary: ✅
AI ReviewSummaryThis PR moves single-column Final Verdict✅ No new blocking findings. |
|
📊 Cloud Performance Report
Release-transition baseline: compared against the last 26.8 master because no 26.9 master baseline exists at or before the trusted base-commit anchor. This PR reworks single-column LowCardinality GROUP BY aggregation (adding a cross-block dictionary-position cache) and re-enables the inline COUNT optimization for LowCardinality keys. Only clickbench Q13, a single-column string GROUP BY, sits on that path, and its -18.6% improvement is consistent with the change. Every other flag falls outside the code this PR touches: all four tpch_adapted_1_official queries (join/subquery, no LowCardinality), clickbench Q4/Q5 (COUNT DISTINCT with no GROUP BY), and the numeric or multi-key GROUP BYs Q15-Q18/Q30/Q31. These coincide with 2-build baselines whose medians sit at the edges of the known master variance, so they are downgraded to not-sure rather than credited to the PR. clickbench🟢 1 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_officialFlagged queries (4 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
|
6039e7e to
574d449
Compare
574d449 to
05b4641
Compare
Build profile diff (arm_release)Comparing Binary sizes
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
|
| Object file | Master | PR | Δ |
|---|---|---|---|
src/CMakeFiles/dbms.dir/Interpreters/Aggregator.cpp.o |
20.33 MiB | 21.49 MiB | +1.17 MiB (+5.74%) |
src/CMakeFiles/dbms.dir/Interpreters/AggregatedDataVariants.cpp.o |
724.85 KiB | 748.06 KiB | +23.21 KiB (+3.20%) |
737 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
451 translation units recompiled, 4683 s compile time in total, 451 of them have a recent master baseline.
Median compile-time ratio to the baselines is ×1.08 (machine-speed difference or a change affecting every TU); per-TU deltas below are relative to that ratio.
The matched translation units cost +359.1 s (+8%) in total before that adjustment.
00a0bb7 to
18372f3
Compare
18372f3 to
9b063a7
Compare
9b063a7 to
0b84416
Compare
00c1345 to
0f39714
Compare
|
It's doing worse than expected for this query: SELECT count()
FROM
(
SELECT
stackMap.stack AS stack,
sum(stackMap.value) AS value
FROM r0.profiles_v4_replica
ARRAY JOIN stackMap
WHERE
(profileType = 'process_cpu:cpu:nanoseconds:cpu:nanoseconds')
AND (serviceName = 'ebpf.profiler')
AND (label_app_name = 'fl2.service')
AND (timestamp >= '2026-08-18 00:00:00') and timestamp < '2026-08-19 00:00:00'
GROUP BY stack
ORDER BY value ASC
)
SETTINGS max_threads = 1My dictionaries are yuge: That's about 66 million entries in the biggest one if my math is right.
There's a bunch of gains coming from aggregations in #114982 (see #114982 (comment)). Here:
I'll see what can be done about this. |
|
Using the same query as above, but with v3 improvements from #114870: SELECT count()
FROM
(
SELECT
stackMap.stack AS stack,
sum(stackMap.value) AS value
FROM r0.profiles_v4_replica
ARRAY JOIN stackMap
WHERE
(profileType = 'process_cpu:cpu:nanoseconds:cpu:nanoseconds')
AND (serviceName = 'ebpf.profiler')
AND (label_app_name = 'fl2.service')
AND (timestamp >= '2026-08-18 00:00:00') and timestamp < '2026-08-19 00:00:00'
GROUP BY stack
ORDER BY value ASC
)
SETTINGS max_threads = 1
That's pretty much the same as before. Good but not great. |
b96fce6 to
c0285ce
Compare
|
Added a benchmark and an optimization for
|
c0285ce to
913aa4f
Compare
|
Updates to v4 in #114870 + latest #114982 + updates here helped quite a bit. Same query: SELECT count()
FROM
(
SELECT
stackMap.stack AS stack,
sum(stackMap.value) AS value
FROM r0.profiles_v4_replica
ARRAY JOIN stackMap
WHERE
(profileType = 'process_cpu:cpu:nanoseconds:cpu:nanoseconds')
AND (serviceName = 'ebpf.profiler')
AND (label_app_name = 'fl2.service')
AND (timestamp >= '2026-08-18 00:00:00') and timestamp < '2026-08-19 00:00:00'
GROUP BY stack
ORDER BY value ASC
)
SETTINGS max_threads = 1
That's -22s from before, -16% overall. |
|
I backported #88213 and it helped to unlock quite a bit of a drop:
We're down to -57% now. |
|
Bad news: things break down with 64 threads. We are in fact slower with forced parallelism (15s vs 9s):
Without it we're still faster (29s vs 32s). Us running v24.8 doesn't help. I'll see what can be backported and then improved upon. |
|
With 50f21458f56e backported and updates from #114982, we're down to this with 64 threads:
That's -54% runtime, -56% memory usage (-52GiB!). That's more like it. For 1 thread, the time is still great:
|
|
See also: #115925. |
|
I split off #115961 as a separate PR to keep things more bite sized for review/merge purposes. |
913aa4f to
f736e40
Compare
This establishes the baseline performance of plan vs low-cardinality: | Width | Plain | LC before | LC speedup over plain | |-----------------|----------:|----------:|----------------------:| | `UInt8` | 0.0565 s | 0.1220 s | 0.46x | | `UInt16` | 0.1019 s | 0.1703 s | 0.60x | | `UInt32` | 0.1923 s | 0.1884 s | 1.02x | | `UInt64` | 0.2476 s | 0.1952 s | 1.27x | | `UInt128` | 0.5048 s | 0.5676 s | 0.89x | | `UInt256` | 1.0715 s | 0.9354 s | 1.15x | | `String` (6 B) | 0.5487 s | 0.2535 s | 2.16x | | `String` (26 B) | 0.6871 s | 0.2521 s | 2.73x | | `String` (56 B) | 0.8557 s | 0.2689 s | 3.18x |
f736e40 to
d643c52
Compare
|
There were some fairly significant conflicts with #96630 and #115604. cc @thevar1able to see if I botched it. I validated the improvement in the description and it still holds. |
Previously dictionary position to aggregate state mappings were only valid within a block. For parts where there's only a single dictionary, this is too restrictive and resulted in repeated work. This moves the mapping cache to the aggregation method, matching its lifetime to the aggregation hash table. We keep the successful mappings while the dict remains unchanged. Non-shared dictionaries remain block local. This gives a very nice speedup to the benchmark in the previous commit: | Width | LC before | LC after | Change | |-----------------|----------:|----------:|-------:| | `UInt8` | 0.1220 s | 0.1158 s | -5.1% | | `UInt16` | 0.1703 s | 0.1395 s | -18.1% | | `UInt32` | 0.1884 s | 0.1489 s | -20.9% | | `UInt64` | 0.1952 s | 0.1513 s | -22.5% | | `UInt128` | 0.5676 s | 0.5649 s | -0.5% | | `UInt256` | 0.9354 s | 0.9206 s | -1.6% | | `String` (6 B) | 0.2535 s | 0.1598 s | -37.0% | | `String` (26 B) | 0.2521 s | 0.1630 s | -35.4% | | `String` (56 B) | 0.2689 s | 0.1655 s | -38.5% | The benefit is largest when many blocks share the same dictionary, because dictionary-position mappings are reused across those blocks.
d643c52 to
af50e9d
Compare
|
See also: #115925. |
|
Marking as draft as #115925 appears to be a better approach. |









Previously dictionary position to aggregate state mappings were only valid within a block. For parts where there's only a single dictionary, this is too restrictive and resulted in repeated work.
This moves the mapping cache to the aggregation method, matching its lifetime to the aggregation hash table. We keep the successful mappings while the dict remains unchanged. Non-shared dictionaries remain block local.
This gives a very nice speedup to the benchmark in the previous commit:
UInt8UInt16UInt32UInt64UInt128UInt256String(6 B)String(26 B)String(56 B)The improvements for UInt128 and UInt256 will be there after #114982 is merged.
The benefit is largest when many blocks share the same dictionary, because dictionary-position mappings are reused across those blocks.
AI assisted, scratching an itch I've had for a while.
Changelog category (leave one):
Changelog entry (a user-readable short description of the changes that goes into CHANGELOG.md):
Improve aggregation performance by reusing LowCardinality aggregation mappings across blocks.
Workflow [PR]
Sync PR [sync-upstream/pr/114993]