Skip to content

Make reading_from_file perf test deterministic to reduce noise - #106249

Merged
alexey-milovidov merged 1 commit into
ClickHouse:masterfrom
Algunenano:fix-reading-from-file-perf-noise
Jun 2, 2026
Merged

alexey-milovidov merged 1 commit into
ClickHouse:masterfrom
Algunenano:fix-reading-from-file-perf-noise

Conversation

@Algunenano

@Algunenano Algunenano commented Jun 1, 2026 •

Copy link
Copy Markdown
Member

The reading_from_file performance test is one of the noisiest tests tracked in #100759 (arm 67% / amd 59% noisy in master runs).

Root cause: the fill query SELECT URL FROM test.hits LIMIT 100000 has no ORDER BY, so when the parts are read by multiple threads the LIMIT returns whichever 100000 rows win the read race, and each of the two compared servers ends up with a different subset of URLs in its parquet file. Because base58Encode cost is super-linear in string length, a slightly different (heavier-tailed) subset costs disproportionately more, so one server is persistently slower than the other within a run and the verdict flips randomly across runs.

Evidence from a master self-comparison (old_sha == new_sha): same SelectedRows on both sides, SelectedBytes differs by 9%, but UserTimeMicroseconds and client_time differ by ~2x. Reproduced locally against test.hits: independent runs of the old fill produce 2.53-5.00 MB of URL data and 0.036-0.167s query time, a 4.6x swing; with ORDER BY URL the fill is byte-for-byte identical and the time is constant at ~0.137s.

This is the same class of issue as the apply_patch_parts_join fix in #105527.

ORDER BY URL makes both servers encode the same deterministic subset. The fill query is not measured, so the sort cost is irrelevant.

Changelog category (leave one):

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

Version info

  • Merged into: 26.6.1.314

The fill query `SELECT URL FROM test.hits LIMIT 100000` has no `ORDER BY`,
so with parts read by multiple threads the `LIMIT` returns a different
100000 rows on each server. Because `base58Encode` cost is super-linear in
string length, the two servers get persistently different workloads and the
comparison is frequently reported as `unstable`/`slower`/`faster`.

Add `ORDER BY URL` so both servers encode the same deterministic subset.

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

clickhouse-gh Bot commented Jun 1, 2026 •

Copy link
Copy Markdown
Contributor

Workflow [PR], commit [26949d7]

Summary: ✅


AI Review

Summary

This PR makes tests/performance/reading_from_file.xml deterministic by adding ORDER BY URL to the setup query that writes the Parquet input. The measured query is unchanged, the selected input becomes stable across the compared servers, and the PR metadata uses an appropriate no-changelog-required CI Fix or Improvement category.

Final Verdict

Status: ✅ Approve

@clickhouse-gh clickhouse-gh Bot added the pr-ci label Jun 1, 2026
@alexey-milovidov alexey-milovidov self-assigned this Jun 2, 2026
@alexey-milovidov
alexey-milovidov added this pull request to the merge queue Jun 2, 2026
Merged via the queue into ClickHouse:master with commit e1af953 Jun 2, 2026
166 checks passed
@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.
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.

3 participants