Skip to content

Perf CI: fail a PR when a query of a test it adds or changes gets slower run over run - #129330

Merged
Algunenano merged 4 commits into
ClickHouse:masterfrom
groeneai:groeneai/perf-run-trend-gate-changed-tests
Nov 10, 2026
Merged

Algunenano merged 4 commits into
ClickHouse:masterfrom
groeneai:groeneai/perf-run-trend-gate-changed-tests

Conversation

@groeneai

@groeneai groeneai commented Nov 4, 2026 •

Copy link
Copy Markdown
Collaborator

Related: #100759

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):

Not required: CI-only change.

Description

perf.py runs each query 5-7 times (up to 30) on the same tables without resetting anything. A query changing what its next run reads (a table that grows with each timed INSERT, an UPDATE rewriting its own rows) gets slower run over run and stays noisy on master for weeks: 8 of the last round's 10 noisiest tests in #100759 were this class, all fixed after merge. Nothing stops it today: the PR status ignores slower/unstable rows, and a new test's A/B diff mixes noise with the PR's own change.

In master_head PR runs (not nightly, not Iceberg), Check Results fails when a query of a test the PR adds or changes has, on the tested server, at least 5 runs with corr(run, time) > 0.8 and last/first > 1.2. It reads the job's own analyze/query-runs.tsv (no extra run). One FAIL row per query shows both servers' run times. The check fails closed if the file is missing or has a malformed row; if the changed files are unknown, it adds a workflow warning instead.

Validated on 16 real job logs: on master before #127696 and #127380, polymorphic_parts_m (amd) and iceberg_suite_local_rw_features (amd and arm) are flagged; after them they are not. The PR that added iceberg_suite_local_rw_features (#119147) would have failed on all 8 of its head jobs. On today's master it flags 1 of 273 tests, a query rising every run on both servers.

Limits: it checks only the queries the job runs (at most 10 random ones per test, unless run_all_queries="1"), and a PR runs the amd jobs only with pr-performance or a performance category. It does not catch level shifts, wide spread or rare slow runs, and changed .xml.inc, .sql or .json files are not mapped to the tests that use them.

🤖 Generated with Claude Code


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

Version info

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

groeneai and others added 2 commits November 4, 2026 13:47
…wer run over run

perf.py repeats every measured query on the same tables without a reset. A
query that changes what its next run reads (a growing table, an UPDATE that
rewrites its own rows, a file each run appends to) gets slower run over run
and is then noisy on master for weeks: 8 of the 10 noisiest tests of the last
round in ClickHouse#100759 were this class, all fixed after merge. A PR run could not
notice: its status ignores slower/unstable rows, and the A/B diff of a new
test mixes noise with the PR's own change.

In master_head PR runs (not nightly, not the Iceberg configuration), read the
job's own analyze/query-runs.tsv for the tests the PR adds or changes and fail
Check Results when a query has, on the tested server, at least 5 runs with
corr(run, time) > 0.8 and last/first > 1.2. Only the tested server counts:
after the merge both master servers run that code, and requiring both servers
drops recall to 0.34-0.94 of heads on last round's offenders against
0.60-0.98. One FAIL child per query carries both servers' run times. A missing
file or a malformed row of a changed test fails the check; unknown changed
files add a workflow warning instead. test_discovery.changed_tests is the
selection, which changed_iceberg_tests now reuses.

Validated on 16 real job logs: flagged on master before ClickHouse#127696 / ClickHouse#127380 and
on all 8 head jobs of ClickHouse#119147, not flagged after the fixes, 1 of 273 tests on
today's master (a query rising on both servers).

Related: ClickHouse#100759

Co-Authored-By: Claude Opus 5.5 <[email protected]>
A run-trend row had the same name as a dashboard row of its query, so it was
dropped when the dashboard also flagged that query: Check Results failed with
no trend data shown, and a trend row in turn hid the query's slower/unstable
row. Name it `<test> #<i> run trend`, append every one, and print each to the
job log. The README states the 5-run floor and the 10-query sample of PR jobs.

Related: ClickHouse#100759

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

groeneai commented Nov 4, 2026

Copy link
Copy Markdown
Collaborator Author
Internal second-model review (click to expand)
Finding Verdict
⚠️ A run-trend row was dropped when the dashboard flagged the same query, leaving a failed check without its run times Fixed: the row is named <test> #<i> run trend and is also printed to the job log
⚠️ Only the 10 queries a PR job samples per test are checked Not changed: the measured recall already includes the sampling, and running every query of a changed test adds runs; stated in the description and the README
⚠️ A non-positive run time would skip the series instead of failing Not changed: 0 of 125,802 run times in 16 real job logs are <= 0; times are timer deltas
⚠️ A change to a .sql (or settings .json) file that a test reads with <query file>/<settings file> does not mark the test as changed Not changed: same limit as .xml.inc fragments (27 of ~850 tests use such files); mapping them would also change which PRs run the Iceberg jobs, so it is a separate change; the .xml.inc and .sql cases are stated in the description
💡 README did not state the 5-run minimum Fixed

@groeneai

groeneai commented Nov 4, 2026

Copy link
Copy Markdown
Collaborator Author
Pre-PR validation gate (click to expand)
# Question Answer
a Deterministic repro? Yes. The check is a pure function of a job's analyze/query-runs.tsv; on downloaded CI logs it flags polymorphic_parts_m #0/#2 (amd master 3a62a05) and iceberg_suite_local_rw_features #5 (amd and arm master, 2026-10-16) every time.
b Root cause explained? perf.py repeats each query on the same tables with no reset; a query that grows what its next run reads gets slower run over run on the tested server. Today nothing in a PR run fails on it, so it is found on master after merge.
c Fix matches root cause? Yes. It reads the raw run order of the tests the PR adds or changes in the PR's own job and fails there. No threshold or test is relaxed.
d Test intent preserved / new tests added? Test-infrastructure change, so no self-test (per #119766). Local validation on 16 real job logs plus a harness that drives main() at the check_results stage (35/35 checks).
e Both directions demonstrated? Flagged on master before #127696/#127380 and on all 8 head jobs of #119147, which introduced the test. Not flagged on master after the fixes. A tested-only trend stops being flagged once the two servers' rows are swapped.
f Fix is general across code paths? SQL and shell queries, partial queries (tested server only) and 30-run fast queries are handled the same way. Each test runs in one batch per arch, so every changed test is checked once per arch. The Iceberg jobs are excluded (they do not gate and were not backtested). changed_iceberg_tests reuses the new selection with identical output (243 lists).
g Fix generalizes across inputs (params/datatypes/wrappers)? Not flagged: 4 runs, constant times, a first time of 0, faster run over run, a reference-only trend. Flagged: unordered rows. Malformed rows: a nan time or a truncated row of a changed test fails closed; malformed rows of other tests are ignored. Unknown or empty changed files, .xml.inc fragments and deleted tests are handled.
h Backward compatible? (maintainer-approved exception only) CI only. Master, nightly, release_base, Iceberg and local runs are unchanged, and a PR that changes no perf test reads nothing.
i Invariants and contracts preserved? The check only sets FAIL or appends to the message, so the existing status logic is unchanged. Every error path fails closed. A trend row is named <test> #<i> run trend, so the dashboard and slower/unstable rows of the same query are kept next to it.

Session id: cron:clickhouse-impl-slot-5:20261104-133000

@groeneai

groeneai commented Nov 4, 2026

Copy link
Copy Markdown
Collaborator Author

cc @egor-click, could you review this and add the can be tested label so CI runs? In master_head PR runs, Check Results now fails when a query of a perf test the PR adds or changes gets slower run over run on the tested server (at least 5 runs, corr(run, time) > 0.8, last/first > 1.2), read from the job's own analyze/query-runs.tsv.

@clickhouse-gh

clickhouse-gh Bot commented Nov 4, 2026 •

Copy link
Copy Markdown
Contributor

Workflow [PR], commit [cde1f15]

Summary: ✅


AI Review

Summary

PR #129330, reviewed at cde1f15fd08b9890d613cf0adae014ee0b63bdde, adds a performance CI gate for increasing query execution times in added or modified tests. No actionable findings remain after reviewing the current diff, surrounding execution and reporting paths, and all prior discussion. Fifteen temporary checks passed for trend detection, malformed or missing input, test and shard selection, result details, and Iceberg test discovery.

Final Verdict

Status: ✅ Approve

@clickhouse-gh clickhouse-gh Bot added the pr-ci label Nov 4, 2026
@Algunenano Algunenano self-assigned this Nov 4, 2026
@Algunenano Algunenano added the can be tested Allows running workflows for external contributors label Nov 4, 2026
@clickhouse-gh clickhouse-gh Bot added the comp-ci-infrastructure CI/CD pipelines (GitHub Actions, CI scripts, runners). label Nov 4, 2026
Comment thread ci/jobs/performance_tests.py Outdated

children = [
Result(
name=f"{t['test']} #{t['query_index']} run trend",

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

@groeneai Can we make both the name and the test clearer please? "run trend" isn't clear to me. Something like "Query test#1 time keeps growing/decreasing in each execution" seems better. Also maybe we can point to the larger description in the README too

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

Done in fc513c7. Each row is now named Query <test> #<i> time keeps growing with each run, and its text reads, for example:

Run times on the tested server, s: 1.326, 1.385, 1.46, 1.158, 1.596, 2.368, 2.43; on the reference server: 1.094, 1.269, 1.347, 1.53, 1.365, 2.359, 2.044. Correlation of run number and time 0.82, last run / first run 1.83 (the check fails above 0.8 and 1.2). Usually each run reads what the previous runs changed, for example a table or file that grows; make every run do the same work. See "Queries whose time keeps growing with each run" in tests/performance/README.md.

The README paragraph now has its own section with that heading, and the row links to it. The summary line, the warning and the error message use the same wording.

I kept the check to growing times. The mirror rule for decreasing times would flag 0.94-0.98% of amd and 0.29-0.31% of arm test jobs on master on 11-03 and 11-04 (growing: 0.48-0.53% and 0.32%), mostly read-only tests such as generate_random_json (23% of its amd jobs), clickbench and sort_patterns.

Review on ClickHouse#129330 asked for a clearer name and text than "run trend" and
for a pointer to the README. Each row is now named
"Query <test> #<i> time keeps growing with each run"; its text gives both
servers' run times, the two values against the thresholds, the usual
cause and the README section, and the row links that section. The README
paragraph moves under its own heading so the link has an anchor. The
summary, warning and error strings use the same wording. Which queries
fail is unchanged.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
@clickhouse-gh clickhouse-gh Bot added the manual approve Manual approve required to run CI label Nov 5, 2026
@Algunenano
Algunenano enabled auto-merge November 10, 2026 14:20
@Algunenano
Algunenano added this pull request to the merge queue Nov 10, 2026
Merged via the queue into ClickHouse:master with commit ae69c2a Nov 10, 2026
187 checks passed
@robot-clickhouse robot-clickhouse added the pr-synced-to-cloud The PR is synced to the cloud repo label Nov 10, 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]>
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-ci-infrastructure CI/CD pipelines (GitHub Actions, CI scripts, runners). manual approve Manual approve required to run CI 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