Skip to content

Replace the window function performance queries above 1 s with smaller copies - #129627

Merged
egor-click merged 1 commit into
ClickHouse:masterfrom
groeneai:perf-window-functions-disable-and-append
Nov 12, 2026
Merged

egor-click merged 1 commit into
ClickHouse:masterfrom
groeneai:perf-window-functions-disable-and-append

Conversation

@groeneai

@groeneai groeneai commented Nov 5, 2026 •

Copy link
Copy Markdown
Collaborator

Related: #129258

Changelog category (leave one):

  • CI Fix or Improvement (changelog entry is not required)

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

...

Description

From the #129258 audit: the five window_functions_* tests of #122542 (@ Michicosun) had 23 queries with a master median above 1 s on amd and 6 on arm. Three more move with them: many_small_partitions query 3 shares their table, sliding_frames query 10 sits at 1 s and query 9 shares its table.

No existing query's number or text changes: 30 queries are marked disabled="1", 30 copies on smaller data are appended, and the four tables that only the disabled queries read are not created any more (the smaller fills are <table>_v2). The data shapes stay:

  • window_functions_ranking: 0-10 -> 11-21, 7000 partitions of 4500 rows (was 10000), k modulus 449 (was 1009) keeps about ten ties per value.
  • window_functions_many_small_partitions: 0-6 -> 7-13, 15000 days of 3000 rows (was 40000 days).
  • window_functions_qualify: 0-4 -> 5-9, 16M rows (was 30M), moduli scaled to keep the keys per row and 100 rows per group.
  • window_functions_sliding_frames: 2 and 6-10 -> 13-18, smaller row bounds; 9 and 10 on 30M rows (was 60M).
  • window_functions_streaming: 1 -> 14, numbers(25000000) (was 40000000).

Projected from local same-binary runs (8 pinned cores, max_threads = 8) onto the 14-day CI medians, the appended queries take 0.23-0.71 s on amd and 0.27-0.71 s on arm. That saves about 3.9 amd and 2.8 arm runner-minutes per master commit in measured runs, not counting the four larger fills. Both perf servers run this PR's files, so its own perf report shows no "faster" verdict; the appended queries start their own history.

On CI the 14-day master median per-query stat_threshold is about the same at 0.2-0.75 s as at 1-1.5 s (amd 0.013-0.015 vs 0.014, arm 0.007-0.009 vs 0.007). sliding_frames query 18 (the copy of 10) keeps its rare slow runs, investigated separately.

🤖 Generated with Claude Code


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

Version info

  • Merged into: 26.11.1.2138-master (included in 26.11 and later)

…r copies

Since the `disabled` query marker, an existing perf query keeps its number and text,
so each long query is disabled and a copy on smaller data is appended to the same test:

- window_functions_ranking: queries 0-10 disabled, 11-21 appended (7000 partitions of 4500 rows instead of 10000, k % 449 keeps about ten ties per value).
- window_functions_many_small_partitions: queries 0-6 disabled, 7-13 appended (15000 days of 3000 rows instead of 40000 days).
- window_functions_qualify: queries 0-4 disabled, 5-9 appended (16 million rows instead of 30 million, same group size and key multiplicity).
- window_functions_sliding_frames: queries 2, 6, 7, 8, 9, 10 disabled, 13-18 appended (smaller WHERE bounds; 9 and 10 on 30 million rows instead of 60 million).
- window_functions_streaming: query 1 disabled, 14 appended (numbers(25000000) instead of 40000000).

No original query's text or number changes. The four tables that only the disabled
queries read (window_functions_ranking, window_functions_small_partitions,
window_functions_qualify, window_functions_sliding_parts) are not created any more; the
smaller fills are created as <table>_v2. The appended queries project to 0.23-0.71 s on
amd and 0.27-0.71 s on arm (local same-binary ratio applied to the CIDB master medians).

Co-Authored-By: Claude Opus 5.5 <[email protected]>
@groeneai

groeneai commented Nov 5, 2026

Copy link
Copy Markdown
Collaborator Author

cc @egor-click, could you review this and add the can be tested and pr-performance labels so CI runs on both arches? Following the disabled approach from #129366: the 30 window_functions_* queries above 1 s (or sharing their tables) are disabled and appended on smaller data, no existing query number or text changes, and the four tables only the disabled queries read are not created any more.

@clickhouse-gh

clickhouse-gh Bot commented Nov 5, 2026 •

Copy link
Copy Markdown
Contributor

Workflow [PR], commit [f2f190b]

Summary: ✅


AI Review

Summary

Replaces 30 expensive window-function performance queries with smaller appended equivalents, preserving all 50 original query texts and indices. The fixture changes and disabled-query handling are consistent with the current runner; no actionable findings.

Missing context / blind spots
  • ⚠️ The performance jobs were skipped for f2f190b8c8cb04587bb718a5e0eea565c5843b2b. Timing evidence comes from the local measurements described in the PR; runs on both AMD and ARM would independently verify the projected CI durations and measurement noise. Local validation covered XML structure, query preservation, replacement shapes, and fixture references, without executing SQL.
Final Verdict

Status: ✅ Approve. No new inline findings to post.

@clickhouse-gh clickhouse-gh Bot added pr-ci can be tested Allows running workflows for external contributors comp-testing Test content only (no production code). labels Nov 5, 2026
@egor-click

Copy link
Copy Markdown
Contributor

i am not sure about this part, i think longer tests still make sense if they are good, so time alone shouldn’t be a metric

if coverage based selection if tests to run experiment will work, this would not be necessary

correct me if i am understanding this pr wrong

@groeneai

groeneai commented Nov 5, 2026

Copy link
Copy Markdown
Collaborator Author

You read the selection right: the queries were picked by time, from @ Algunenano's ask to reduce queries above 1 s (#129176, #129258). What they measure is kept: each copy runs the same query on less data with the shape it depends on (ranking keeps 7000 partitions and about ten ties per value at 4500 rows per partition instead of 10000, many_small_partitions 3000 rows per day, qualify 100 rows per group), and the originals are disabled, not deleted. If you'd rather keep the long versions until the coverage-based selection results are in, I'll leave this PR as it is; that's for you and @ Algunenano to decide.

@egor-click
egor-click added this pull request to the merge queue Nov 12, 2026
Merged via the queue into ClickHouse:master with commit f9d56ea Nov 12, 2026
548 of 550 checks passed
@robot-clickhouse-ci-2 robot-clickhouse-ci-2 added the pr-synced-to-cloud The PR is synced to the cloud repo label Nov 12, 2026
mosya415 pushed a commit to mosya415/ClickHouse that referenced this pull request Nov 22, 2026
The check of the tests a PR adds or changes (ClickHouse#129330) failed a PR only when
a query's time grows run over run on the tested server. A test whose runs
are noisy without a trend passed its own PR, and in master_head PR mode the
report's own unstable/changed verdict never fails a PR. That is how
system_clusters_replicated_databases (ClickHouse#122223) got in: tested-server
spread (stddevPop / median of its runs) 0.41-2.1 in its PR, now > 0.5 on
both master servers in about 99% of runs and the noisiest test on master.

The check now also fails on an unstable query of such a test:

- PR changes only files under tests/ and the reference is the performance
  reference build of the tested master commit's sources (find_prev_build's
  new third value; a reference of an older commit, as in about a quarter
  of PR jobs, does not count): both servers run the same code built the
  same way, so the report's verdict judges the test; fail on changed_fail
  or unstable_fail of report/all-queries.tsv. A query that failed on the
  reference server and ran only on the tested one is not in that file; it
  is judged by the rule below.
- Any other PR or reference (code changes, the official-build fallback, or
  an older reference): the report measures the PR's change, not the test
  (the floors flag 79% of the heads of the 214 code PRs that changed a
  perf test in 2026-11-12..21, their own speedups). Fail when stddevPop /
  median of the tested server's runs is above 0.5 (at least 5 runs). A
  spread the change causes also fails: after the merge both master servers
  run that code.

The bar 0.5 flags 0.5% of those code-PR heads and 0.2% of quiet tests'
master heads (CIDB backtest), and all 4 jobs of ClickHouse#122223. A query the trend
check already reports gets only its trend row. The reading loop of
find_run_trends moves to read_query_runs, shared by both checks;
run_trend_gate becomes changed_tests_gate.

Validated locally on downloaded job logs (no test of the test
infrastructure): ClickHouse#122223's 4 jobs fail (the old check passes them); the
new tests of ClickHouse#129328, ClickHouse#124553, ClickHouse#131203 (code PRs) and the tests-only
ClickHouse#130763, ClickHouse#129627 pass; the run-trend output is unchanged on all 1754 tests
of 14 jobs.

Related: ClickHouse#100759

Co-Authored-By: Claude Opus 5.5 <[email protected]>
@clickhouse-gh clickhouse-gh Bot added comp-window-functions Window function execution + frame handling (ROW_NUMBER/RANK/LAG/LEAD, frames, partitions, order). and removed comp-testing Test content only (no production code). labels Nov 22, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

can be tested Allows running workflows for external contributors comp-window-functions Window function execution + frame handling (ROW_NUMBER/RANK/LAG/LEAD, frames, partitions, order). pr-ci 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