Skip to content

Perf CI: in a PR that changes only tests, do not fail on a query that slows down on the tested server only - #133241

Open
groeneai wants to merge 1 commit into
ClickHouse:masterfrom
groeneai:groeneai/perf-run-trend-reference-rises
Open

groeneai wants to merge 1 commit into
ClickHouse:masterfrom
groeneai:groeneai/perf-run-trend-reference-rises

Conversation

@groeneai

@groeneai groeneai commented Nov 20, 2026 •

Copy link
Copy Markdown
Collaborator

Related: #122537
Related: #129330
Related: #132631

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

The run-trend check (#129330) failed Performance Comparison (arm_release, master_head, 5/8) of #122537, which changes only tests, on insert_select_squashing_dynamic #1: the same 2,000,000 rows inserted into a Null table every run. Tested server: 0.087, 0.091, 0.102, 0.107, 0.114 s (correlation 0.99, last/first 1.31). Reference server: 0.102, 0.103, 0.104, 0.101, 0.107 s (0.50, 1.05).

perf.py runs every query on both servers in the same runs. When a PR changes only files under tests/, both servers run the same server code, so a test whose runs leave more work for the next run slows down both, and a slowdown of the tested server alone comes from that server. In such a PR the check now also requires the reference series to rise, by either of its two bounds (correlation above 0.8 or last/first above 1.2). A query without a reference series, and every PR that changes a file outside tests/, are judged as before.

Either bound, not both: files written by earlier runs slow down both servers unevenly while the disk writes them out. Requiring both would catch number_formatting_formats (before #127695) in 20% of arm jobs instead of 61% (CIDB backtest, 2026-10-08 to 11-19); with either, 61%.

Validated locally on the job's query-runs.tsv and the 537 changed files of #122537: the old check fails, the new one passes, and it fails again with src/Core/Settings.cpp added to the list. Of the 12 failures of the check since its merge, only this one is dropped; the other 11 are read-only queries (#132631). Lost signal: in a PR that changes only tests, a query that slows down on the tested server only.

The alternative is reverting #129330.


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

… slows down on the tested server only

The run-trend check (ClickHouse#129330) judged the tested server's runs of a query
alone. perf.py runs every query on both servers in the same runs, so in a
PR that changes only files under tests/ both servers run the same server
code, and a test whose runs leave more work for the next run slows down
both. A slowdown of the tested server alone is that server's own drift:
on ClickHouse#122537 (tests only), `insert_select_squashing_dynamic ClickHouse#1` inserts the
same 2,000,000 rows into a Null table every run; tested 0.087 -> 0.114 s
(corr 0.99, x1.31, system CPU time 35 -> 69 ms), reference flat (corr
0.50, x1.05).

In such a PR a flagged query now fails only when the reference series
also rises by either of the check's bounds (corr > 0.8 or last/first >
1.2). Either, not both: files written by earlier runs slow down both
servers unevenly while the disk writes them out; requiring both would
have caught number_formatting_formats (before ClickHouse#127695) in 20% of arm jobs
instead of 61%. A query without a reference series, and any PR that
changes a file outside tests/ (the compiler pin, the builder image, CI
scripts and docs included), are judged as before.

Validated locally on the CI job's query-runs.tsv with the PR's real file
list, on the 12 failures of the check since its merge and on 4 known
self-growing tests rebuilt from CIDB query_metric_runs_v1: only the
ClickHouse#122537 failure is dropped.

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

Copy link
Copy Markdown
Collaborator Author
Internal second-model review: 1 finding fixed, 1 nit noted
Finding Verdict
❌ The reference veto keyed on _has_build_digest_changes also applied to PRs that change the compiler image, ci/defs or .gitmodules, which can change the binary AGREE, fixed: the veto applies only when every changed file is under tests/
💡 The README does not say that a query without a reference series is still judged on the tested server alone Noted, not blocking: the PR description says it

@groeneai

Copy link
Copy Markdown
Collaborator Author

cc @leshikus, could you review this? In a PR that changes only files under tests/, the Performance Comparison run-trend check now flags a query only when its reference-server runs also rise (correlation above 0.8 or last/first above 1.2), which drops the false failure on #122537 where only the tested server drifted.

@groeneai

Copy link
Copy Markdown
Collaborator Author
Pre-PR validation gate (click to expand)
# Question Answer
a Deterministic repro? Yes. run_trend_gate on the real query-runs.tsv of Performance Comparison (arm_release, master_head, 5/8) of #122537 with its 537 changed files: master fails with Query insert_select_squashing_dynamic #1 time keeps growing with each run on every run.
b Root cause explained? The check judged the tested server's runs alone. In a PR that changes only files under tests/ both servers run the same server code in the same runs, so the tested server's own drift (system CPU 35 to 69 ms per run, reference flat at x1.05) was read as the test's growth.
c Fix matches root cause? Yes. The reference is used as the control only where it is a valid one (only tests changed, so the same server code), with the check's own two bounds. No threshold widened, no rerun added, no class of test skipped.
d Test intent preserved / new tests added? CI-script change: no test of the test infrastructure (#119766). Validated locally (rows a, e, g); tests/performance/README.md documents the rule.
e Both directions demonstrated? Yes. Master fails, the new check passes; with any path outside tests/ added to the file list (src/Core/Settings.cpp, a submodule, ci/docker/binary-builder/Dockerfile, ci/defs/defs.py, .gitmodules, docs/) it fails again. Mutations (or to and, the tests-only condition replaced by True, no ./ normalization, no filter) each change the verdict they should.
f Fix is general across code paths? find_run_trends has one caller, run_trend_gate; nightly, Iceberg and non-PR jobs never call it. The read-only skip of #132631 is independent and composes.
g Fix generalizes across inputs (params/datatypes/wrappers)? Reference absent, fewer than 5 runs, constant, first time 0, negative correlation with growth above 1.2, correlation just above 0.8; changed files unknown, empty, non-test only, tests only (also with ./ prefixes), with each of 7 paths outside tests/. All 12 failures of the check since its merge and 4 known self-growing tests rebuilt from CIDB: only the #122537 failure is dropped, the 4 self-growing tests stay flagged.
h Backward compatible? (maintainer-approved exception only) CI only. A PR that changes any file outside tests/, and a query without a reference series, are judged exactly as before.
i Invariants and contracts preserved? The filter runs inside the existing try, so an error still fails the check ("could not check"); unknown changed files still return before it. Failure texts, links and the order of find_run_trends results are unchanged.

Session id: cron:clickhouse-impl-slot-6:20261120-131400

@clickhouse-gh

clickhouse-gh Bot commented Nov 20, 2026 •

Copy link
Copy Markdown
Contributor

Workflow [PR], commit [8b4890a]

Summary: ✅


AI Review

Summary

PR #133241, reviewed at 8b4890a150d570d4c8819ea8db51e95d97180008, suppresses performance run-trend failures in PRs changing only tests/ when sufficiently sampled reference-server measurements exceed neither trend threshold. No actionable findings remain after reviewing the current diff, surrounding execution paths, and all prior discussion.

All 16 focused validation checks passed, including replay of the exact archived measurements from the reported failure, reference thresholds, missing samples, changed-path scoping, and malformed input. The added field from find_run_trends is consumed by its sole caller, run_trend_gate; downstream Result, report, and CIDB output retain their existing structure.

Final Verdict

Status: ✅ Approve

@clickhouse-gh clickhouse-gh Bot added pr-ci can be tested Allows running workflows for external contributors manual approve Manual approve required to run CI comp-ci-infrastructure CI/CD pipelines (GitHub Actions, CI scripts, runners). labels Nov 20, 2026

This branch has not been deployed

No deployments
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

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant