Skip to content

Faster short LowCardinality range inserts from a different dictionary - #123900

Merged
harikrishnan94 merged 9 commits into
ClickHouse:masterfrom
groeneai:lc-short-range-insert-from-other-dictionary
Oct 7, 2026
Merged

harikrishnan94 merged 9 commits into
ClickHouse:masterfrom
groeneai:lc-short-range-insert-from-other-dictionary

Conversation

@groeneai

@groeneai groeneai commented Oct 4, 2026 •

Copy link
Copy Markdown
Collaborator

Closes: #123874
Related: #114870

Changelog category (leave one):

  • Performance Improvement

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

Hash joins with many matches per key are faster when they output a LowCardinality column whose blocks have different dictionaries (several parts, FINAL, or a LowCardinality value computed per block): short ranges from another dictionary are now inserted key by key instead of through temporary columns. Such joins run 4-9x faster, at the 26.6 level or better.

Description

Since #107189 the hash join emits consecutive same-block rows of a key with one insertRangeFrom; such runs are 2-6 rows long. When the source block's dictionary differs from the output column's, ColumnLowCardinality::insertRangeFrom builds about five temporary columns per call, so a run costs ~25x per row what insertFrom costs. #115961 avoids it only when the right side has a single shared dictionary.

Ranges of at most 64 rows from a different dictionary are now translated row by row by ColumnUnique::uniqueInsertRowsFrom, which shares the NULL and default-value rules (-0.0 folds to the default) with uniqueInsertRangeFrom through one helper; results are unchanged. A microbenchmark over 16-1024 rows puts the crossover at 66-85 rows for a few distinct short keys (two 200-byte keys: 0.86x at 64) and past 128 rows for 100+ distinct keys. Longer ranges and same-dictionary paths are untouched.

Medians of 10 interleaved runs, RelWithDebInfo, base = parent commit, official 26.6.8.7 for reference:

query 26.6 base this PR
issue repro 4 as filed (FINAL) 2.31 s 8.93 s 2.30 s
repro 1 with the table in 4 parts 1.33 s 5.12 s 0.79 s
same, default settings 1.00 s 4.40 s 0.50 s
table-free join, hash 0.18 s 0.75 s 0.15 s

Shared-dictionary and String controls are unchanged. Repro 4 at default settings takes a different path (the planner swaps the join sides) and is not affected.

A new gtest checks that lengths 1-256 give the same indexes and dictionary as the range path and that NULL and default rows land in their slots (String, Nullable, Float64 with -0.0 and NaN payloads, nullable promotion, a shared source, index width growth, out-of-bound ranges).

🤖 Generated with Claude Code


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

Version info

  • Merged into: 26.10.1.1741-master (included in 26.10 and later)
  • Backported to: 26.9.13.11, 26.8.21.9

robot-clickhouse and others added 3 commits October 4, 2026 16:53
Since ClickHouse#107189 the hash join emits consecutive same-block rows of a key with
one `insertRangeFrom` instead of one `insertFrom` per row. `RowRefList` keeps
a key's rows in nodes of up to 6 refs, so these runs are 2-6 rows long. When
the source block's dictionary differs from the output column's,
`ColumnLowCardinality::insertRangeFrom` builds about five temporary columns
per call whatever the length (`cut`, `mapUniqueIndex`, `index` of the used
keys, `uniqueInsertRangeFrom`, `index` of the positions), so such a run costs
~25x per row what `insertFrom` costs. ClickHouse#115961 avoids it only when the right
side has a single shared dictionary; several parts, `FINAL` or a
`LowCardinality` value computed per block still hit it on every run.

Ranges of at most 32 rows from a different dictionary are now translated row
by row with the per-key rules of `uniqueInsertRangeImpl`: the source NULL maps
to the destination NULL, a key that compares equal to the default (so `-0.0`
too) maps to the default slot, anything else goes through `uniqueInsertFrom`,
which canonicalizes NaN. Positions are computed before the indexes change and
the range is bounds-checked first, so a throw leaves the rows untouched, as on
the range path.

The threshold is the largest power of two at which the per-row path is not
slower than the range path in a microbenchmark of ns per call (RelWithDebInfo,
one core, median of 7): range/per-row at 32 rows is 1.99x for 7 short keys,
2.52x for 10000 random keys, 1.48x for two 200-byte keys and 3.61x for 1000
UInt64 keys; at 64 the 200-byte case drops to 0.87x.

A/B, RelWithDebInfo, n = 10 interleaved, medians (26.6.8.7 / parent / this):
issue repro 4 with `compatibility = '23.8'` 2.31 / 8.93 / 2.30 s; repro 1 with
the table in 4 parts 1.33 / 5.12 / 0.79 s, at default settings 1.00 / 4.40 /
0.50 s; a table-free `hash` join 0.18 / 0.75 / 0.15 s. Shared-dictionary and
`String` controls unchanged. Repro 4 at default settings does not reach this
path (the join sides are swapped and the time is in the row-store emit).

The gtest compares a short range against a 600-row range of the same rows for
every length 1-256; it fails when the default fold, the bounds check or the
NULL branch is removed.

Closes: ClickHouse#123874

Co-Authored-By: Claude Opus 5.5 <[email protected]>
…eFrom wrap

`start + length` can overflow `size_t` (e.g. `start = SIZE_MAX, length = 1` sums to 0), so the guard
passed and the per-row loop read outside the source indexes. Compare `start` and `length` separately,
as `ColumnIndex::insertIndexesRange` does, and cover `start = SIZE_MAX` in the gtest.

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 4, 2026
@groeneai

groeneai commented Oct 4, 2026

Copy link
Copy Markdown
Collaborator Author
Internal second-model review: adjudication log (click to expand)

Pre-publication review by an independent model (engine: codex; round 1: 2 findings, round 2 on the fix: 0), plus my own review.

# Sev Finding Verdict Evidence / action
1 ⚠️ The short-range bounds check start + length > size wraps for start near SIZE_MAX (ColumnLowCardinality.cpp) AGREE, fixed in f48c1ff Rewritten as start > size || length > size - start (as in ColumnIndex::insertIndexesRange); the gtest asserts that a SIZE_MAX start throws and leaves the column unchanged, and fails with the old check
2 ⚠️ The gtest passes if the optimization is reverted DISAGREE The gtest checks equivalence with the range path and fails under three mutations of the new branch (no -0.0 fold, no bounds check, no NULL branch); a revert is caught by the new perf test (1.50 s before, 0.27 s after)
3 💡 No type check before compareAt on the source keys, unlike the range path DISAGREE No caller passes a different nested type; the existing insertFrom is equally unchecked

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

@groeneai

groeneai commented Oct 4, 2026

Copy link
Copy Markdown
Collaborator Author
Pre-PR validation gate (click to expand)
# Question Answer
a Deterministic repro? Yes. Table-free hash join emitting a per-block LowCardinality column: 0.75 s on the parent commit vs 0.18 s on 26.6.8.7, every run; issue repro 4 as filed 8.93 s vs 2.31 s; repro 1 with the table in 4 parts 5.12 s vs 1.33 s.
b Root cause explained? Since #107189 the join emits 2-6 row runs with insertRangeFrom; from a different dictionary, ColumnLowCardinality::insertRangeFrom builds about five temporary columns per call whatever the length (66.5% of repro 4 in perf).
c Fix matches root cause? Yes. The fixed per-call cost is removed where it lives: ranges of at most 32 rows are translated row by row with the rules of uniqueInsertRangeFrom. The join and the long-range path are unchanged.
d Test intent preserved / new tests added? New gtest: for lengths 1-256 and 4 starts, a short range gives the same indexes, nulls, bytes and dictionary prefix as the range path. New perf test hash_join_low_cardinality_many_matches.
e Both directions demonstrated? Perf, n = 10 interleaved: 5.1x (table-free), 3.9x (repro 4, now at 26.6 parity), 6.5-8.7x (4-part repro 1). The gtest fails under 3 mutations: no default fold (-0.0 arm), no bounds check, no NULL branch.
f Fix is general across code paths? Covers every short-range caller (join runs and ranges, LowCardinality nested in Array/Tuple/Map, ColumnArray::insertFrom). insertFrom/insertManyFrom are already per-row; the same-dictionary and shared-dictionary-adoption paths are untouched.
g Fix generalizes across inputs (params/datatypes/wrappers)? gtest arms: String, Nullable(String) with NULLs, nullable promotion, shared source dictionary, Float64 with -0.0 and two NaN payloads, UInt64 with index width growth, out-of-bound range.
h Backward compatible? (maintainer-approved exception only) Yes. No setting, format or storage change; results are identical to the range path (gtest oracle, SQL differential base vs fix byte-identical).
i Invariants and contracts preserved? Same index values and first-appearance key order as the range path; bounds checked before any mutation; all positions computed before the indexes change. Index width grows only when a value needs it, as in insertFrom.

Session id: cron:clickhouse-impl-slot-4:20261004-185300

@clickhouse-gh

clickhouse-gh Bot commented Oct 4, 2026 •

Copy link
Copy Markdown
Contributor

Workflow [PR], commit [34ac297]

Summary: ✅


AI Review

Summary

This PR teaches ColumnLowCardinality::insertRangeFrom to translate short foreign-dictionary ranges row by row, and it adds both correctness coverage in gtest_low_cardinality and a targeted hash-join performance query. After reviewing the current diff plus the prior discussion, I did not find a remaining correctness, compatibility, or evidence gap that warrants an inline finding.

Final Verdict

Status: ✅ Approve

LLVM Coverage Report

Measured on commit 34ac297.

Metric Baseline Current Δ
Lines 88.30% 88.30% +0.00%
Functions 92.10% 92.10% +0.00%
Branches 79.70% 79.70% +0.00%

Changed lines: Changed C/C++ lines covered: 50/52 (96.15%) · Uncovered code

Full report · Diff report

@clickhouse-gh clickhouse-gh Bot added pr-performance Pull request with some performance improvements comp-datatype-wrapper Type modifiers/wrappers (Nullable, LowCardinality, etc.). labels Oct 4, 2026
Build (arm_tidy) failed with cppcoreguidelines-pro-type-member-init /
hicpp-member-init on the `positions` stack array of the short-range path
in ColumnLowCardinality::insertRangeFrom. Only the first `length` entries
are written, all before they are read, so the array does not need to be
initialized.

Value-initializing it (`positions{}`, the tidy fix-it) zeroes 256 bytes on
every call of this hot path: RelWithDebInfo A/B, n=11 interleaved medians
on the table-free hash-join repro, 0.146 -> 0.148 s (q7) and
0.146 -> 0.149 s (q7p), identical results. Use the in-tree NOLINT idiom
for write-before-read stack buffers instead (AggregateFunctionUniq.h,
UniquesHashSet.h), which leaves codegen unchanged.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
@clickhouse-gh

clickhouse-gh Bot commented Oct 5, 2026 •

Copy link
Copy Markdown
Contributor

📊 Cloud Performance Report

✅ AI verdict: no_change — no significant changes across 32 queries analysed

No query changed in a way this PR can explain. The PR adds a per-row path to ColumnLowCardinality::insertRangeFrom, used only for inserts of up to 64 rows that come from a different dictionary. That situation mainly occurs when a hash join outputs right-side LowCardinality columns. The only flagged row is ClickBench Q34 (+6.5%), which stayed suppressed because it falls within master's normal variance. That decision fits the diff: ClickBench stores its data in plain String and numeric columns, so Q34 never reaches the changed code, and CPU time moved only about 1.5%. Neither ClickBench nor tpch_adapted_1_official exercises the new path, so the hash-join performance test this PR adds is the right place to measure its effect.

clickbench

⚠️ 1 inconclusive

Flagged queries (1 of 43)
Query Verdict Baseline median (ms) PR median (ms) Change q-value Hint
⚠️ 34 not_sure 1123 1196 +6.5% <0.0001 aggregation: This query is a large GROUP BY over plain String columns, and the ClickBench schema has no LowCardinality columns, so the new short-range insert path never runs. The 1196 ms median sits inside master's current 1089.5 to 1342.5 ms range, and CPU time is nearly unchanged.

Change = percent below ×2; the ratio of medians (×N faster/slower) beyond, where percent understates the scale. q-value = BH-FDR adjusted p; smaller is stronger evidence. MIRAI flags a query when q < fdr_q (default 0.10) — the value the verdict is based on.

tpch_adapted_1_official

🟢 No significant changes

Debug info
  • StressHouse run: 770012bb-9039-4fc1-b79a-63e2849b5ea4
  • MIRAI run: c4e8bae1-d4e6-4bb3-9362-d94fc706e791
  • PR check IDs:
    • clickbench_141136_1791359320
    • clickbench_141142_1791359320
    • clickbench_141148_1791359320
    • tpch_adapted_1_official_141160_1791359320
    • tpch_adapted_1_official_141171_1791359320
    • tpch_adapted_1_official_141208_1791359320

@clickhouse-gh

clickhouse-gh Bot commented Oct 5, 2026 •

Copy link
Copy Markdown
Contributor

Build profile diff (arm_release)

Comparing 34ac29760 with master 899038e29 (stripped binary size, per-symbol sizes and ThinLTO time; compile times per translation unit against the most recent warmup build that recompiled it).

✅ No significant changes.

Binary sizes

programs/clickhouse-stripped: smaller than the master baseline by the known offset between the two builds, so the difference is not shown. A delta that differs from the offset by more than 50% of it is shown, in either direction.

The official master build is compiled with -g and a pull request build is not, and XRay counts debug instructions towards its instrumentation threshold, so master instruments thousands of functions more and its binary is ~0.4% larger no matter what the pull request does.

Object file sizes

12 object files changed (-13.09 KiB total), 0 added.

Object file Master PR Δ
src/CMakeFiles/dbms.dir/Columns/ColumnUnique.cpp.o 2.90 MiB 2.88 MiB -17.54 KiB (-0.59%)

719 more object files are built by the master warmup baseline only (it builds every object-file target, a pull request build only clickhouse-bundle) and not compared.

Compile time of recompiled translation units

1241 translation units recompiled, 9383 s compile time in total, 1241 of them have a recent master baseline.

Job report

@harikrishnan94 harikrishnan94 self-assigned this Oct 5, 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.

Could you benchmark a few more lengths between 32 and 1024 to choose a reasonable crossover? Use that cutoff for max_rows_to_translate_individually and add a short comment explaining how it was chosen.

Requested in review: pick the crossover of `insertRangeFrom` from a
different dictionary from measurements between 32 and 1024 rows.

Microbenchmark (RelWithDebInfo, one pinned core, median of 7, two runs on
different cores agree within 1%). Ratio = range path time / per-row time,
above 1 means per-row translation is faster:

  source keys            32    48    64    96   128   256   512  1024
  7 short strings      1.96  1.37  1.07  0.76  0.61  0.38  0.26  0.20
  10 8-byte strings    2.11  1.48  1.14  0.81  0.63  0.37  0.25  0.19
  10 UInt64            2.35  1.65  1.28  0.91  0.72  0.43  0.28  0.22
  2 200-byte strings   1.45  1.06  0.86  0.65  0.54  0.39  0.30  0.26
  100 16-byte strings  3.33  2.80  2.49  2.11  1.22  0.71  0.39  0.21
  1000 UInt64          3.61  3.12  2.90  2.71  2.56  2.82  2.48  0.96
  10000 strings        2.49  2.23  2.05  1.91  1.85  1.99  1.80  1.93

With a few distinct short keys the range path overtakes at 66-85 rows, so
64 is the largest power of two that does not lose there; with 100 or more
distinct keys per-row translation keeps winning well past 64. Two distinct
1000-byte keys favour the range path at every length from 16 (hashing each
row dominates), as they already did at 32.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
@groeneai

groeneai commented Oct 5, 2026

Copy link
Copy Markdown
Collaborator Author

Thanks. I benchmarked both paths at 16-1024 rows (RelWithDebInfo, one pinned core, median of 7; two runs on different cores agree within 1%). Ratio = range path time / per-row time, above 1 means per-row is faster:

source keys 32 48 64 96 128 256 512 1024
7 short strings 1.96 1.37 1.07 0.76 0.61 0.38 0.26 0.20
10 8-byte strings 2.11 1.48 1.14 0.81 0.63 0.37 0.25 0.19
10 UInt64 2.35 1.65 1.28 0.91 0.72 0.43 0.28 0.22
2 200-byte strings 1.45 1.06 0.86 0.65 0.54 0.39 0.30 0.26
100 16-byte strings 3.33 2.80 2.49 2.11 1.22 0.71 0.39 0.21
1000 UInt64 3.61 3.12 2.90 2.71 2.56 2.82 2.48 0.96
10000 strings 2.49 2.23 2.05 1.91 1.85 1.99 1.80 1.93

With a few distinct short keys the range path overtakes at 66-85 rows, so I set max_rows_to_translate_individually to 64 and added a comment on how it was chosen (d52cce6). With large dictionaries the per-row path stays about 2x faster up to 1024 rows, so a cutoff that also looks at the source dictionary size could go further; I kept a single constant. Two distinct 1000-byte keys favor the range path at every length from 16 (hashing each row dominates), as they already did at 32.

@groeneai

groeneai commented Oct 5, 2026

Copy link
Copy Markdown
Collaborator Author

CI finish ledger - d52cce6

Every failure below has an owner: a fixing PR (mine or external), or a full-effort fix task
whose fixing-PR link will be posted here when it opens. Only CH Inc sync is exempt.

Check / test Reason Owner / fixing PR
Stress test (arm_release) / Hung check failed, possible deadlock found not from this PR, which changes ColumnLowCardinality::insertRangeFrom only: the hung query is a fuzzed variant of 05317_exponential_null_propagation (a join over a chain of aliases that reuse each other), still planning 3628 s after it was cancelled, and its stack is all ActionsDAG::Node::updateHash frames, which visit the shared subexpressions once per path #123793 (mine, open)
Mergeable Check, PR rollups of the row above #123793 (mine, open)

CIDB has no other FAIL or ERROR row on this head, and CH Inc sync passed.

Session id: cron:our-pr-ci-monitor:20261005-223244

@harikrishnan94

Copy link
Copy Markdown
Contributor

@groeneai Could you move the NULL and default-value rules into a shared helper in ColumnUnique? Both the short-range and bulk paths should use it, so we only maintain these rules in one place. Keep the existing uniqueInsertFrom behavior unchanged, and rerun the benchmarks to confirm the refactor preserves the speedup. Along with that make the PR merge ready

…olumnUnique

Requested in review: keep the NULL and default-value rules of
`uniqueInsertRangeFrom` in one place. `ColumnUnique::getSpecialValueIndex`
now holds them and is used by `uniqueInsertRangeImpl` and by the new
`uniqueInsertRowsFrom`, which translates the rows of a short range from a
different dictionary. `ColumnLowCardinality::insertRangeFrom` only gathers
the source indexes and hands them over. `uniqueInsertFrom` is unchanged.

A per-row virtual call (one `uniqueInsertFrom`-like call per row) was
measured first and cost 14% on the table-free join below, because the
source column was unwrapped on every row; taking the whole range unwraps it
once. `getSpecialValueIndex` is `ALWAYS_INLINE`: without it the call is not
inlined in `uniqueInsertRowsFrom` and the join is 5% slower.

Microbenchmark (RelWithDebInfo, one pinned core, ns per insertRangeFrom
call, 2 runs on different cores): on the per-row path (2-64 rows) this
commit takes 0.91-0.99x the time of the previous head for every key set
except two 1000-byte strings (1.00-1.01x); on the range path (96-1024 rows)
0.99-1.01x. At 2-6 rows it is 3-25x faster than the parent of the PR.

End to end (median of 7, base = parent of the PR / previous head / this):
table-free hash join 0.757 / 0.143 / 0.146 s, parallel_hash 0.756 / 0.144 /
0.147 s, issue repro 1 with 4 parts (compatibility 24.8) 3.755 / 0.773 /
0.784 s. Results identical.

The gtest now also checks the NULL and default rules against the source,
since both paths share them; removing either rule turns it red.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
@groeneai

groeneai commented Oct 6, 2026

Copy link
Copy Markdown
Collaborator Author

Thanks. Done in 4a9f718: ColumnUnique::getSpecialValueIndex now holds the NULL and default-value rules, and both uniqueInsertRangeImpl and the short-range path use it. The short path calls the new IColumnUnique::uniqueInsertRowsFrom, which translates the whole range, so ColumnLowCardinality::insertRangeFrom only gathers the source indexes. uniqueInsertFrom is unchanged.

I tried a per-row virtual call first: it was 14% slower on the table-free join because it unwrapped the source column on every row, so the method takes the whole range and unwraps it once. The helper is ALWAYS_INLINE; without it the join was 5% slower.

Microbenchmark (RelWithDebInfo, one pinned core, two runs on different cores), time of this commit / previous head, by range length:

source keys 2 6 32 64
7 short strings 0.93 0.95 0.95 0.95
10 UInt64 0.92 0.91 0.93 0.92
100 16-byte strings 0.95 0.95 0.95 0.95
10000 strings 0.99 0.98 0.98 0.97
2 1000-byte strings 1.00 1.00 1.01 1.01

The range path (96-1024 rows) is 0.99-1.01x. At 2-6 rows this is 3-25x faster than the parent of the PR.

End to end, median of 7, within 2% of the previous head:

query parent of the PR previous head this
table-free join, hash 0.757 s 0.143 s 0.146 s
same, parallel_hash 0.756 s 0.144 s 0.147 s
repro 1, table in 4 parts 3.755 s 0.773 s 0.784 s

Since both paths now share the rules, the gtest also checks that NULL and default rows land in their slots; removing either rule turns it red.

For merge readiness: the branch merges cleanly with current master and CI is running on the new head. The only failure on the previous head, the Stress test (arm_release) hung check, is a fuzzed 05317_exponential_null_propagation query unrelated to this change; my open #123793 addresses it.

@harikrishnan94

Copy link
Copy Markdown
Contributor

Replace

/// Benchmarked at 16-1024 rows: with a few distinct short keys the range path overtakes per-row translation at 66-85 rows,
    /// with 100 or more distinct keys per-row translation stays faster past 128 rows.

With
/// The range path starts to win around 64 rows when there are only a few distinct short keys.

As requested in review.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
@groeneai

groeneai commented Oct 6, 2026

Copy link
Copy Markdown
Collaborator Author

Done in ad338f1: replaced the comment with your line (comment-only change).

Comment thread src/Columns/ColumnLowCardinality.cpp Resolved
@groeneai

groeneai commented Oct 6, 2026

Copy link
Copy Markdown
Collaborator Author

CI finish ledger - ad338f1

Every failure below has an owner: a fixing PR (mine or external), or a full-effort fix task
whose fixing-PR link will be posted here when it opens. Only CH Inc sync is exempt.

Check / test Reason Owner / fixing PR
Performance Comparison (amd_release, master_head, 2/6) / is_valid_utf8 #7 code placement in this one binary: the query (isValidUTF8 over a String column) never reaches ColumnLowCardinality. Measurements below a fix task is created (its fix direction awaits a maintainer decision; fixing-PR link to follow on this PR)
Stateless tests (arm_asan_ubsan, azure, sequential) job timeout at 9000 s after 1166 of 1167 tests, 0 failed tests; the same timeout hits master and other PRs since 2026-10-03 #123849 (mine, open)
Mergeable Check, PR rollups of the rows above #123849 (mine, open); a fix task is created (the one above)

is_valid_utf8 #7 (0.039 -> 0.083 s) is the only slow value in 1625 amd runs of this query in 14 days. Running the CI amd_release binaries locally, this head takes 83.7 cycles per row, against 35.8 for this PR's head d52cce6 and 35.3 for the reference, at the same 177.3 instructions per row. The four hot functions (FunctionStringOrArrayToT<ValidUTF8Impl>::executeImpl, UTF8::isValidUTF8, and simdutf's validate_utf8_with_errors and rewind_and_validate_with_errors) are byte-identical in the three binaries; only their addresses differ. In the slow one the uop cache delivers 1.1G instead of 22.1G uops and BACLEARS.ANY is 452M instead of 2M, and the two 64-byte lines of the per-row loop in executeImpl share their address mod 4 KiB with lines of rewind_and_validate_with_errors, which happens in neither fast binary. I merged master in 38a9e21 for a new build.

Session id: cron:clickhouse-maint-slot-13:20261006-155500

@groeneai

groeneai commented Oct 6, 2026

Copy link
Copy Markdown
Collaborator Author

CI finish ledger - 38a9e21

Every failure below has an owner: a fixing PR (mine or external), or a full-effort fix task
whose fixing-PR link will be posted here when it opens. Only CH Inc sync is exempt.

Check / test Reason Owner / fixing PR
Performance Comparison (amd_release, master_head, 6/6) / float_formatting #14, #17, #18 code placement in this one binary: the queries (toString(toFloat32(...)) over numbers()) never reach ColumnLowCardinality or ColumnUnique. Measurements below a fix task is created (its fix direction awaits a maintainer decision; fixing-PR link to follow on this PR)
Mergeable Check, PR rollups of the row above a fix task is created (the one above)

float_formatting #14, #17 and #18 are +24.5%, +20.7% and +20.0% (+26.8%, +20.6% and +17.9% after the server restart). In the CI profiles the extra samples are in itoa(int, char*) (#17 135 -> 215, #18 148 -> 229) and in writeFloatTextFastPath<float> (#14 180 -> 241). The per-row chain ConvertImpl<DataTypeFloat32, DataTypeString, NameToString>::execute -> writeFloatTextFastPath<float> -> itoa(int, char*) is the same machine code in this build, in the reference 740fe426 and in this PR's two previous builds; only its offsets differ. In this build the two lines of the per-row loop sit at the same 4 KiB page offsets (0x200, 0x240) as the writeFloatTextFastPath<float> lines around its itoa call; in the other three builds the loop shares no offset with a hot line. On my Xeon 6975P-C the four CI binaries run these queries at the same speed (within 1%, same instruction count), so I can't confirm the mechanism without a Sapphire Rapids host.

Session id: cron:clickhouse-maint-slot-14:20261006-232900

@harikrishnan94

Copy link
Copy Markdown
Contributor

@groeneai Make this Merge ready

@groeneai

groeneai commented Oct 7, 2026

Copy link
Copy Markdown
Collaborator Author

Merged current master in 34ac297. The PR diff itself is unchanged, and the LowCardinality / ColumnUnique gtests pass on the new head.

The only red on the previous head was Performance Comparison (amd_release, master_head, 6/6) on float_formatting #14/#17/#18. Those queries never reach this code: it was code placement in that one binary (measurements in the ledger above), and a new build is the only lever for it, so this merge also re-runs that check on a fresh binary. CI is running on the new head.

@harikrishnan94
harikrishnan94 added this pull request to the merge queue Oct 7, 2026
Merged via the queue into ClickHouse:master with commit 80259c9 Oct 7, 2026
149 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 Oct 7, 2026
@robot-ch-test-poll3 robot-ch-test-poll3 added the pr-must-backport-synced The `*-must-backport` labels are synced into the cloud Sync PR label Oct 7, 2026
clickhouse-gh Bot added a commit that referenced this pull request Oct 7, 2026
Backport #123900 to 26.9: Faster short `LowCardinality` range inserts from a different dictionary
harikrishnan94 added a commit that referenced this pull request Oct 8, 2026
Cherry pick #123900 to 26.8: Faster short `LowCardinality` range inserts from a different dictionary
robot-clickhouse added a commit that referenced this pull request Oct 8, 2026
@robot-ch-test-poll4 robot-ch-test-poll4 added the pr-backports-created Backport PRs are successfully created, it won't be processed by CI script anymore label Oct 8, 2026
clickhouse-gh Bot added a commit that referenced this pull request Oct 8, 2026
Backport #123900 to 26.8: Faster short `LowCardinality` range inserts from a different dictionary
kewin-robetti pushed a commit to viasoftkorp/ClickHouse that referenced this pull request Oct 9, 2026
…ge inserts from a different dictionary
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-datatype-wrapper Type modifiers/wrappers (Nullable, LowCardinality, etc.). groeneai-origin-request PR origin: a maintainer pinged or directed groeneai pr-backports-created Backport PRs are successfully created, it won't be processed by CI script anymore pr-must-backport-synced The `*-must-backport` labels are synced into the cloud Sync PR pr-performance Pull request with some performance improvements pr-synced-to-cloud The PR is synced to the cloud repo v26.8-must-backport

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Hash join with many matches per key and LowCardinality columns is about 2.3x slower (26.6 -> 26.8)

7 participants