Skip to content

Run the short and variable-length string joins of hash_join_with_row_store_strings on smaller tables - #131570

Merged
Algunenano merged 2 commits into
ClickHouse:masterfrom
groeneai:groeneai/perf-hash-join-row-store-strings-smaller
Nov 18, 2026
Merged

Algunenano merged 2 commits into
ClickHouse:masterfrom
groeneai:groeneai/perf-hash-join-row-store-strings-smaller

Conversation

@groeneai

@groeneai groeneai commented Nov 14, 2026 •

Copy link
Copy Markdown
Collaborator

Related: #129258

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

...

Description

From the #129258 audit: all 6 queries of hash_join_with_row_store_strings (#125979) take more than 1 s on amd master (MasterCI medians since 2026-11-10: 1311-2502 ms on amd, 788-1403 ms on arm).

No existing query number or text changes: 2 queries (4 with substitutions) are disabled and appended on smaller tables; the tables only the disabled queries read are no longer created.

  • The short-string and variable-length-string joins (0-3 -> 10-13, after the long-string queries 6-9 from Add long String columns with and without statistics to the hash join row store perf test #132249) run on 3M-row builds and a 30M-row probe (was 10M / 100M). The probe stays 10 times the build, so the match rates, the output rows per build row and the runtime-filter state are unchanged.
  • The Nullable(String) join (4, 5) keeps its 10M-row build: with a 100 MiB L3 its row store speedup at match rate 0.9 falls from 1.86x at 10M rows to 1.29x at 3M, so these 2 queries stay above 1 s on purpose.

With a 100 MiB L3 (Intel CAT, 8 pinned cores, one release build) the row store is still 1.32-1.87x faster than enable_hash_join_row_store = 0 for the appended queries at 3M rows, against 1.51-2.44x for the originals at 10M (#125979's CI runs showed 1.48-2.29x on amd). Each copy builds the row store with the parallel layout and keeps its original's result/probe ratio (ProfileEvents), and perf.py --print-queries gives master's first 10 entries byte for byte.

Projected onto the CI medians the appended queries take 0.39-0.71 s on amd and 0.24-0.42 s on arm, which saves about 60 s of amd and 36 s of arm query time per master commit. The table setup time does not change, because the Nullable join still reads the 100M-row probe. The appended queries start their own history.

🤖 Generated with Claude Code


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

Version info

  • Merged into: 26.11.1.2700-master (included in 26.11 and later)

…er tables

Disable the short-string and variable-length-string joins (0-3) and append them on
3M-row builds and a 30M-row probe (6-9). With a 100 MiB L3 (CAT) the row store stays
1.32-1.87x faster at 3M rows (1.51-2.44x at 10M). The Nullable(String) join keeps its
10M-row build: at 3M its 0.9-match speedup falls from 1.86x to 1.29x.

Related: ClickHouse#129258

Co-Authored-By: Claude Opus 5.5 <[email protected]>
@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 cold review (1 nit).

# Sev Finding Verdict Evidence / action
1 💡 The description says the table setup time does not change, although two 10M-row string fills become 3M-row fills and a 30M-row probe fill is added DISAGREE Measured locally on one release build: the create stage takes 8.8 / 9.5 s with the master file and 8.7 s with this one; the 100M-row probe fill stays because the kept Nullable(String) join reads it

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

Session id: cron:clickhouse-review-slot-10:20261114-084000

@groeneai

Copy link
Copy Markdown
Collaborator Author

cc @egor-click, could you review this? Disable the short and var-length string joins of hash_join_with_row_store_strings and append them on 3M-row builds with a 30M-row probe

@groeneai

Copy link
Copy Markdown
Collaborator Author
Pre-PR validation gate (click to expand)
# Question Answer
a Deterministic repro? N/A as a bug (perf-test cost change). The cost is measured: MasterCI medians since 2026-11-10 of 1311-2502 ms on amd for all 6 queries, and local same-binary passes of the old file (1.1-2.2 s per query).
b Root cause explained? Each query joins a 100M-row probe to a 10M-row string build and produces 60-90M rows. Queries cannot be edited (series rule: never change or renumber), so the expensive ones are disabled, smaller copies are appended, and the tables only disabled queries read are not created.
c Fix matches root cause? Yes. No bound, setting, kept query or kept fill changes; only the setup the disabled queries alone read is removed.
d Test intent preserved / new tests added? Each copy keeps its original's row store decision, parallel layout, no spill, result/probe ratio and runtime-filter state (ProfileEvents), and keeps the row store speedup at a CI-sized 100 MiB L3 (1.32-1.87x at 3M rows vs 1.51-2.44x at 10M). The Nullable(String) join keeps its 10M-row build because at 3M it loses more than half of that speedup. No new test: this file is the test.
e Both directions demonstrated? Old vs new per query on the same binary and rig, two CAT cycles with and without the row store; the perf.py --print-queries shape check passes on the new file and fails on six mutations.
f Fix is general across code paths? All 3 query elements of the file were measured; 2 are replaced, 1 is kept with the measured reason above.
g Fix generalizes across inputs (params/datatypes/wrappers)? Covered by the file's own matrix, unchanged: inline short strings, variable-length out-of-line strings, Nullable(String), match rates 0.9 / 0.6.
h Backward compatible? (maintainer-approved exception only) Yes: no setting, product code or perf.py change; every existing query number and text is unchanged.
i Invariants and contracts preserved? The first 6 expanded entries equal master's, only enabled entries run (none of 0-3 appears in either query_log), and every table an enabled query reads is created, filled and dropped.

Session id: cron:clickhouse-impl-slot-5:20261114-081001

@clickhouse-gh

clickhouse-gh Bot commented Nov 14, 2026 •

Copy link
Copy Markdown
Contributor

Workflow [PR], commit [f60ad95]

Summary: ✅


AI Review

Summary

The PR reduces the short-string and variable-length-string join fixtures to 3 million build rows and 30 million probe rows, preserving existing performance history and the larger Nullable(String) cases. The current diff and prior discussion reveal no actionable findings. The fixture validation confirms unchanged query texts and indexes 0–9, disabled entries 0–3, appended replacements 10–13, and complete setup and teardown. The reported timing and row-store comparisons support the reduction.

Missing context / blind spots
Final Verdict

Status: ✅ Approve

@clickhouse-gh clickhouse-gh Bot added pr-ci can be tested Allows running workflows for external contributors comp-testing Test content only (no production code). labels Nov 14, 2026
@alexey-milovidov

Copy link
Copy Markdown
Member

@groeneai, perf tests showed nothing.

@groeneai

Copy link
Copy Markdown
Collaborator Author

That is expected for this PR: it changes only the XML, and the comparison runs this XML on both the master binary and the PR binary, which have the same server code. No query can get faster or slower, so an empty report (no changes, no unstable queries) is the right result here.

What changes is the cost of the test itself. Its arm run in this PR, against the master medians of the same queries since 2026-11-12 (207 runs):

query master this PR
short strings, match 0.9 / 0.6 (0, 1 -> 6, 7) 0.80 / 0.77 s 0.22 / 0.21 s
variable-length strings, match 0.9 / 0.6 (2, 3 -> 8, 9) 1.37 / 1.21 s 0.38 / 0.32 s
Nullable(String), kept (4, 5) 1.31 / 1.13 s 1.26 / 1.09 s

One pass over the test's queries goes from 6.6 s to 3.5 s on arm, slightly better than the projection in the description. PR runs compare on arm only, so the amd saving will first show in the master runs after the merge.

@Algunenano Algunenano self-assigned this Nov 17, 2026
@Algunenano

Copy link
Copy Markdown
Member

@groeneai Can you merge master please?

…join-row-store-strings-smaller

# Conflicts:
#	tests/performance/hash_join_with_row_store_strings.xml
@groeneai

Copy link
Copy Markdown
Collaborator Author

Done: merged master in f60ad95.

The only conflict was #132249, which appended two long-string queries to this file and took query indexes 6-9. My appended queries now come after them as 10-13 (CIDB has no history for 10 or above), master's first 10 entries are unchanged byte for byte, 0-3 stay disabled and 10 queries remain enabled. I ran the merged file once on a master release build: all 10 enabled queries ran without errors, the appended ones in 0.30-0.59 s. I updated the index numbers in the description.

@Algunenano
Algunenano added this pull request to the merge queue Nov 18, 2026
Merged via the queue into ClickHouse:master with commit fd1118c Nov 18, 2026
193 checks passed
@robot-clickhouse robot-clickhouse added the pr-synced-to-cloud The PR is synced to the cloud repo label Nov 18, 2026
@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... 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.

4 participants