Skip to content

Stabilize join_convert_full_to_left_or_right perf test by disable merges - #119175

Merged
alexey-milovidov merged 4 commits into
ClickHouse:masterfrom
UnamedRus:vk/perf-join-convert-full-stable
Sep 12, 2026
Merged

alexey-milovidov merged 4 commits into
ClickHouse:masterfrom
UnamedRus:vk/perf-join-convert-full-stable

Conversation

@UnamedRus

@UnamedRus UnamedRus commented Sep 10, 2026 •

Copy link
Copy Markdown
Contributor

Perf diff just because of merges:

Changelog category (leave one):

  • CI Fix or Improvement

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

Version info

  • Merged into: 26.9.1.1263 (included in 26.9 and later)

…test

The test creates its two tables with `ORDER BY ()`, so there is no primary key
and the pushed-down `uid < 100` predicate is resolved by the automatic column
statistics. Those prune at part level, not at granule level, so the query reads
in full the single part that holds `uid < 100`, and how many rows that is
depends only on how the `INSERT` cut its parts and on how far the background
merge has folded them together.

The reported read amount therefore swung between 2223906 rows (the predicate
still inside an unmerged 1.1M-row part on both sides) and 13343436 rows (a
merged 6.7M-row part), with a merge landing between two runs making one server
report both, so `SelectedRows`, `SelectedMarks`, `ReadCompressedBytes` and the
times derived from them were reported as changed for two identical query plans
- in
https://performance.ci.clickhouse.com/runs/pr-106955-fc873716689ba5717d444b511537455090e21212/tests/join_convert_full_to_left_or_right
the amd shard read 2223906 rows against the arm shard's 13343436, purely
because their merges had progressed differently.

`SYSTEM STOP MERGES` before the `INSERT` keeps the inserted parts as they were
written, and pinning `max_block_size` and `min_insert_block_size_rows` makes the
way they are cut a property of the settings rather than of the number of insert
streams the machine chose: 10 parts of 1048576 rows, the last one 562816, on
every server. The predicate then sits in the first part, `EXPLAIN indexes = 1`
prunes to `Parts: 1/10`, and the query reads 2097152 rows over 256 marks, run
after run - measured over 8 consecutive local runs, 11-24ms each.

`OPTIMIZE TABLE ... FINAL` on both tables fixes the layout just as well, but it
rewrites 10M rows per table during the fill (1.98s against 1.01s) and leaves the
query reading the whole table on every run (20000000 rows, 2442 marks, 50-67ms).
A single-block `INSERT` reaches one part without the rewrite, but holds the
whole block in memory - 343 MiB against 67 MiB - and reads the full table too.

Related: ClickHouse#106955

Signed-off-by: UnamedRus <[email protected]>

Co-Authored-By: Claude Opus 5 (1M context) <[email protected]>
@clickhouse-gh clickhouse-gh Bot added the comp-testing Test content only (no production code). label Sep 10, 2026
@vdimir vdimir added the can be tested Allows running workflows for external contributors label Sep 10, 2026
@clickhouse-gh

clickhouse-gh Bot commented Sep 10, 2026 •

Copy link
Copy Markdown
Contributor

Workflow [PR], commit [0ce9500]

Summary: ✅


AI Review

Summary

This PR stabilizes tests/performance/join_convert_full_to_left_or_right.xml by freezing merges and pinning the insert-side part layout so the benchmark stops comparing different merged-part states across servers. The setup itself looks coherent, but the new explanatory comment contains one factual inconsistency in the quoted row-count ratio.

Findings

💡 Nits

  • [tests/performance/join_convert_full_to_left_or_right.xml:18] The rationale says the amd shard read "a third" of the arm shard's rows, but the quoted numbers (2223906 vs 13343436) are exactly 1/6. Since this comment is the design record for why the setup exists, the ratio should match the numbers.
Final Verdict

✅ The test change looks sound overall. One small comment-accuracy fix is still warranted.

@clickhouse-gh clickhouse-gh Bot added the pr-ci label Sep 10, 2026
that part was still a 1.1M-row one and 13343436 where it had already been
merged into a 6.7M-row one, and a merge landing between two runs made a
single server report both. The comparison then reports a change in
performance for two identical query plans - an amd shard read a third of

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.

The arithmetic in this rationale doesn't match the numbers it quotes: 2223906 vs 13343436 is exactly one sixth, not one third. Since this comment is the design record for why the benchmark setup exists, can you fix the ratio so the explanation stays internally consistent?

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.

n.p.

@clickhouse-gh clickhouse-gh Bot added the external Author is not a member of the ClickHouse organization label Sep 11, 2026
@maxknv maxknv removed the external Author is not a member of the ClickHouse organization label Sep 11, 2026
@clickhouse-gh clickhouse-gh Bot added the external Author is not a member of the ClickHouse organization label Sep 11, 2026
@alexey-milovidov alexey-milovidov self-assigned this Sep 12, 2026
@alexey-milovidov
alexey-milovidov added this pull request to the merge queue Sep 12, 2026
Merged via the queue into ClickHouse:master with commit 716efd4 Sep 12, 2026
175 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 Sep 12, 2026
syoshida20 pushed a commit to syoshida20/ClickHouse that referenced this pull request Nov 1, 2026
`where n.null` is pruned by the automatic column statistics (basic,
null_count) to the one part that holds row 0. The unpinned INSERT writes
8 parts (7 x 130818 + 84274 rows), and a background merge of parts 1-6
into a 784908-row part can complete before `perf.py --stop-merges` stops
merges, which it does only after BOTH servers finished their fill. The
server that fills faster gives that merge more time, so a fill-speed
difference between the two compared binaries decides which layout each
side measures: one server read 784908 rows / 229 marks, the other
130818 / 39, and the dashboard confirmed a +30% regression of query ClickHouse#1
on 11 unrelated PRs in Performance Comparison (arm_release, 4/6), where
the official build used as the reference filled in ~3.9 s vs ~2.7 s.
The confirmation reruns refill the table, so they repeat the asymmetry.

Stop merges for the table before the INSERT and cut the parts by rows
(max_insert_threads = 1, max_block_size = 65536,
min_insert_block_size_rows = 131072, min_insert_block_size_bytes = 0),
then assert the layout (8 parts, 7 x 131072 + 82496) with throwIf, the
same pin as join_convert_full_to_left_or_right.xml (ClickHouse#119175). Queries are
unchanged; query ClickHouse#1 now reads one 131072-row part on every server.

Validated with the official master build and two local servers: the
master XML with the merge allowed to finish reads 784908 rows / 229
marks (3/3); with the pin every trial reads 131072 rows and an OPTIMIZE
is refused; perf.py --stop-merges with one server CPU-throttled gives
784908 vs 130818 on master and 131072 on both servers with the pin;
removing either pin makes the throwIf fail.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
@clickhouse-gh clickhouse-gh Bot added comp-joins JOINs end-to-end (planning hooks + runtime join operators/algorithms). Single bucket to avoid pla... 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-joins JOINs end-to-end (planning hooks + runtime join operators/algorithms). Single bucket to avoid pla... external Author is not a member of the ClickHouse organization 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.

5 participants