Skip to content

Make the clickbench_parquet_short fixture identical on both perf servers - #125513

Merged
alexey-milovidov merged 2 commits into
ClickHouse:masterfrom
groeneai:groeneai/clickbench-parquet-short-deterministic-fixture
Oct 13, 2026
Merged

alexey-milovidov merged 2 commits into
ClickHouse:masterfrom
groeneai:groeneai/clickbench-parquet-short-deterministic-fixture

Conversation

@groeneai

@groeneai groeneai commented Oct 12, 2026 •

Copy link
Copy Markdown
Collaborator

Related: #125105

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

The clickbench_parquet_short performance test now writes the same fixture file on both compared servers.

Description

clickbench_parquet_short query 5 (WHERE UserID = 435090932899640449) is reported slower or faster on PRs that do not touch Parquet, e.g. #125105 (3.8 ms -> 5.1 ms).

Each perf server writes its own copy of the fixture. With the profile's max_threads = 12, generateRandom(...) LIMIT 1000000 runs 12 parallel streams and keeps whichever blocks arrive first, so the two copies differ. Since #120907 this query is answered from the bloom filters of the 16 row groups alone. When one copy has a bloom filter false positive for the constant, that server reads and decodes one UserID dictionary page on every run. All five results with a difference above 20% since 2026-10-11 show it: 33 decoding tasks instead of 32 on the slow side.

The generator now runs in a subquery as one stream of fixed 50000-row blocks (max_threads = 1, max_block_size = 50000, preferred_block_size_bytes = 0), so the file depends neither on thread scheduling nor on block-size defaults; its 20 row groups are the 50000 rows output_format_parquet_row_group_size asks for (was 16 of 66180). The outer INSERT keeps the parallel Parquet encoding. The queries are unchanged, so their history and thresholds stay. Sibling generateRandom fixtures (parquet_read, parquet_read_with_index, orc_tuple_field_prune) only feed unfiltered scans and stay as they are.

Validation with official master 26.10.1.2232: the old fill wrote a different file on each of 6 fills. The new one writes one file at max_threads 1-64 and with max_block_size, preferred_block_size_bytes and max_insert_threads varied, also on two concurrently filled servers. The fill takes about 1.3 s per server instead of 0.8 s; query 5 is still answered from the bloom filters alone (~4 ms). On two servers, a copy with the false positive ran query 5 6-28% slower than a clean copy (median of 200 runs, both server orders); identical copies were within 1%.


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

Version info

  • Merged into: 26.10.1.2301-master (included in 26.10 and later)

Each performance-comparison server writes its own copy of the fixture with
`generateRandom(...) LIMIT 1000000`. With the profile's `max_threads = 12` the
generator runs as 12 parallel streams and `LIMIT` keeps whichever blocks arrive
first, so the two copies have different content.

Since the bloom filter is checked before the dictionary page, query 5
(`WHERE UserID = <constant absent from the data>`) is answered from the bloom
filters of the 16 row groups alone. When one copy has a bloom filter false
positive, that server reads and decodes one `UserID` dictionary page on every
run (33 decoding tasks instead of 32, ~530 KB more read), which is +25-40% on a
~4 ms query and is reported as a regression (or an improvement) of an unrelated
PR.

Run the generator in a subquery with `max_threads = 1`. The outer `INSERT`
keeps the parallel Parquet encoding, so the fill stays at ~1.3 s per server,
and both servers write byte-identical files. The queries are unchanged.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
@groeneai groeneai added can be tested Allows running workflows for external contributors groeneai-origin-request PR origin: a maintainer pinged or directed groeneai labels Oct 12, 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; 0 findings) plus my own review of the same head: no findings. Checked: the generateRandom stream seeding and shared limit (StorageGenerateRandom::read), the per-server fixture copies and the shared test XML in the perf harness, the subquery-scoped max_threads leaving the Parquet encoding parallel, and the sibling perf fixtures (unfiltered scans only).

Session id: cron:clickhouse-review-slot-10:20261012-212800

@groeneai

Copy link
Copy Markdown
Collaborator Author
Pre-PR validation gate (click to expand)
# Question Answer
a Deterministic repro? Yes, by file content. The old fill wrote a different file on each of 6 clickhouse local fills and on each server of 3 concurrent two-server fills. A copy with a bloom filter false positive gives 33 decoding tasks for query 5 on 5/5 runs, a clean copy 32 on 5/5.
b Root cause explained? max_threads = 12 makes generateRandom(...) LIMIT 1000000 keep whichever parallel blocks arrive first, so each server writes different data. Query 5 is answered from bloom filters, and a false positive in one copy makes that server decode one UserID dictionary page on every run.
c Fix matches root cause? Yes: the generator runs as one stream, so both servers write the same file. No threshold, query or data-size change.
d Test intent preserved / new tests added? Yes: same queries, same 16-row-group layout, query 5 still measures the bloom filter path. The change is to the test itself, so no extra test.
e Both directions demonstrated? Old fill: copies differ (local, two servers, perf.py), and a false-positive copy is 6-28% slower (p50 of 200 runs). New fill: one md5 on 14 files from clickhouse local, two servers and perf.py; identical copies within 1%.
f Fix is general across code paths? The main run and both confirmation reruns use the same <fill_query>. Other perf tests with a parallel generateRandom fixture have no data-dependent pruning query.
g Fix generalizes across inputs (params/datatypes/wrappers)? Same file at max_threads 1, 12, 16 and 64. Both servers run the PR's copy of tests/performance.
h Backward compatible? (maintainer-approved exception only) N/A, test-only.
i Invariants and contracts preserved? Both servers read byte-identical fixtures; row count and row-group sizes are unchanged.

Session id: cron:clickhouse-impl-slot-5:20261012-211100

@clickhouse-gh

clickhouse-gh Bot commented Oct 12, 2026 •

Copy link
Copy Markdown
Contributor

Workflow [PR], commit [f0cecf5]

Summary: ✅


AI Review

Summary

This PR makes clickbench_parquet_short generate its fixture as a single stream of fixed 50000-row blocks, which removes the scheduler- and block-size-dependent divergence that was making Q19 noisy today. That fixes the previous chunk-boundary issue, but the benchmark still does not guarantee that the PR and reference servers read the same Parquet fixture.

Findings
  • ⚠️ Major — [tests/performance/clickbench_parquet_short.xml:30] tests/performance/scripts/perf.py:887 still runs every <fill_query> on both connections, so this test writes one Parquet file with the PR binary and another with master. The new inner SETTINGS make the fill deterministic within one build, but they do not keep the compared row groups / bloom filters identical when a PR changes generateRandom or Parquet serialization. Suggested fix: materialize the fixture once and reuse or copy the same file for both servers instead of having each build execute INSERT INTO FUNCTION file(...) on its own.
Final Verdict

⚠️ One benchmark-invariant issue remains: the fixture generation is deterministic within each build now, but the comparison still is not guaranteed to read the same Parquet file on both sides.

@clickhouse-gh clickhouse-gh Bot added the pr-ci label Oct 12, 2026
@clickhouse-gh clickhouse-gh Bot added the comp-testing Test content only (no production code). label Oct 12, 2026
`max_threads = 1` makes the fixture independent of thread scheduling, but its
content still depended on the block-size defaults: `generateRandom` shrinks
`max_block_size` to `preferred_block_size_bytes` divided by its row-size
estimate (16545 rows here), its random stream is consumed block by block, and
the Parquet writer cuts row groups at block boundaries (16 groups of 66180
rows). A change to either default or to the estimate would give the two
servers different files again. Pinning `max_block_size` alone does nothing,
because the bytes-based correction still applies.

Generate fixed 50000-row blocks with `preferred_block_size_bytes = 0`. The file
is now the 20 row groups of 50000 rows that
`output_format_parquet_row_group_size = 50000` asks for, and its md5 is the same
for every `max_threads`, `max_block_size`, `preferred_block_size_bytes` and
`max_insert_threads` value tried. Query 5 still skips every row group by its
bloom filter.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
<!-- The generator runs as one stream of fixed 50000-row blocks (one per row group), so both servers write
byte-identical files; otherwise Q19's work depends on bloom filter false positives in each server's copy. -->
<fill_query><![CDATA[
INSERT INTO FUNCTION file('test_clickbench_hits.parquet', Parquet)

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.

tests/performance/scripts/perf.py:887 still executes every <fill_query> independently on each connection, so this benchmark still materializes one Parquet file with the PR binary and another with master. Pinning max_threads and the source block size removes the current scheduler/block-size noise, but it still does not make the compared fixtures identical when a PR changes generateRandom or Parquet serialization itself: Q19 can then compare different row-group / bloom-filter contents again for the same reason as before.

If the invariant here is really “the same fixture on both perf servers”, the file has to be generated once and reused on both sides (or copied from one side to the other) instead of letting each build run INSERT INTO FUNCTION file(...) separately.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Totally irrelevant.

@alexey-milovidov
alexey-milovidov added this pull request to the merge queue Oct 13, 2026
@alexey-milovidov alexey-milovidov self-assigned this Oct 13, 2026
Merged via the queue into ClickHouse:master with commit 5c6ba8f Oct 13, 2026
177 checks passed
@robot-clickhouse robot-clickhouse added the pr-synced-to-cloud The PR is synced to the cloud repo label Oct 13, 2026
@clickhouse-gh clickhouse-gh Bot added comp-formats Input/output formats (CSV/JSON/Parquet/ORC/Arrow/Protobuf/etc.). and removed comp-testing Test content only (no production code). labels Nov 22, 2026
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-formats Input/output formats (CSV/JSON/Parquet/ORC/Arrow/Protobuf/etc.). groeneai-origin-request PR origin: a maintainer pinged or directed groeneai 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