Repository navigation
Introduce Peers Abstraction for WindowTransform - #125749
Conversation
|
Workflow [PR], commit [41b42f5] Summary: ✅
AI ReviewSummaryThe PR introduces Findings
Tests
Final Verdict |
| if (current.peer_group_index_in_partition != peer_group_start.peer_group_index_in_partition) | ||
| peer_group_start = current; | ||
| checkInvariants(); | ||
| peers.advancePeerGroupBounds(blocks, partition.bounds()); |
There was a problem hiding this comment.
This now computes peer-group ends for every window, including ROWS frames and functions such as row_number or streaming count/sum that never consume those ends. It also replaces direct row access throughout the loop with calls to Peers::current, whose definition is in a separate translation unit. The claimed improvement to pure window functions needs before/after evidence covering these other users of the same hot path.
The PR description has no measurements, the performance dashboard has no runs for this PR, and the AMD comparison jobs were skipped because pr-performance is absent. Please provide a base/head comparison using the existing window_transform and window_functions_streaming benchmarks, covering both cume_dist and the simple ROWS/streaming cases. This would establish that the peer-group optimization pays for the extra work across the affected paths.
4e7160e to
a69b5ed
Compare
9a9fd28 to
41b42f5
Compare
| // scanning forward to the last peer) only when we enter a new peer group; otherwise reuse the | ||
| // cached value. This turns the per-peer-group cost from O(k^2) into O(k). | ||
| if (state.cached_peer_group_number != transform->current.peer_group_index_in_partition + 1) | ||
| if (state.cached_peer_group_number != transform->peers.current().peer_group_index_in_partition + 1) |
There was a problem hiding this comment.
Nit
Peers already maintains the group end, so read peers.bounds().end.row_index_in_partition directly and remove cached_peer_group_number, cached_peer_group_end_row_number, and their reset logic
There was a problem hiding this comment.
Good catch, I didn't refactor window functions yet, so in the current pr no logic changes.
let's do it in a follow-up to speed up the CI runs :)
…-rank-dense-rank-rows-frame-peers Master's ClickHouse#125749 (Peers) and ClickHouse#127389 (general window functions batch execution) removed IWindowFunction.h and made rank() and dense_rank() read bounds.peers_start and bounds.peer_group_index. Port of the same fix onto that interface: - needsSeparateOrderByPeerGroups uses the function's getRequirements().peers (under ROWS only rank() and dense_rank() can require peers, cume_dist() and percent_rank() reject any frame but RANGE over the whole partition), so the needsOrderByPeerGroup virtual is dropped. - The ORDER BY peer group start is tracked in WindowTransform as before and appendCurrentRow passes it as peers_start / peer_group_index, so the rank and dense_rank sources are master's again. - SlidingIndexes is unchanged on master and merged cleanly. 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 combines the current row and peer group into a single peers abstraction to clean up the window transform code and improve the performance of some pure window functions.
Workflow [PR]
Sync PR [sync-upstream/pr/125749]
Version info
26.11.1.78-master(included in26.11and later)