Skip to content

Perf CI: do not fail a PR on the run times of a query that only reads - #132631

Open
groeneai wants to merge 2 commits into
ClickHouse:masterfrom
groeneai:groeneai/perf-run-trend-skip-read-only
Open

groeneai wants to merge 2 commits into
ClickHouse:masterfrom
groeneai:groeneai/perf-run-trend-skip-read-only

Conversation

@groeneai

@groeneai groeneai commented Nov 18, 2026 •

Copy link
Copy Markdown
Collaborator

Related: #100394
Related: #129330

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, 1/8) of #100394 on read_in_order_direct_io #1, SELECT * FROM read_in_order_direct_io ORDER BY key DESC FORMAT Null. Every run read the same rows, bytes and marks with flat CPU time; from the third run the disk read time under min_bytes_to_use_direct_io rose on both servers at the same second. The same step shows in 23 of the 27 arm jobs of that PR since 2026-10-02, 14 of them over the thresholds. All 6 failures of the check since its merge are queries that only read.

A query that only reads cannot change what its next run reads, so the check's premise ("each run reads what the previous runs changed") does not hold for it. The check now skips such queries, using the rule perf.py already applies to stop merges for a read-only test (WRITE_KEYWORDS and first_keyword, now query_writes, which also counts WITH ... INSERT and PARALLEL WITH as writing), per query: perf.py prints read-only <query_index>, compare.sh collects it into analyze/read-only-queries.tsv, find_run_trends skips those queries. Shell queries and queries with INSERT, ALTER, OPTIMIZE, SYSTEM, ... are judged as before.

Backtest on CIDB query_metric_runs_v1 (2026-10-08 to 11-17): 7606 read-only queries were flagged in 0.08% (amd) / 0.03% (arm) of their series, none but read_in_order_direct_io #1 in 10% or more; the 29 writing queries flagged that often (Iceberg write suites, insert_sequential_and_background_merges, polymorphic_parts_*, ...) stay checked.

Validated locally: on the CI job's query-runs.tsv the old check fails and the new one passes; a test whose ALTER UPDATE grows each run still fails; perf.py marks exactly the read-only queries of a mixed test, and stop-merges decides as before for every existing test.

Unlike #131251, this adds no run. The alternative is reverting #129330.


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

groeneai and others added 2 commits November 18, 2026 10:14
The run-trend check (ClickHouse#129330) fails a PR when the time of a query of a
test it adds or changes keeps growing with each run on the tested server.
Its premise is that each run reads what the previous runs changed. A query
that only reads cannot change what its next run reads, so a trend there
comes from the host. On ClickHouse#100394, `read_in_order_direct_io ClickHouse#1` read the
same rows, bytes and marks every run with flat CPU time, while the disk
read time under `min_bytes_to_use_direct_io` stepped up on both servers at
the same second; the same step shows in 23 of 27 arm jobs of that PR. All
6 failures of the check since its merge are read-only queries.

perf.py already decides per test whether the measured queries write, to
stop merges for read-only tests (`WRITE_KEYWORDS`, `first_keyword`). That
predicate is now `query_writes`, and perf.py prints `read-only
<query_index>` for every measured query that does not write. compare.sh
collects the records into `analyze/read-only-queries.tsv`, and
`find_run_trends` skips those queries. Without the file the check behaves
as before; a malformed row of a changed test makes it fail as "could not
check", like a malformed `query-runs.tsv` row. Writing and shell queries
are judged as before, so state growth (Iceberg write suites,
`insert_sequential_and_background_merges`, `polymorphic_parts_*`) is
still caught. No extra run, no threshold change.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
…ites

The first keyword of `WITH y AS (...) INSERT INTO x ...` is `WITH`, and of
`SELECT 1 PARALLEL WITH INSERT INTO t ...` it is `SELECT`, so `query_writes`
called both read-only: the run-trend check skipped them and stop-merges
stopped merges for their tests. No test in tests/performance uses either form.

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

Copy link
Copy Markdown
Collaborator Author
Internal second-model review: adjudication log (click to expand)

Pre-publication review by an independent model (engine: codex; 2 rounds, 1 finding each) plus my own review (2 findings).

# Sev Finding Verdict Evidence / action
1 ⚠️ WITH ... INSERT and PARALLEL WITH write while their first keyword does not (perf.py query_writes) AGREE, fixed statement_writes counts both as writes; no test in tests/performance uses either form, so no current verdict changes
2 ⚠️ PARALLEL /* c */ WITH INSERT ... (a comment inside the compound keyword) still reads as read-only; an INSERT word in a WITH ... SELECT string counts as a write DISAGREE none of the 5068 measured statements in tests/performance uses PARALLEL WITH, and none of the 61 stateless tests that use it puts a comment inside it; matching the bare word PARALLEL would flip 12 real read-only queries (hash_join_layout = 'parallel'). The INSERT-word over-match only means "checked as before"
3 💡 README: "a slower run there comes from the host" is broader than strictly true while merges keep running AGREE, not changed the backtest found no read-only query whose time grows from that
4 💡 REPLACE TABLE / UNDROP TABLE are not in WRITE_KEYWORDS AGREE, not changed neither makes the next run read more; no measured query uses them

Severity: ❌ blocker / ⚠️ major / 💡 nit. DISAGREE verdicts carry recorded evidence and are
terminal per finding.

Session id: cron:clickhouse-review-slot-8:20261118-111500

@groeneai

Copy link
Copy Markdown
Collaborator Author

cc @maxknv, could you review this? The perf comparison run-trend check now skips queries that only read (classified by the write rule perf.py already uses for stop-merges, per query), since a read-only query cannot change what its next run reads; all 6 failures of the check since #129330 were such queries.

@groeneai

Copy link
Copy Markdown
Collaborator Author
Pre-PR validation gate (click to expand)
# Question Answer
a Deterministic repro? Yes. The CI job's own analyze/query-runs.tsv (#100394 @ 1bf7105, arm 1/8) fed to the old run_trend_gate fails on read_in_order_direct_io #1 every time.
b Root cause explained? The check fits a trend to the wall time of every query of a changed test. A query that only reads cannot change what its next run reads, so a trend there is a host level shift: here the disk read time under O_DIRECT stepped up on both servers at the same second while rows, bytes, marks and CPU time stayed the same.
c Fix matches root cause? Yes. The check skips exactly the queries its premise does not cover, using the write rule perf.py already applies for stop-merges. No threshold change, no rerun, no discount.
d Test intent preserved / new tests added? No test of the test infrastructure (#119766), validated locally. Writing queries are judged as before: a local ALTER UPDATE test whose time grows each run still fails.
e Both directions demonstrated? Yes. On the CI job's data: old fails, new passes. Hermetic case: a growing query fails without its read-only row and passes with it.
f Fix is general across code paths? stop-merges uses the same predicate (408 item lists, identical old vs new). Shell queries, query files, substitutions, disabled queries, confirm reruns and every other consumer of the raw output (all select by record type) checked.
g Fix generalizes across inputs (params/datatypes/wrappers)? Comments before the keyword, WITH, lowercase select, multi-statement queries, shell, disabled; writes hidden behind the first keyword (WITH ... INSERT, ... PARALLEL WITH <statement>) count as writes; a missing file; malformed rows (fail closed); rows of tests the PR does not change (ignored).
h Backward compatible? (maintainer-approved exception only) Yes. A workdir without the new file, or raw output without the record, gives today's result. No settings.
i Invariants and contracts preserved? The check still fails closed on a malformed row. The (test, query_index) key is the one of query-runs.tsv. The stop-merges decision of every existing test, thresholds, messages and early returns are unchanged.

Session id: cron:clickhouse-impl-slot-4:20261118-100201

@clickhouse-gh

clickhouse-gh Bot commented Nov 18, 2026 •

Copy link
Copy Markdown
Contributor

Workflow [PR], commit [80920d2]

Summary: ✅


AI Review

Summary

The PR excludes queries classified as read-only from the performance run-trend gate while retaining checks for writing and shell queries. No material findings remain after reviewing the diff, current code, and all prior discussion.

Focused local validation passed: 905 performance XML files, 8,000 enabled query instances, and no changed merge-control decisions. Checks covered mixed queries, grouped statements, WITH ... INSERT, PARALLEL WITH, TSV extraction, missing metadata, and rejection of malformed metadata. The complete server performance pipeline was not run locally.

Output consumers checked: CHServer.run_test preserves the additional record; compare.sh analysis, confirmation, profiling-budget, and error extraction select records by tag; parse_perf_tsv ignores unrelated tags; profile and coverage collection tolerate the added output.

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 18, 2026
alexey-milovidov added a commit that referenced this pull request Nov 20, 2026
The run-trend check of the performance comparison failed on query #1
(`ORDER BY key DESC`) on ARM in two consecutive runs. Rows, bytes and
CPU time are the same in every run. After about four seconds of
continuous `O_DIRECT` reading, the time steps from ~0.61 s to ~0.80 s on
both the tested and the reference server. The AMD runners measure
~0.82 s from the first run. So the first measured runs were faster
than the steady state, not later ones slower. Read the table a few
times in `fill_query` statements so that the measured runs start at
the steady state.

https://s3.amazonaws.com/clickhouse-test-reports/praktika.html?PR=100394&sha=e0bf56ffe49a895ddaff980122a57197002efab1&name_0=PR&name_1=Performance%20Comparison%20%28arm_release%2C%20master_head%2C%208%2F8%29
#100394
Related: #132631

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

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