Skip to content

Make classification perf test deterministic to reduce noise - #106278

Merged
Algunenano merged 1 commit into
ClickHouse:masterfrom
Algunenano:fix-classification-perf-noise
Jun 2, 2026
Merged

Algunenano merged 1 commit into
ClickHouse:masterfrom
Algunenano:fix-classification-perf-noise

Conversation

@Algunenano

@Algunenano Algunenano commented Jun 2, 2026 •

Copy link
Copy Markdown
Member

classification is one of the noisy tests tracked in #100759 (classification #1, arm 14% / amd 10%).

Root cause is the same as #106249 (reading_from_file): the queries select a row subset with LIMIT and no ORDER BY, so when the parts are read by multiple threads each of the two compared servers ends up processing a different set of rows. Because the detect* functions' cost depends on the input phrases, one server is persistently slower than the other within a run and the verdict flips randomly across runs.

Per-run CI data for classification #1 confirms the signature: within each server the runs are stable, but the two servers diverge by up to ~3x (e.g. baseline 3.08s/3.14s vs candidate 9.12s/9.22s on the same master commit), with the slow side alternating.

cityHash64(WatchID) % K = 0 is a reproducible sample that depends only on row contents, so both servers process exactly the same rows. The modulus keeps roughly the original row counts (% 10 for the LIMIT 10000000 queries, % 200 for the LIMIT 500000 ones) and preserves the natural distribution, so the runtime is unchanged. detectTonality already scans the whole table and is not affected, so it is left as is.

Changelog category (leave one):

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

Version info

  • Merged into: 26.6.1.334

The queries used `LIMIT 10000000` / `LIMIT 500000` without `ORDER BY`, so
with parts read by multiple threads each server selected a different set of
rows. Because the `detect*` functions' cost depends on the input phrases, the
two servers got different workloads and the comparison was frequently reported
as `unstable`/`slower`/`faster`.

Replace the `LIMIT` with a reproducible `cityHash64(WatchID)` sample, which
depends only on the row contents so both servers process the same rows. The
modulus keeps roughly the original row counts (`% 10` for the 10M queries,
`% 200` for the 500k ones). `detectTonality` scans the whole table and was not
affected, so it is left unchanged.

Co-Authored-By: Claude Opus 4.8 (1M context) <[email protected]>
@clickhouse-gh

clickhouse-gh Bot commented Jun 2, 2026 •

Copy link
Copy Markdown
Contributor

Workflow [PR], commit [3106271]

Summary: ✅


AI Review

Summary

This PR makes the noisy classification performance test use deterministic row sampling instead of unordered LIMIT. The direction is right, but the current sampling is evaluated inside the measured queries, so the benchmark no longer measures roughly the same work as before. I left one inline comment and recommend changes before merge.

Missing context / blind spots
  • ⚠️ I could not inspect the machine-readable performance-comparison report with .claude/tools/fetch_perf_report.py because clickhouse is not on PATH in this checkout. A focused classification performance run after the sampling change would close the exact runtime/stability evidence gap.
Findings

⚠️ Majors

  • [tests/performance/classification.xml:12] The PR promises to make the selected rows deterministic while keeping the detect* benchmark runtime roughly unchanged, but cityHash64(WatchID) % K = 0 is part of the measured query. Because the predicate is random at row level, essentially every 8192-row mark contains at least one selected row for both % 10 and % 200, so PREWHERE cannot skip SearchPhrase at mark granularity. The sampled queries therefore scan/decompress SearchPhrase for almost all hits_100m_single rows, while the old LIMIT queries stopped after about 10M or 500k input rows. This changes the benchmark target and can add full-table scan cost unrelated to detectLanguage, detectLanguageMixed, detectLanguageUnknown, or detectCharset.
    Suggested fix: materialize the deterministic sample in setup, for example with create_query/fill_query, and run the measured detect* queries over that helper table; alternatively use a deterministic sampling form that can skip ranges before reading SearchPhrase.
Tests
  • ⚠️ Please include or link a focused before/after performance-comparison run for classification showing that the rewritten queries still run in the intended range and that the noisy verdict for classification #1 is reduced without shifting most measured time into scanning/filtering.
Final Verdict

Status: ⚠️ Request changes

Minimum required action: move the deterministic sample out of the measured detect* queries, or provide evidence that the current in-query predicate does not materially change the benchmarked work and resolves the instability.

Comment thread tests/performance/classification.xml Resolved
@Algunenano
Algunenano added this pull request to the merge queue Jun 2, 2026
Merged via the queue into ClickHouse:master with commit c80b92b Jun 2, 2026
166 checks passed
@Algunenano
Algunenano deleted the fix-classification-perf-noise branch June 2, 2026 20:09
@robot-ch-test-poll robot-ch-test-poll added the pr-synced-to-cloud The PR is synced to the cloud repo label Jun 2, 2026
pull Bot pushed a commit to sowelswl/ClickHouse that referenced this pull request Jun 6, 2026
ClickHouse#106278 tried to remove the LIMIT-without-ORDER-BY non-determinism by
sampling with WHERE cityHash64(WatchID) % N = 0. Post-merge master data
showed it did not work: it made the measured queries scan the whole table on
every run, so instead of reducing the noise it regressed it badly:

  classification #0: 6.5% -> 76% noisy
  classification #1:  10% -> 90% noisy

(#2/#3/#4 were already clean.)

Materialize the deterministic subset once into its own single-part table
(single-threaded insert + OPTIMIZE FINAL) and measure over that, so the
determinism lives in the setup (like ClickHouse#106249 for reading_from_file) and the
measured queries read only the subset instead of rescanning the source.
pull Bot pushed a commit to sowelswl/ClickHouse that referenced this pull request Jun 6, 2026
…on-perf-regression

Fix classification perf test regression from ClickHouse#106278
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

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.

2 participants