Skip to content

Add a performance test for hash joins on a single String key - #132288

Merged
Blargian merged 1 commit into
ClickHouse:masterfrom
groeneai:groeneai/perf-hash-join-packed-string-keys
Nov 17, 2026
Merged

Blargian merged 1 commit into
ClickHouse:masterfrom
groeneai:groeneai/perf-hash-join-packed-string-keys

Conversation

@groeneai

@groeneai groeneai commented Nov 17, 2026 •

Copy link
Copy Markdown
Collaborator

Related: #128972

Changelog category (leave one):

  • Not for changelog (changelog entry is not required)

Changelog entry (a user-readable short description of the changes that goes into CHANGELOG.md):

...

Description

Adds tests/performance/hash_join_packed_string_keys.xml, one query for each of the 9 single-String-key shapes requested in #128972 (comment), with the 4 settings given there and enable_packed_string_keys_in_hash_join at its default.

Open choices: a probe row hits when cityHash64(number) % 2 = 0; misses of the 8M build side take ids below 10M, so the short probe keys stay at 1-7 bytes and the mixed ones at 2-40; shapes 8 and 9 put the UNION ALL on the probe side.

Validated on a master release build: results are equal with the setting 0 and 1; with 1, JoinPackedStringKeysInline + JoinPackedStringKeysHashed equal the build rows (0 with 0); counts and sums equal the generators' values (only shape 4 is 0); every sipHash128 argument is a UInt64 on both sides; perf.py runs it green, also with --table-engine iceberg_local; the fill takes 0.55 s. Medians of 5 runs at 16 threads on a 384-core host, not a CI runner:

Shape count Inline / Hashed ms on / off ms on, 8 threads
1 short 9996710 8M / 0 104 / 196 206
2 long 9996710 0 / 8M 134 / 232 225
3 1M keys 9996710 0 / 1M 79 / 98 141
4 no hits 0 0 / 8M 101 / 152 208
5 skewed 20000000 0 / 8M 104 / 208 196
6 mixed 9996710 1973070 / 6026930 117 / 193 209
7 duplicates 19993420 0 / 8M 150 / 234 272
8 256 bytes 7502064 0 / 100K 122 / 127 202
9 20 bytes 15998892 0 / 100K 86 / 91 156

Shapes 3 and 9 run slightly under 0.1 s at 16 threads here; at 8 threads (the perf CI's amd setting, 12 on arm) every shape takes 0.14 to 0.28 s.

🤖 Generated with Claude Code


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

Version info

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

`tests/performance/hash_join_packed_string_keys.xml` has one query for each
of the 9 shapes requested in
ClickHouse#128972 (comment):
short keys (1-7 bytes), 36-byte keys, a 1M-key build side, no probe hits, a
skewed probe, mixed lengths (2-40 bytes), a duplicate build side, and 256-byte
and 20-byte keys on a 100K-row build side.

The test sets `join_algorithm = parallel_hash`,
`max_bytes_ratio_before_external_join = 0`, `query_plan_join_swap_table = false`
and `enable_join_runtime_filters = 0`, and leaves
`enable_packed_string_keys_in_hash_join` at its default, so that both sides of
the comparison run the same default.

A probe row hits when `cityHash64(number) % 2 = 0`. A miss of the 8M build side
takes an id below 10M, so the short and the mixed probe keys keep the lengths
of the build side. The 256-byte and 20-byte shapes read the probe table 6 and 4
times with `UNION ALL` on the probe side, joined once to the build table.

Validated on master 45e6326 (release build): the results are equal with
the setting 0 and 1; with 1 `JoinPackedStringKeysInline` +
`JoinPackedStringKeysHashed` equal the build rows (0 with 0); every count and
sum equals the value computed from the generators; every id hashed by
`sipHash128` is a UInt64 on both sides; `perf.py` runs the test green, also
with `--table-engine iceberg_local`.

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 review of the same head (0 blockers, 0 majors, 3 nits, none blocking).

# Sev Finding Verdict Evidence / action
1 💡 Shapes 3 and 9 run under 0.1 s at 16 threads on my host AGREE, noted The sizes are the requested ones; stated in the description (0.14 to 0.28 s at 8 threads, the amd perf CI setting)
2 💡 A PR adding a perf test also runs it in the Iceberg perf jobs; only iceberg_local was run locally AGREE, noted perf.py --table-engine iceberg_local is green; iceberg_s3 needs S3 and its jobs are allow_failure
3 💡 The shared 20M-row probe table is about 5.4 GB, above the 1 GB that tests/performance/scripts/README.md flags as a stability risk AGREE, noted One probe table with a key column per shape is the requested layout; each query reads one column

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

Session id: cron:clickhouse-review-slot-8:20261117-080100

@groeneai

Copy link
Copy Markdown
Collaborator Author
Pre-PR validation gate (click to expand)
# Question Answer
a Deterministic repro? N/A: a requested new performance test, no failure. The checks are deterministic: every query was run 18 times (setting 1 and 0, 16 and 8 threads) with identical results and events.
b Root cause explained? N/A: the packed String key path of #128972 had no performance test.
c Fix matches root cause? Yes: one new file, tests/performance/hash_join_packed_string_keys.xml, with the 9 requested shapes and settings.
d Test intent preserved / new tests added? The test is the deliverable. Each query measures its shape: the counts and sums equal the values computed from the generators, and the packed-key events equal the build rows.
e Both directions demonstrated? Setting 0 vs 1: equal results; JoinPackedStringKeysInline + JoinPackedStringKeysHashed = build rows with 1 and 0 with 0. Hashing a UInt32 id on the build side gives 0 matches against the shape 7 probe, while the test's toUInt64 gives 19993420.
f Fix is general across code paths? Covers inline (shape 1), hashed (2-5, 7-9) and mixed (6) keys; with and without hits; duplicates; skew; build sides of 100K, 1M and 8M rows.
g Fix generalizes across inputs (params/datatypes/wrappers)? Key lengths 1-7, 2-40, 20, 36 and 256 bytes; the 100K build side is the min_rows_for_packed_string_keys_in_hash_join threshold, and the events show that packing applies there.
h Backward compatible? (maintainer-approved exception only) Yes: test only. All 4 settings exist on master; the test does not set the new setting, so both servers of a comparison run their own default.
i Invariants and contracts preserved? Every id hashed by sipHash128 is a UInt64 on both sides (checked per fill); perf.py runs the test green, also with --table-engine iceberg_local, and the 7 tables are dropped.

Session id: cron:clickhouse-impl-slot-4:20261117-074800

@clickhouse-gh

clickhouse-gh Bot commented Nov 17, 2026 •

Copy link
Copy Markdown
Contributor

Workflow [PR], commit [3eee35f]

Summary: ✅


AI Review

Summary

Adds nine performance workloads for hash joins on a single String key, covering short, long, mixed, skewed, unmatched, and duplicate keys. The generators and settings match the requested shapes. Reported validation includes equal results with packing enabled and disabled, expected row counts and profile events, timings, and successful performance-runner execution. No actionable findings.

Final Verdict

Status: ✅ Approve

@clickhouse-gh clickhouse-gh Bot added the pr-not-for-changelog This PR should not be mentioned in the changelog label Nov 17, 2026
@harikrishnan94 harikrishnan94 added the can be tested Allows running workflows for external contributors label Nov 17, 2026
@harikrishnan94 harikrishnan94 self-assigned this Nov 17, 2026
@clickhouse-gh clickhouse-gh Bot added the comp-testing Test content only (no production code). label Nov 17, 2026

@harikrishnan94 harikrishnan94 left a comment

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.

Test only changes.
LGTM.

@harikrishnan94
harikrishnan94 added this pull request to the merge queue Nov 17, 2026
@Blargian
Blargian removed this pull request from the merge queue due to a manual request Nov 17, 2026
@Blargian
Blargian added this pull request to the merge queue Nov 17, 2026
Merged via the queue into ClickHouse:master with commit 19d6eab Nov 17, 2026
571 of 573 checks passed
@robot-ch-test-poll2 robot-ch-test-poll2 added the pr-synced-to-cloud The PR is synced to the cloud repo label Nov 17, 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-not-for-changelog This PR should not be mentioned in the changelog 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