Skip to content

Revert WindowTransform changes of #123808 - #124640

Merged
Michicosun merged 1 commit into
masterfrom
revert-window-sorted-key-runs
Oct 9, 2026
Merged

Michicosun merged 1 commit into
masterfrom
revert-window-sorted-key-runs

Conversation

@Michicosun

@Michicosun Michicosun commented Oct 8, 2026 •

Copy link
Copy Markdown
Member

Changelog category (leave one):

  • Not for changelog (changelog entry is not required)

Changelog entry (a user-readable short description of the changes that goes into CHANGELOG.md):

I am reworking the WindowTransform state right now. Let's not complicate it with additional changes.


Workflow [PR]
Sync PR [sync-upstream/pr/124640]

Version info

  • Merged into: 26.10.1.1908-master (included in 26.10 and later)

Restores `WindowTransform` and `SlidingIndexes` to their state before
#123808: the `SortedKeyRuns`
peer-run cache in `findPeerRunEnd` and the stateful run search in
`markKeyChangesInRange` are removed, and the window queries are dropped
from the `sorted_key_prefix_runs` performance test. The other users of
`SortedKeyRuns` added by that pull request are kept.

Co-Authored-By: Claude Fable 5.1 <[email protected]>
@clickhouse-gh

clickhouse-gh Bot commented Oct 8, 2026 •

Copy link
Copy Markdown
Contributor

Workflow [PR], commit [90f713b]

Summary: ✅


AI Review

Summary

This PR cleanly reverts the WindowTransform-specific part of #123808, but it also reintroduces the long-leading-key slow path that #123808 removed for window workloads and simultaneously deletes the only in-tree performance queries that would keep that regression measurable. I would not merge it in this form.

Findings

⚠️ Majors

  • [src/Processors/Transforms/WindowTransform.cpp:341; src/Processors/Transforms/Window/SlidingIndexes.cpp:25] The revert switches the window paths back to the stateless getEqualRangeEndAssumeSorted search, so on (a, b)-sorted data with long runs of a and short groups on b we once again re-scan the tail of the a run for every peer group instead of reusing the known prefix run. That is the same user-visible slowdown #123808 fixed for OVER (ORDER BY a, b), GROUPS, and PARTITION BY boundary discovery, so this PR is reintroducing a hot-path regression rather than just simplifying WindowTransform state.
    Suggested fix: keep the SortedKeyRuns-style prefix-run reuse for the window paths in this PR, or land an equivalent replacement in the same change before reverting the current helper.
  • [tests/performance/sorted_key_prefix_runs.xml:12] The three deleted queries are the only in-tree tests/performance coverage for the window workloads slowed down above. Removing them at the same time as the code revert means a future pr-performance run can no longer quantify whether the follow-up rework restores the lost behavior, so the regression disappears from CI instead of staying measurable.
    Suggested fix: keep these three window benchmarks in tests/performance/sorted_key_prefix_runs.xml even if the temporary code revert is necessary.
Tests
  • ⚠️ There is no performance evidence on this PR: the Performance Comparison jobs were skipped because the PR is not labeled pr-performance, and the diff removes the only window benchmarks from tests/performance/sorted_key_prefix_runs.xml. A pr-performance run with those queries intact would close the gap.
Final Verdict
  • Status: ⚠️ Request changes
  • Minimum required actions: preserve the prefix-run reuse for the reverted window paths or land an equivalent replacement in the same PR, and keep the three removed window benchmarks so the regression remains measurable.

LLVM Coverage Report

Measured on commit 90f713b.

Metric Baseline Current Δ
Lines 88.30% 88.30% +0.00%
Functions 91.80% 91.80% +0.00%
Branches 79.70% 79.70% +0.00%

Changed lines: Changed C/C++ lines covered: 29/29 (100.00%) · Uncovered code

Full report · Diff report

@clickhouse-gh clickhouse-gh Bot added the pr-not-for-changelog This PR should not be mentioned in the changelog label Oct 8, 2026
@nihalzp nihalzp self-assigned this Oct 8, 2026
// so the scan will just return the end of the block.
const Int64 peer_group_end_row = findPeerRunEnd(frame_end.block, frame_end.row, rows_end);
const Int64 peer_group_end_row
= getEqualRangeEndAssumeSorted(blocks.blockAt(frame_end.block).materialized_columns, params.order_by_indices, frame_end.row, rows_end, 1 /* nan_direction_hint */);

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

#123808's findPeerRunEnd/SortedKeyRuns reuse was the part that stopped window scans from re-searching the same long leading-key run for every short peer group inside it. Switching this call site back to the stateless getEqualRangeEndAssumeSorted path reintroduces that sorted-prefix slowdown for OVER (ORDER BY a, b) workloads, and the same regression is reintroduced again in src/Processors/Transforms/Window/SlidingIndexes.cpp for peer-group and PARTITION BY boundary discovery. If the ongoing WindowTransform refactor cannot keep the helper verbatim, please preserve the prefix-run reuse here (or land an equivalent replacement in the same PR) instead of merging the regression.

Comment on lines -12 to -14
<query>SELECT sum(x) OVER (ORDER BY a, b) FROM sorted_key_prefix_runs FORMAT Null</query>
<query>SELECT count() OVER (ORDER BY a, b GROUPS BETWEEN 1 PRECEDING AND 1 FOLLOWING) FROM sorted_key_prefix_runs FORMAT Null</query>
<query>SELECT row_number() OVER (PARTITION BY a, b ORDER BY x) FROM sorted_key_prefix_runs FORMAT Null SETTINGS max_threads = 1</query>

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please keep these benchmarks. They are the only in-tree tests/performance cases that exercise the three window paths slowed down by this revert: OVER (ORDER BY a, b), GROUPS, and PARTITION BY a, b ORDER BY x. Dropping them at the same time as the code change means a pr-performance run can no longer quantify whether the follow-up rework restores the lost behavior, so the regression disappears from CI instead of staying measurable.

@clickhouse-gh clickhouse-gh Bot added the comp-window-functions Window function execution + frame handling (ROW_NUMBER/RANK/LAG/LEAD, frames, partitions, order). label Oct 8, 2026
@Michicosun
Michicosun enabled auto-merge October 8, 2026 17:40
@clickhouse-gh

clickhouse-gh Bot commented Oct 8, 2026

Copy link
Copy Markdown
Contributor

Build profile diff (arm_release)

Comparing 90f713b8e with master 83c1e5c74 (stripped binary size, per-symbol sizes and ThinLTO time; object sizes against the warmup build of e73771ba3; compile times per translation unit against the most recent warmup build that recompiled it).

✅ No significant changes.

Binary sizes

programs/clickhouse-stripped: smaller than the master baseline by the known offset between the two builds, so the difference is not shown. A delta that differs from the offset by more than 50% of it is shown, in either direction.

The official master build is compiled with -g and a pull request build is not, and XRay counts debug instructions towards its instrumentation threshold, so master instruments thousands of functions more and its binary is ~0.4% larger no matter what the pull request does.

Object file sizes

14 object files changed (+53.09 KiB total), 0 added.

Object file Master PR Δ
src/CMakeFiles/dbms.dir/Processors/Transforms/MergeJoinTransform.cpp.o 320.70 KiB 356.36 KiB +35.67 KiB (+11.12%)

719 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

8 translation units recompiled, 13 s compile time in total, 8 of them have a recent master baseline.

Job report

@Michicosun
Michicosun added this pull request to the merge queue Oct 9, 2026
Merged via the queue into master with commit f411b96 Oct 9, 2026
152 checks passed
@Michicosun
Michicosun deleted the revert-window-sorted-key-runs branch October 9, 2026 04:43
@robot-clickhouse-ci-1 robot-clickhouse-ci-1 added the pr-synced-to-cloud The PR is synced to the cloud repo label Oct 9, 2026
fm4v added a commit that referenced this pull request Oct 9, 2026
Take the multi-column sorted key run reuse for LIMIT BY, negative LIMIT BY, DISTINCT in order, full_sorting_merge and partial_merge JOIN.
Skip the WindowTransform changes (reverted on master by #124640) and the ReplacingSortedAlgorithm run skipping (needs the batch sorting queue, absent in 26.8).

Fixes the LIMIT BY regression from #106502 reported in #123700
fm4v added a commit that referenced this pull request Oct 9, 2026
Take the multi-column sorted key run reuse for LIMIT BY, negative LIMIT BY, DISTINCT in order, full_sorting_merge and partial_merge JOIN.
Skip the WindowTransform changes (reverted on master by #124640) and the ReplacingSortedAlgorithm run skipping (needs the batch sorting queue, absent in 26.9).

Fixes the LIMIT BY regression from #106502 reported in #123700
alexey-milovidov added a commit that referenced this pull request Oct 16, 2026
- Resolve the `TODO: wait for the revert-of-revert.` on #123808: #124640
  reverted only its `WindowTransform` part and no re-apply is planned, so
  the window functions are dropped from the entry instead.
- Sort every category by significance, clustering related entries.
- Move 21 entries between categories (efficiency entries to
  `Performance Improvement`, user-visible failures to `Bug Fix`, usability
  changes out of `Bug Fix`, new SQL surface to `New Feature`).
- Merge 28 groups of entries describing the same feature or fix, including
  regressions of this release folded into the feature they broke.
- Rewrite entries that described internal classes instead of the
  user-visible effect, and fix backticks and formatting.
- Drop two pure CI/test-build entries from `Build/Testing/Packaging
  Improvement` (#123180, #125593).

Related: #120500

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

comp-window-functions Window function execution + frame handling (ROW_NUMBER/RANK/LAG/LEAD, frames, partitions, order). pr-not-for-changelog This PR should not be mentioned in the changelog pr-synced-to-cloud The PR is synced to the cloud repo

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants