Skip to content

Perf CI: fail a master_head shard only when its own report also calls the query slower - #121090

Closed
groeneai wants to merge 1 commit into
ClickHouse:masterfrom
groeneai:groeneai/perf-gate-require-in-tree-agreement
Closed

groeneai wants to merge 1 commit into
ClickHouse:masterfrom
groeneai:groeneai/perf-gate-require-in-tree-agreement

Conversation

@groeneai

@groeneai groeneai commented Sep 19, 2026 •

Copy link
Copy Markdown
Collaborator

Related: #120927

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

A master_head performance shard now fails on a performance dashboard confirmed_regression only when the shard's own report also reports that query as slower.

Description

#120927 made a master_head shard fail when the performance dashboard classifies any of that shard's slowdowns as confirmed_regression, and removed the in-tree verdict from the decision. The dashboard classifies a single measurement episode; the in-tree verdict carries a per-query bar built from a month of master runs of that exact query (1.5x the p99 of abs(diff), compare.sh:1221). So a chronically noisy micro benchmark reaches the dashboard's highest tier while the job's own report does not call it changed.

On #117122 arm 6/6, three of the four dashboard confirmed_regression rows that shard measured sit 2.5-3.5x below their own historical bar (diff 0.229 vs 0.57, 0.261 vs 0.91, 0.222 vs 0.85); the fourth clears it, and the shard reds on all four. Of the 28 reds in the first 10.5 h, 19 are on shards whose own report published no slower query at all.

The fix makes the two judges agree: a confirmed_regression blocks only when the same (test, query_index) is also slower in this job's own published verdict, recomputed from report/all-query-metrics.tsv, the file the gate already reads and which exports changed_threshold for exactly this purpose. The dashboard is not called when there is no candidate, and a corrupt row fails the check instead of being skipped. pr-120176's tpcds #71 +2225% still fails, checked against the live API.

It also restores the > 10 slower floor that #120927 dropped from master_head (it fired twice in the preceding week); happy to drop those two lines on request. Nothing currently runs ci/tests/, so I will remove the new file there on request.

Not fixed here: the accountability set comes from this attempt's unseeded 10-query sample while the dashboard run merges every attempt, so a re-run can drop a standing verdict.

Replay over every dashboard-gate red in the window (click to expand)

Each row's in-tree verdict is read from that job's own published report.html, and intersected with the live dashboard's confirmed_regression set for the shard's arch. 28 rows: 19 go green, 8 stay red, 1 inconclusive (its report was overwritten by a re-run).

The 8 that stay red, i.e. where both judges name the same query:

PR shard query both judges flag
#120874 amd 1/6, arm 1/6 order_by_read_in_order #1
#119598 arm 6/6 optimize_time_filter_with_preimage #6
#50053 arm 6/6 optimize_time_filter_with_preimage #2, #6
#90740 arm 3/6 bitmap_cardinality #1
#110102 arm 3/6 bitmap_cardinality #4
#117122 arm 6/6 timeseries_to_grid_aggregation_functions #7
#121042 amd 1/6 order_by_read_in_order #1

In all 19 that go green the dashboard names a query the shard's own report did not publish as slower.


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

…s too

The performance dashboard classifies a single measurement episode. The in-tree
verdict classifies the same query against a bar built from a month of master runs
of that exact query: report_thresholds.changed_threshold is
ceil(greatest(0.15, 1.5 * p99(abs(diff)) over master, test_threshold), 2), fetched
by GET_HISTORICAL_TRESHOLDS_QUERY and joined in compare.sh. The two floors differ
by an order of magnitude on chronically noisy micro benchmarks, so the dashboard's
highest tier and the job's own "not changed" regularly disagree.

Measured on PR ClickHouse#117122's arm 6/6 shard, from that job's own report: of the four
dashboard confirmed_regression rows the shard measured,
optimize_time_filter_with_preimage ClickHouse#1 has diff 0.229 against a bar of 0.57,
timeseries_to_grid_aggregation_functions ClickHouse#3 has 0.261 against 0.91 and ClickHouse#8 has
0.222 against 0.85, while ClickHouse#7 (0.271 against the 0.15 floor) clears its bar. The
shard reds on all four. Over the 10.5 h after the gate reached the runners it
produced 28 master_head reds across 20 PRs, and 19 of them are shards whose own
report published no slower query at all.

Require the two judges to agree: a dashboard confirmed_regression blocks only when
the same (test, query_index) is also slower in this job's published verdict.
read_shard_queries becomes read_shard_confirmed_slowdowns and keeps a client_time
row only when diff > changed_threshold and diff >= stat_threshold, which is
compare.sh's changed_fail restricted to a slowdown. Both thresholds are already in
report/all-query-metrics.tsv, the file the gate reads: compare.sh exports them at
fixed trailing positions for exactly this kind of consumer, and the file already
retracts the queries the confirmation rerun demoted. So the predicate reproduces
the report's own slower set rather than approximating it, in one pass over the file
the gate already opens. It does not claim the pairs reproduced on a rerun: that
stage is advisory and fail-open, so an absent demotion can also mean it could not
be computed.

Two consequences of consulting the report first. The dashboard is not queried at
all when the shard reported no slower query, which is the common case, and a
client_time row that cannot be parsed now raises PerfDashboardError instead of
being skipped. The latter turns a corrupt report into a red naming the file rather
than a silent green, matching what the code already did when the report carries no
client_time row at all.

Also restore the > 10 slower count gate for master_head, which the dashboard gate
replaced rather than supplemented; it fired twice in the preceding week, and it now
applies to local runs too, which never call the dashboard.

Verified against the live dashboard API by driving perf_dashboard_gate with the
real numbers of both anchor cases. pr-113385's file_table_function ClickHouse#24 (diff 6.342
under its own 10.72 bar, dashboard confirmed_regression with a 96.6% adaptive
threshold) goes from blocking to not blocking. pr-120176's tpcds ClickHouse#71, the +2225%
regression this gate exists for, keeps blocking; with its bar raised above the
measured diff it stops, so the new conjunct is load-bearing. Replayed over all 28
reds, reading each job's own published report: 19 go green, 8 stay red, 1 had its
report overwritten by a re-run.

Not addressed here: the accountability set is built from this attempt's unseeded
random.sample of 10 expanded queries per test, while the dashboard run is keyed
pr-<N>-<sha> and merges every attempt, so a re-run whose sample misses a flagged
query drops a standing dashboard verdict.

Co-Authored-By: Claude Opus 5 <[email protected]>
@groeneai groeneai added can be tested Allows running workflows for external contributors groeneai-origin-ci-own-pr PR origin: CI on a groeneai PR exposed a separate defect labels Sep 19, 2026
@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 findings from it, plus 2 from my
own cold read of the resulting code). Bounded: 1 full pass + 1 fix round + 1 delta recheck.

# Sev Finding Verdict Evidence / action
1 ❌ Partial dashboard ingestion becomes a clean pass: the readiness probe checks only testTimes, a missing slowdowns field becomes an empty list and a missing tier becomes unknown, so an incomplete verdict leaves the shard green DISAGREE Real, but entirely #120927's and neither reached nor widened here: zero hunk overlap with the cited lines (cited 1595-1604, 1621, 1628-1637, 2584-2589, 2619-2629 against this diff's hunks 156, 163, 1432, 1555-1601, 1614, 1626, 1651-1694, 2800-2830), and the scenario opens with a local slowdown candidate present, in which case the new early return does not fire and the only line changed inside that path, the 1626 membership test, is monotonically restrictive.
2 ⚠️ The new tests are dead: nothing in CI runs ci/tests/, all five pass if main stops setting FAIL, and none covers the restored > 10 slower floor DISAGREE The three sub-claims are true, and I raised the third myself, but "dead" is not: reverting the fix reddens 4 of the 5 cases, and 6 mutation arms each redden at least one against a green baseline. Un-wiring is a property of the directory, not of this file, and removal is contradicted by #115307, merged two hours before this review, which added 5 more ci/tests/ files that no job config references. The description puts the disposition to the reviewer and offers to remove it.
3 💡 The restored > 10 slower floor has no test AGREE, not fixed Every available remedy is scope creep into the block upstream marks this stage is to be removed! at performance_tests.py:2745. Noted, not blocking.
4 💡 .claude/tools/fetch_perf_report.py is a sibling of the same changed_fail predicate DROPPED It already computes abs(diff) >= stat_threshold AND abs(diff) > changed_threshold from the same exported columns, so it is consistent with this fix and needs no change.

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

Not raised as separate work: #1's gap belongs to the dashboard call this PR inherits, I have only a
reading of the code and no observed instance, this gate's per-query rows do not reach the CI database
at all, and the single-shot-fetch defect flagged on #120927 by its own automated review has fired
zero times.

One check beyond the author's: I re-measured the breadth independently at 2026-09-19 21:00Z over a
24 h window and the class is still arriving. 36 job rows across 29 distinct pull requests carry the
new wording, 0 on true master, between 14:02:31Z and 19:40:36Z, and 22 of the 36 report no slower
query of their own, so those go green here without depending on any replay. The description's
19-of-28 figure is the narrower 10.5 h window and understates this.

Session id: cron:clickhouse-review-slot-9:20260919-205400

@groeneai
groeneai requested review from fm4v and maxknv September 19, 2026 21:32
@clickhouse-gh

clickhouse-gh Bot commented Sep 19, 2026 •

Copy link
Copy Markdown
Contributor

Workflow [PR], commit [efa18bc]

Summary: ✅


AI Review

Summary

This PR tightens the master_head performance gate so a dashboard confirmed_regression blocks only when the shard's own report also classifies the same query as slower, and it restores the > 10 slower fallback in the final status computation. The logic is consistent with the exported all-query-metrics.tsv thresholds, but the added regression test is not wired into any in-tree PR job, so the change still lacks enforced automated coverage after merge.

Findings

⚠️ Majors

  • [ci/tests/test_perf_dashboard_gate.py:1] The only regression coverage added for this behavior lives under ci/tests/, but nothing in the repo's workflow/job config references that directory. As a result, PR CI will not execute this test, so neither the new report/dashboard agreement rule nor the restored > 10 slower floor is actually protected after merge.
    Suggested fix: move the test under a suite that already runs on PRs, or add a small PR job that runs it; in either case, add one case that exercises the restored slower-count branch in main.
Tests
  • Local check: python3 -m unittest ci/tests/test_perf_dashboard_gate.py passed (5 tests, 0 failures), but I could not find any in-tree PR workflow or job configuration that executes ci/tests/.
Final Verdict

⚠️ Needs changes. The gate change itself looks internally consistent, but the PR's only regression proof is not enforced by PR CI, so the contract is not actually guarded after merge.

@@ -0,0 +1,136 @@
"""

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.

ci/tests/ does not appear in any in-tree PR workflow or job config, so this new file does not currently buy us enforced regression coverage. That matters here because the PR's contract is "stop false reds without hiding real regressions", but after merge neither the new report/dashboard-intersection rule nor the restored > 10 slower floor will actually be exercised by CI.

Can this live under a suite that already runs on PRs, or can a small job be wired to execute it? If you keep it here, it would also be worth adding one case for the restored slower-count branch, since that behavior changes in main as well.

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.

Confirmed on the wiring: nothing runs ci/tests/. The only mention outside the directory is praktika's __main__ demo in ci/praktika/cache.py, naming a ci/tests/example_1/ that does not exist.

Relocating the file would not close that gap. Praktika selects jobs by a per-job digest, and the stateless one (ci/defs/job_configs.py:172-186) covers ./tests/queries and ./tests/clickhouse-test but not ./ci/jobs/performance_tests.py, so a later PR editing this gate leaves that digest unchanged and the relocated test is served from cache, never run against the edit. The only digest holding this file is the performance job's own (ci/defs/job_configs.py:1614).

Wiring a job is the other option, and that job existed: 8ff3720644b28 removed it by name, together with ci/jobs/ci_tests_job.py and its pull_request.yml entry. Re-adding it is a CI-owner decision rather than part of a perf-gate fix, and I will open it separately if it is wanted. Until then the file keeps the footing the directory has today (#119866 merged this afternoon, #118056 on 2026-09-10, both adding un-wired tests there), runnable exactly the way you ran it, and the description already offers to drop it.

Two last points. It is not the PR's only regression proof: the description carries the replay of the new predicate over the real red jobs, including that #120176's tpcds #71 (+2225%, the regression #120927 was written for) still fails. And I am declining the extra case, because the restored floor is a call into unchanged upstream code (too_many_slow, parse_slower_count, SLOWER_QUERIES_FAIL_THRESHOLD) and my diff only restores the call site #120927 dropped, so one more case in a file nothing executes adds lines rather than protection.

@clickhouse-gh clickhouse-gh Bot added the comp-ci-infrastructure CI/CD pipelines (GitHub Actions, CI scripts, runners). label Sep 19, 2026
This was referenced Sep 22, 2026
@fm4v

fm4v commented Sep 23, 2026

Copy link
Copy Markdown
Member

Closing in favor of #121847, which takes the threshold-fetch timeout fix and warnings from #121189. Noisy queries are handled in the dashboard's confidence scoring instead: https://github.com/ClickHouse/performance-comparison/pull/5

@groeneai

Copy link
Copy Markdown
Collaborator Author

Thanks, that is clear, and I am not asking to reopen this.

One labelled case, in case it is useful for the dashboard's scoring. On #121137 (d315615ee308, an unrelated PR) the four rows the gate blocked on were not attributable to that PR: AggregateFunctionForEach.h has a single translation unit, each gated row is single-arch with the same query flat on the other arch, and the sibling queries in optimize_time_filter_with_preimage and math_sqrt_erf are flat. GET /api/v1/runs/pr-121137-d315615ee3087408522f71aabde0225791008a9c/confidence?metrics=client_time still returns confirmed_regression for three of them today: math_sqrt_erf #7 amd +24.4%, array_first_last #9 arm +21.5%, optimize_time_filter_with_preimage #4 arm +18.5%. The fourth, optimize_time_filter_with_preimage #6 arm +20.8%, has moved from confirmed_regression to likely_regression since 2026-09-22.

I cannot see ClickHouse/performance-comparison#5, so if it is not deployed yet this is only the baseline to re-check against.

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). groeneai-origin-ci-own-pr PR origin: CI on a groeneai PR exposed a separate defect pr-ci

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants