Repository navigation
Introduce Window Aggregate Function Execution Strategy - #129257
Conversation
|
Workflow [PR], commit [1acc33b] Summary: ✅
AI ReviewSummaryThe PR moves aggregate window evaluation into prefix and recalculation strategies and changes input-block retention. Review of Findings
Missing context / blind spots
Final Verdict |
Build profile diff (arm_release)Comparing ✅ No significant changes. Binary sizes
The official master build is compiled with Object file sizes22 object files changed (+61.16 KiB total), 4 added.
719 more object files are built by the master warmup baseline only (it builds every object-file target, a pull request build only Compile time of recompiled translation units34 translation units recompiled, 83 s compile time in total, 30 of them have a recent master baseline. |
| if (arena && arena->allocatedBytes() > arena_replace_bytes) | ||
| arena = std::make_unique<Arena>(); |
There was a problem hiding this comment.
[P2] Clear the arena when resetting a partition
Both aggregate strategies call recreate from resetPartition, so this condition also changes partition cleanup: allocations from completed partitions now survive until the arena exceeds 16 MiB. Small partitions containing long strings accumulate dead state, and a query with a lower memory limit fails before reaching that cleanup threshold.
SELECT any(repeat('x', 1000)) OVER (PARTITION BY number)
FROM numbers(50000)
SETTINGS max_threads = 1, max_block_size = 1000, max_memory_usage = 10000000
FORMAT Null;This passes on official 26.10.2.103, but the fast-test binary for 1acc33bca18ca8ddd57e180754cdcf8c4e10fd5c throws MEMORY_LIMIT_EXCEEDED in WindowTransform: it would use 14.57 MiB against a 9.54 MiB limit. The base implementation replaces its arena at every partition boundary. Preserve that cleanup separately from the threshold used for rebuilding frames within a partition, and cover this case with a stateless regression test.
An aggregate over only-NULL arguments collapses to `nothing`, whose state has `sizeOfData() == 0`. A zero-byte arena allocation does not advance the arena, so distinct zero-size states allocated back to back share one address. Copying such a state, e.g. the same-frame copy of both window strategies (`AggregateWindowFunctionPrefix`, `AggregateWindowFunctionRecalculate`) through `ColumnAggregateFunction::insertFromWithOwnership`, which is `insertDefault()` followed by `merge(new, previous)`, then trips `chassert(place != rhs)` although the two states are distinct and have no bytes for `mergeImpl` to read or write. Every CI firing of this assertion family since it was added (ClickHouse#103543) is such a zero-size state. The window site is reached for `-State` results since ClickHouse#129257 and, before that, for `any`/`groupArray` over a state column. Refine the predicate once (`IAggregateFunction::isSelfMerge`) and use it at all six assertion sites instead of patching call sites one by one. `mergeImpl` is still called, non-empty states are checked as before, and release builds are unaffected (`chassert` is compiled out there). STID: 2508-3fb0 Co-Authored-By: Claude Opus 5.5 <[email protected]>
Changelog category (leave one):
Changelog entry (a user-readable short description of the changes that goes into CHANGELOG.md):
This patch adds a window aggregate function interface execution strategy and implements
prefixandrecalculatestrategies with dispatch based on the used frame type.Workflow [PR]
Sync PR [sync-upstream/pr/129257]
Version info
26.11.1.1544-master(included in26.11and later)