Repository navigation
Use larger groups in the aggregation_in_order_if_null_map performance test - #133621
Conversation
…ce test With groups of 8 rows about 75% of each query is per-group work (the group-end search of in-order aggregation, the `-If`/`-Null` adapters, state create and finalize). Its speed depends on how a build lays out these small hot functions: 73 of 2667 amd builds since 2026-10-26 run one of the six queries 16-35% slower than the rest of the same build, with the same instruction count and one more branch miss per group. That made the test fail on unrelated PRs (ClickHouse#120906: ClickHouse#3 +35%, #0 +27%) with a different query each time. Disable the six queries (their history keys stay) and append them on three new tables: `sumIfOrDefault`, `avgIfOrDefault` and `sumIf` on groups of 1024 rows, `corr` and `argMinIf` on groups of 128 rows and `minIf` on groups of 256 rows. `corr` has the smallest per-group penalty and needs the smaller groups to keep its ClickHouse#118025 guard (~1.10 at 1024 rows). `argMinIf` and `minIf` keep a guard of ClickHouse#122505: reverting its change to the variadic and unary `-If` null adapters slows them 1.21x and 1.28x, while the other `-If` queries move +0.9% to +13.2%. Measured locally with perf.py against the CI reference build: the ClickHouse#120906 build runs the old #0/ClickHouse#3 at 1.31x/1.39x and the new copies at 1.016x/1.020x in the same processes (`sumIf` 1.067x in another run); 7 slow CI builds stay within 6.7% on the new queries (A/A 2.5%), below the 15% minimum change threshold. Restoring the value-initialised `row_end`-sized buffer at each ClickHouse#118025 site master still reaches (`AggregateFunctionSum.h:669`, `AggregateFunctionAvg.h:539`, `SingleValueData.cpp:39`, `AggregateFunctionNull.h:769`) slows its queries 1.2x-1.8x, with identical results. Co-Authored-By: Claude Opus 5.5 <[email protected]>
Internal second-model review (click to expand)Five review rounds (own review + Gate B), last Gate B on this exact tree: 0 findings.
|
|
cc @Algunenano, could you review this? It moves the aggregation_in_order_if_null_map perf test (red on #120906 and on unrelated PRs) from 8-row groups to groups of 1024, 256 and 128 rows, so per-group adapter work no longer dominates and the timings stop depending on the build's code layout, while every #118025 and #122505 buffer site it guards still slows one of its queries by at least 1.2x. |
Pre-PR validation gate (click to expand)
Session id: cron:clickhouse-impl-slot-40:20261122-183700 |
|
Workflow [PR], commit [cba2dac] Summary: ✅
AI ReviewSummaryPR #133621 replaces six layout-sensitive performance queries with larger-group equivalents while preserving their historical indices. The reported cross-build comparisons and per-site regression measurements support the stability improvement and retained regression sensitivity. Review of head Missing context / blind spots
Final VerdictStatus: ✅ Approve |
0f72fc8
Related: #120906 (comment)
Related: #100759
Related: #118025
Related: #127697
Changelog category (leave one):
Changelog entry (a user-readable short description of the changes that goes into CHANGELOG.md):
The
aggregation_in_order_if_null_mapperformance test aggregates groups of 1024 rows (128 forcorrandargMinIf, 256 forminIf) instead of 8, so its timings depend much less on the code layout of a build.Description
Performance Comparison (amd_release, master_head, 1/8)failed on #120906 withaggregation_in_order_if_null_map#3sumIf(y, cn)+35% (#0 +27%), and the test goes red on unrelated PRs with a different query each time. Of 2667 amd builds since 2026-10-26, 73 (2.7%) run one of its queries 16-35% slower than the rest of the same build; a re-run reproduces it.With groups of 8 rows, about 75% of each query is per-group work: finding the group end, the
-If/-Nulladapters, creating and finalizing the state. Its speed depends on how a build places these small hot functions: the #120906 build has the same instruction count and one more branch miss per group.The six queries are disabled (their history keys stay) and appended on three new tables: three on groups of 1024 rows,
corrandargMinIf(the least layout-sensitive) on groups of 128 andminIfon groups of 256, where smaller groups keep their guards. One part per table, 0.18-0.23 s per query.Validation, ratios slow build / reference build in the same server processes: the #120906 build runs the old #0 / #3 at 1.31x / 1.39x and the new copies at 1.016x / 1.020x (
sumIf1.067x in another run); on 7 slow CI builds the new queries stay within 6.7% (A/A 2.5%), below the 15% minimum change threshold. The test still guards #118025: restoring the value-initialisedrow_end-sized flag buffer at each site master still reaches (AggregateFunctionSum.h,AggregateFunctionAvg.h,SingleValueData.cpp,AggregateFunctionNull.h) slows at least one of its queries by 1.2x-1.8x (mutant / master build, same results, A/A within 3%). Reverting the per-group buffer #122505 removed from the-Ifadapters slowsargMinIfby 1.21x andminIfby 1.28x;sumIf, the only other query on these adapters, moves 1.13x on its 1024-row groups.🤖 Generated with Claude Code
Workflow [PR]
Sync PR [sync-upstream/pr/133621]
Version info
26.12.1.222-master(included in26.12and later)