Skip to content

Remove dead string_columns code in BufferedV1 WASM UDF executor - #2

Closed
bacek wants to merge 1 commit into
spr/master/e31f0f25from
spr/master/0152cb03
Closed

bacek wants to merge 1 commit into
spr/master/e31f0f25from
spr/master/0152cb03

Conversation

@bacek

@bacek bacek commented Mar 13, 2026 •

Copy link
Copy Markdown
Owner

In UserDefinedWebAssemblyFunctionBufferedV1::executeOnBlock there was
a loop that collected pointers to ColumnString columns into a local
vector, but the vector was never read after the loop — making the entire
block dead code.

The loop logic was also incorrect: the else branch called
string_columns.clear(), erasing all previously collected pointers
whenever any column was not a pure string type. This appears to be an
abandoned fast-path optimization for all-string tables that was never
completed.

Remove the dead loop and the now-unused #include <Columns/ColumnString.h>.

Co-Authored-By: Claude Sonnet 4.6 [email protected]


Stack:


⚠️ Part of a stack created by spr. Do not merge manually using the UI - doing so may have unexpected results.

In `UserDefinedWebAssemblyFunctionBufferedV1::executeOnBlock` there was
a loop that collected pointers to `ColumnString` columns into a local
vector, but the vector was never read after the loop — making the entire
block dead code.

The loop logic was also incorrect: the `else` branch called
`string_columns.clear()`, erasing all previously collected pointers
whenever any column was not a pure string type. This appears to be an
abandoned fast-path optimization for all-string tables that was never
completed.

Remove the dead loop and the now-unused `#include <Columns/ColumnString.h>`.

Co-Authored-By: Claude Sonnet 4.6 <[email protected]>

commit-id:0152cb03
@bacek bacek closed this Mar 13, 2026
bacek pushed a commit that referenced this pull request Apr 1, 2026
## #1: Cross-test ownership ratio (find_tests.py)

Replace plain `1/width` scoring with `1/(width × region_test_count)` where
`region_test_count = uniqExact(test_name)` for each region.  A region covered
by 1 test scores 1000× higher than one covered by 1000 tests, naturally
eliminating the hot-region problem without a hard cap.

## #2: Branch direction (LLVMCoverageMapping + coverage_log)

Parse `BranchRegion` (LLVM kind=4) in `readLLVMCoverageMapping`.  Format:
kind-marker → true_counter → false_counter → line/col, producing two
`CoverageRegion` entries with `is_branch=true` and `is_true_branch` set.
Added `branch_flags Array(UInt8)` to `system.coverage_log` (0=code, 1=true,
2=false).  Tests that covered both sides of a changed condition now carry that
information for smarter ranking.

## #3: Indirect call targets (coverage.h/cpp + CoverageCollection)

Read `LLVMProfileData::Values` (LLVM value profiling, kind IPVK_IndirectCallTarget)
to capture which concrete functions were called via virtual dispatch or function
pointers.  Each observation: `(caller_name_hash, caller_func_hash, callee_offset,
call_count)` where `callee_offset = callee_abs − binary_load_base` (from
`/proc/self/maps`), stable across ASLR restarts.  Flushed alongside coverage
counters into `system.coverage_indirect_calls`.  Fixes the fundamental gap where
a test covering `IStorage::read` cannot be distinguished from a test specifically
dispatching to `StorageMergeTree::read`.

## #4: XRay call-depth tracking (coverage.h/cpp + cmake/sanitize.cmake)

New CMake option `WITH_COVERAGE_XRAY=ON` enables `CLICKHOUSE_XRAY_INSTRUMENT_COVERAGE`.
At test start, activates XRay (`__xray_patch`) with a handler that maintains per-thread
relative call depth.  On first activation, builds a `(xray_function_id → profile_data_index)`
map by resolving each function via `__xray_function_address(id)` + `dladdr()` → symbol name
→ FNV64 hash → match against `LLVMProfileData::NameRef`.  This solves the PIE
`FunctionPointer=0` limitation: XRay provides real runtime text addresses where
`LLVMProfileData::FunctionPointer` is always null.  When enabled, `min_depth` in
`CovCounter` contains actual call depth; otherwise falls back to call-count proxy.

Co-Authored-By: Claude Sonnet 4.6 (1M context) <[email protected]>
bacek pushed a commit that referenced this pull request May 14, 2026
`getReturnTypeImpl` already constrains the second argument of
`kostikConsistentHash` / `jumpConsistentHash` to an integer type, so the
constant bucket count can be read directly via `IColumn::getInt` /
`getUInt` instead of materialising an intermediate `Field`.

Apart from being a small simplification this fixes a `-march=x86-64-v3`
regression: `Field` is a 32-byte object, and `clang` lowered the
`Field buckets_field = (*arguments[1].column)[0]` copy to YMM
`vmovups`-pairs.  The dirtied AVX upper state then forced `vzeroupper`
before every per-row call to the (separately compiled, scalar-only)
`ConsistentHashing` helper, regressing
`consistent_hashes #0/#2/#4` ~10–13% on AMD release.

After the refactor the per-row hot path no longer touches YMM at all;
the remaining `vzeroupper` instructions left in the function body are in
cold exception-construction paths and execute as no-ops because the
upper YMM state is already clean.

On Sapphire Rapids LTO (100M rows):
  - master:                 0.211–0.215 s
  - PR (no fix):            0.227–0.242 s  (+11 %)
  - PR + this refactor:     0.211–0.214 s  (matches master)

Co-Authored-By: Claude Opus 4.7 (1M context) <[email protected]>
bacek pushed a commit that referenced this pull request May 14, 2026
`convertNumericGeneral` runs a per-element `static_cast` loop. For
same-width integer conversions (e.g. `toInt64(UInt64)`, `toUInt32(Int32)`,
`toUInt8(Int8)`) `static_cast` is a pure bit-reinterpret, so the loop is
semantically a memcpy.  Calling `std::memcpy` directly is the natural way
to express that.

It also avoids a v3 codegen issue that caused the recurring CI regression
in `decimal_casts #2` (`SELECT toInt64(x) y, toDecimal32(y, 1),
toDecimal64(y, 5), toDecimal128(y, 6) FROM t` with `x UInt64`):

- At `-march=x86-64-v3` clang's SLP vectorizer widens the trivial copy
  loop to 4-way unrolled 256-bit `vmovdqu ymm` stores in
  `callOnIndexAndDataType<...NameToInt64...>` (232 YMM moves vs master's
  126 XMM `movdqu`).  The wider stores left the upper YMM state dirty,
  triggering an SSE/AVX state-save penalty on Intel cores that serialise
  the transition - reproducible in CI as ~+13.6% on this query, even
  though the YMM loop on its own is no faster (memory-bandwidth-bound).
- Routing same-width integer conversions to `std::memcpy` removes the
  YMM emission entirely and shrinks
  `callOnIndexAndDataType<DataTypeNumber<long>, ..., NameToInt64>` from
  30527 to 4084 bytes.  No XMM, no YMM in the function body.

Local Sapphire Rapids LTO (max_threads=12, 500 iter):
  - master:  0.064s median, 0.072s p90
  - PR:      0.063s median, 0.070s p90

Behaviour preserved: same-width integer reinterprets (e.g. `toInt8(255_u8)
== -1`, `toUInt8(-1_i8) == 255`, `toInt32(0xFFFFFFFF_u32) == -1`) match
the pre-change loop output.  The accurate / overflow-checking strategies
(`AccurateConvertStrategyAdditions`, `AccurateOrNullConvertStrategyAdditions`)
are excluded from the fast path because they need the per-element checks.

Co-Authored-By: Claude Opus 4.7 (1M context) <[email protected]>
bacek pushed a commit that referenced this pull request May 14, 2026
At x86-64-v3 the loop and SLP vectorizers widen the per-row Int128
stores in convertToDecimalBatch into YMM/XMM packs (vmovq +
vpunpcklqdq + vmovdqu) wrapping the BMI2 mulxq, costing 4 vmovq
GPR->XMM moves and 2 vpunpcklqdq per 2 elements. The packing
overhead dominates the mulxq win, regressing sum ClickHouse#16 ~12% and
decimal_casts #2 ~7-12% on x86-64-v3 vs v2 master.

Disable the loop and interleave vectorizers for the scaled multiply
loop with a clang loop pragma gated on __AVX2__. Plain GPR stores
keep the mulxq v3 win and match v2 master's hot-loop perf.

Co-Authored-By: Claude Opus 4.7 (1M context) <[email protected]>
bacek pushed a commit that referenced this pull request May 21, 2026
…ax indices

Address PR ClickHouse#101170 review feedback (CI #2):

- Drop the 5 add_minmax_index_for_* members from ProjectionDescription. They
  were stale ad-hoc fields duplicating MergeTreeSettings; with the new generic
  SettingsChanges flow the effective MergeTreeSettings is already the canonical
  representation.
- Thread the already-computed effective MergeTreeSettings (defaults from the
  projection index plus user WITH SETTINGS overrides) into fillProjectionDescription
  and fillProjectionDescriptionByQuery as a new parameter, instead of
  reconstructing it. fillProjectionDescriptionByQuery reads the implicit-minmax
  flags via strongly-typed MergeTreeSetting accessors.
- Add the 5 add_minmax_index_for_* names to ALLOWED_PROJECTION_SETTINGS so the
  feature added in ClickHouse#105137 (Enable Implicit Skip Indices for Projections) keeps
  working under the new settings flow.

The ATTACH validation gap raised by review item #3 is intentionally left as
`mode <= LoadingStrictnessLevel::CREATE` to match the project-wide convention
(InterpreterCreateQuery, registerStorageMergeTree, etc. all validate user input
on CREATE/SECONDARY_CREATE only). The previous loadSettings validated
unconditionally because it had no access to mode; now that we do, aligning with
the rest of the codebase is the consistent choice.
bacek pushed a commit that referenced this pull request Jun 10, 2026
ClickHouse#106278 tried to remove the LIMIT-without-ORDER-BY non-determinism by
sampling with WHERE cityHash64(WatchID) % N = 0. Post-merge master data
showed it did not work: it made the measured queries scan the whole table on
every run, so instead of reducing the noise it regressed it badly:

  classification #0: 6.5% -> 76% noisy
  classification #1:  10% -> 90% noisy

(#2/#3/#4 were already clean.)

Materialize the deterministic subset once into its own single-part table
(single-threaded insert + OPTIMIZE FINAL) and measure over that, so the
determinism lives in the setup (like ClickHouse#106249 for reading_from_file) and the
measured queries read only the subset instead of rescanning the source.
bacek pushed a commit that referenced this pull request Jul 11, 2026
- Resolve setting query parameters on a copy of the changes instead of
  mutating the AST, so the placeholders are preserved for the old-server
  compatibility rewrite in ClientBase::processOrdinaryQuery (review major #1).
- Pass the changes to checkSettingsConstraints as const: the non-const
  overload rewrites the list and drops no-op changes, which lost the
  "changed" flag for a setting explicitly set to its current value
  (e.g. SET log_queries = 1) and broke 03595_set_query_no_eq_set_to_one.
- Teach QueryParameterVisitor / analyzeReceiveQueryParams to discover query
  parameters used as setting values (stored inside FieldFromAST), so
  predefined HTTP handlers accept param_<name> for them (review major #2).
- Renumber the stateless test to 04416 to satisfy the test-numbers style check.

Co-Authored-By: Claude Opus 4.8 (1M context) <[email protected]>
alexey-milovidov pushed a commit that referenced this pull request Aug 3, 2026
Populate skipping_indices_types for session temporary tables
bacek pushed a commit that referenced this pull request Aug 21, 2026
A query flagged in `report.html` was dropped when `all-query-metrics.tsv` had
no `client_time` row for it, and a shard whose TSV could not be read dropped
all of its flagged queries. With every flagged query dropped the run ended with
"the comparison ran and was clean" - a non-empty CI report turned into an
all-clear. The cause is deliberate on CI's side: `compare.sh` retracts a query
from the TSV when its confirmation rerun demoted it, while the report still
lists it under both "Changes in Performance" and "Unconfirmed Changes". On
PR ClickHouse#115255 that is `round_down` #2 and #3 and `and_compare_chain_derived` #2.

Those rows carry their own numbers, so they are now read from `report.html` and
marked `*` in the report - CI's verdict on them was already in doubt, which
makes them the most interesting queries to rerun, not the ones to discard. A
flagged query readable from neither source is reported as unresolved, and if
that leaves nothing to rerun the run fails instead of reporting a clean
comparison.

The commit under test drove only the report and binary lookup; the XMLs,
`perf.py`, its `stat_threshold`, and the configs still came from the working
tree. Query indices are positional and substitutions expand them, so a tree
that differs from the measured commit silently reruns a different query - on a
checkout one commit behind master, `and_compare_chain_derived.xml` has no query
#2 at all while CI flagged exactly that, and a `refs/pull/<n>/merge` checkout
is never the commit CI measured. `tests/performance`, `programs/server` and
`tests/config/top_level_domains` are now extracted from that commit into the
work dir and everything runs from there, fetching the commit when the clone
lacks it. `--use-working-tree-tests` opts out for iterating on a local test.

Verified: all six flagged queries of PR ClickHouse#115255 are now kept, the three the TSV
retracts carrying the report's numbers and flagged as unconfirmed; a dry run of
PR ClickHouse#112688 recovers `date_time_64` #5, which had been dropped the same way, and
runs against the extracted tree.

CI report: https://s3.amazonaws.com/clickhouse-test-reports/json.html?PR=115278&sha=baefff6dcc4dbb3201337a52b5ca54453fb34562&name_0=PR&name_1=Style%20check
Pull request: ClickHouse#115278

Co-Authored-By: Claude Opus 5 (1M context) <[email protected]>
Claude-Session: https://claude.ai/code/session_01GYYbBbrQpmi2zkYJ8LQw5Z
alexey-milovidov pushed a commit that referenced this pull request Sep 8, 2026
Address review on 03480_year.sql and year.cpp:

- The query-result-cache section is gone; determinism is asserted from
  `system.functions` (`year 0 <empty alias_to>`), which is a direct read of the
  flag rather than an observation of one of its consumers.
- `no-parallel` goes with it. The tag was earned only by the query result cache
  being a global singleton; what is left creates one table in the test's own
  database and reads `system.functions`, so it is safe to run against itself.
- The `year(datetime, timezone)` case is removed from the test, and the
  timezone argument is removed from the documented signature, the arguments
  list and the examples. Only the one-argument form is documented now.

Dropping the timezone example renumbers the remaining ones, so the
`docs_examples` baseline entry for the current-year example moves from
`Function/year#2` to `Function/year#1`. Left at `#2` the runner reports it as a
known failure that no longer exists, which fails the job.

The index-analysis statement gains a `pruned` column. Comparing the two row
estimates for equality also holds when neither spelling prunes: on the same
fixture with `ORDER BY tuple()` both estimates are 40000, so `same_index_scan`
is 1 while `pruned` is 0.

Co-Authored-By: Claude Opus 5 <[email protected]>
bacek pushed a commit that referenced this pull request Oct 3, 2026
…nce per block

`mortonEncode` with two arguments ran one row loop for every argument type
and mask: per row and argument it tested the mask and `is_const`, reloaded
the ratio, switched on the column width and, with a mask, called the
out-of-line `expand` (36 call sites in the arm `executeImpl`). On arm the
speed of the branch-dense paths depends on the binary's layout, so
`space_filling_curve` #1 (constant mask) and #4 (`UInt32` arguments) have
per-build speed modes and flag unrelated PRs in Performance Comparison
(ClickHouse#122482), while #2 (two `UInt64` columns) is stable.

Now each argument is resolved once per call into a contiguous `UInt64` array
with the range expansion applied: a `UInt64` column that needs no expansion
is read in place, other widths are widened with one type dispatch, and a
constant ratio is applied in one loop per ratio value (`expand` is
`ALWAYS_INLINE` and called with a template-constant ratio, so its switch
folds). A per-row mask keeps the per-row `expand`. `nd == 1` writes the
result column directly. The encode loops only encode.

x86, one core, median fix/base of 5 interleaved rounds over the queries of
`space_filling_curve.xml`: #1 0.57 (BMI2) / 0.55 (lookup-table path, built
with `-mno-bmi2`), #2/#3/#6 0.45-0.64, #4 0.86-0.88, untouched functions
0.99-1.03. Results are unchanged: 545 checksums over every width, mask and
ratio are byte-identical before and after on both code paths, and the new
test fails on both paths under two mutations of the change.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
bacek pushed a commit that referenced this pull request Oct 3, 2026
…test

The two compared servers each built a different copy of the fixture:

- `rand64() % 5000000` makes the number of rows with key 5, which queries
  #1 and #3 look up, a fresh draw per server (0 to 3 over 10 local fills);
- each INSERT is squashed into ~5 parts (cut at min_insert_block_size_rows),
  which merge until perf.py's --stop-merges freezes them at a per-server
  point.

#1 and #3 read about one granule per part, so each server read its own
number of granules: in CI the servers read different parts in 80% of runs,
and time follows the rows read (correlation 0.85-0.88). This redded
unrelated PRs (e.g. ClickHouse#118662, arm 4/6, #1 +37.5% confirmed_regression) and
inflated the learned threshold of #1/#3 to 0.41-0.53 (0.04-0.09 for
#0/#2/#4 on the same tables); the dashboard now caps both at
likely_regression as "Flaky lately", so a real regression there cannot red.

Use deterministic data, cityHash64(number, 7) and cityHash64(number, 11)
modulo 5000000 (same key range and duplicate profile; the seeds put key 5
once in each table, the modal case of the random draw, so #1/#3 keep
measuring a non-empty point join), and write each table as one part with
min_insert_block_size_rows = 10000000, min_insert_block_size_bytes = 0
(5M rows give one squashed block). A throwIf on system.parts fails the
fill if the layout ever drifts. Same shape as ClickHouse#122479 and ClickHouse#122660.

Validated through perf.py --stop-merges on two servers, 5 fresh fills per
arm: new fixture identical on all 10 server fills (one part per table, same
data, #1/#3 read 2 granules on both, #0/#2/#4 read 10M rows); old fixture
different on all 5 iterations. Without the insert settings the throwIf
fails the fill.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
bacek pushed a commit that referenced this pull request Oct 3, 2026
On x86, returning the rescan of the matching block from inside the block loop
is unrolled into branchless code that reuses the comparisons of the block.
Rescanning after the loop made it a loop whose exit is mispredicted when the
match position varies: `array_index_simd_numeric` #2 got 36% slower on amd.
Return from inside the loop on x86 again, so its code is the same as before
this PR. Other targets keep the `break`, which ARM needs to vectorize the block
loop for 4- and 8-byte elements (the same query got 25% faster on arm).

Related: ClickHouse#123377

Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]>
bacek pushed a commit that referenced this pull request Oct 23, 2026
…t have no MasterCI run

A PR performance run looks for `Build (<arch>_release_performance_reference)`
of the master commit it is tested on, and goes back to an older build only
over commits where MasterCI skipped that job. A commit of a batched push has
no MasterCI run at all, so the walk stopped there and the run was compared
with the official build. On 2026-10-22 that happened for every PR based on
a6c5f4a (its parent ffbc6be has no run), although 0ddba95 two
commits back has a reference build of the same sources. The official build
places the code differently from a PR build, and `long_primary_key` #0..#2
were 29-51% slower in the PR build, red on unrelated PRs.

Prove "same sources" by the praktika digest MasterCI records for the job in
`workflow_config_masterci.json` instead: pass over commits without a
reference build and accept the newest older one only if its digest equals
the one of the first commit with an official build. The last part of the
digest hashes the job config, which includes the docker `--memory` computed
from the Config Workflow runner's RAM, so it differs between runs with the
same sources and is not compared. Any missing or unreadable record keeps the
official fallback.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
bacek pushed a commit that referenced this pull request Nov 14, 2026
The four queries of `rand.xml` have the shape
`SELECT count() FROM (SELECT f() FROM zeros(N))`. `count()` reads no column
of the subquery, so the projection is dropped and `f()` is never called: in
CI `FunctionExecute` is 0 in every run of all four queries on both
architectures, and the queries time `count()` over `zeros()` (4-8 ms for
queries 2 and 3), which is noise. This started with the analyzer becoming
the default (ClickHouse#61652): on master `rand #2` went from 246 ms on 2024-03-26 to
6.3 ms on 2024-03-27.

Performance test queries keep their numbers, so queries 0-3 are disabled
(`disabled="1"`, text unchanged) and queries 4-7 are appended in the
`WHERE NOT ignore(f())` form used by `random_string.xml` and
`synthetic_hardware_benchmark.xml`, with the same row counts. `ignore` is
never constant-folded, so its argument is computed for every row.

Related: ClickHouse#110105, ClickHouse#101039

Co-Authored-By: Claude Opus 5.5 <[email protected]>
bacek pushed a commit that referenced this pull request Nov 14, 2026
…up window

`NegativeLimitBySortedStreamTransform::consume` sent every group, even one
that starts and ends inside the current chunk, through the sliding window:
`append_run` pushed a `ChunkSlice` into the empty window deque (allocating the
deque map and a block, and copying the chunk `shared_ptr`), `finalizeWindow`
copied it into `pending` (a second `shared_ptr` copy) and then `window = {}`
(libc++: `clear(); shrink_to_fit();`) freed the block and the map. So each
one-row group cost two memory-tracked allocations, two frees and two atomic
increment/decrement pairs, plus one `pending` entry.

The window is only needed for a group that touches a chunk boundary. A group
that ends inside the chunk while the window is empty also started inside this
chunk, so its output is known when its end is found: the last
`min(L, length + offset)` rows of the run without the trailing `offset` rows,
the same rows `append_run` + `dropExcessRows` + `dropOffsetRows` keep for a
one-slice window. Such groups are now staged into `pending` directly, and
`appendToPending` extends the last pending slice when the new rows continue
it in the same chunk, so the one-row groups of a chunk become one slice.
`generate()` produces the same chunk for a merged slice (same rows, first
start and last end). Groups touching a chunk boundary still use the window.

Evidence that this path is what moves the `negative_limit_by_in_order`
queries #0, #1 and #8 (millions of groups): ClickHouse#125000, which changed only the
allocator of these deques, moved them by -19/-16/-17% on master d3ee313 while
#2-#7 stayed flat; and the ClickHouse#125013 perf job's prewarm counters for #0 show
equal instructions on both sides (10301M vs 10333M, ~1030 per group) and +15%
cycles on one build.

Local A/B (release build, `CMAKE_BUILD_TYPE=None`, no ThinLTO, the perf
test's tables and queries, 12 rotating rounds, geomean of per-round ratios
new/base with bootstrap 95% CI):

  #0 10M one-row groups      0.764 s -> 0.096 s  0.123 [0.113, 0.135]
  #1 1M groups of 10         0.098 s -> 0.049 s  0.457 [0.413, 0.510]
  #2 100k groups of 100      0.025 s -> 0.019 s  0.707 [0.642, 0.785]
  #3-#7 100 groups           0.86-1.03, no CI lower bound above 1.0 (4-15 ms)
  #8 5M two-key groups       0.447 s -> 0.116 s  0.250 [0.236, 0.265]

User-space instructions of 5 runs of #0: 60.3G -> 10.2G (~1190 -> ~190 per
group after subtracting 5 runs of #3), cycles 16.2G -> 3.1G; #8: 31.4G ->
6.4G instructions. In the base profile of #0 about half of the samples are
in the deque allocation, `shrink_to_fit`, `CurrentMemoryTracker` and
jemalloc; none of them is in the top 15 after the change.

Replacing only `window = {}` by `clear()` (keeps the deque blocks) gives
0.526 / 0.594 / 0.583 on #0 / #1 / #8, so the direct staging is 4.3x and
2.3x faster than that on #0 and #8.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
bacek pushed a commit that referenced this pull request Nov 16, 2026
…dimensions on AArch64

`morton_decode` #6 (`mortonDecode(8, number)`) is 1.24x slower with
clang-23 on AArch64. `MortonNDLutDecoder<8, 8, 8>::DecodeInternal` is out
of line in both builds, but clang-23 compiles it to 218 instructions
instead of 173: an XRay sled (the body crossed the 200-instruction
threshold), callee-saved SIMD spills, and a wider SLP schedule with more
constant loads (llvm-mca: 40 against 30 cycles per call).

Apply `always_inline` to the morton-nd headers in `mortonDecode.cpp` and
`mortonEncode.cpp` through `#pragma clang attribute`: that alone brings
8 dimensions from 1.24x to 1.15x and fixes 4 dimensions (`morton_decode`
#2, 1.12x in the PR build, below the CI threshold) to 0.96x. For 8
dimensions, switch to `MortonNDCompressDecoder`, which under clang-23
measures equal to the clang-22 table decoder (0.99x), and add it to the
compile-time equivalence check.

Measured with the CI binaries on a Graviton 4 host against the clang-22
master build.

CI: https://s3.amazonaws.com/clickhouse-test-reports/praktika.html?PR=117346&sha=d847a368b13c19355fbfac4bbcec67663d20ec9f&name_0=PR&name_1=Performance%20Comparison%20%28arm_release%2C%20master_head%2C%204%2F6%29
PR: ClickHouse#117346

Co-Authored-By: Claude Fable 5.1 <[email protected]>
bacek pushed a commit that referenced this pull request Nov 16, 2026
…d `Aggregator`

LLVM 23 enabled dereferenceable-at-point semantics by default
(llvm/llvm-project#204795): a reference argument is known
to be dereferenceable only at function entry. After the calls before the row
loop, the loads of the hash table fields (`buf`, `mask`, `has_zero`), which are
conditional on the consecutive-keys and zero-key checks, can no longer be hoisted
and are repeated on every row of `Set::executeImplCase` and of the `findKey` loops
of `Aggregator::executeImplBatch`. `set_hits` #0 +18%, `parquet_dictionary_filter`
#2 +17%, `aggregation_overflow` #0 +28% on x86.

`__builtin_assume_dereferenceable` right before the loop lets LICM hoist them
again (checked in the generated code; compiling `Set.cpp` with
`-mllvm -use-dereferenceable-at-point-semantics=false` gives the same result).

CI: https://s3.amazonaws.com/clickhouse-test-reports/praktika.html?PR=117346&sha=8675465598566b9a2f459432b9831f33b2876b86&name_0=PR
PR: ClickHouse#117346

Co-Authored-By: Claude Opus 5.5 <[email protected]>
bacek pushed a commit that referenced this pull request Nov 16, 2026
…ersion

`convertNumericGeneral` checked `isFinite` and could throw for every row. Look for NaN and Inf in a separate
pass without a branch, and convert in a loop without a check, unless the values become NULL
(`accurateCastOrNull`). The conversion loop stays scalar: a value outside of the range of the result type is
converted differently by vector instructions, so the result of a row would depend on its position.
`intDiv` #2 (`toUInt32` of `Float64`) is 1.11 to 1.12 times slower on x86-64 in the performance comparison of
clang 23; with this change it is 25% faster than before locally.

https://s3.amazonaws.com/clickhouse-test-reports/praktika.html?PR=117346&sha=3dd3995a5ef4e0b7c19340ffe509331cf3e91827&name_0=PR
ClickHouse#117346

Co-Authored-By: Claude Fable 5.2 <[email protected]>
bacek pushed a commit that referenced this pull request Nov 16, 2026
The collation sort (#2, 5M rows) and the single-column string sort (#3,
20M rows) take 1.2-1.9 s on MasterCI on both arches. They get
disabled="1" (text and number unchanged) and are appended as #9 and #10
on a quarter of the rows with max_block_size = 16384, a quarter of the
default 65409. `numbers_mt` hands out blocks of exactly max_block_size
rows, so each copy has as many blocks as its original (77 and 306): the
same number of cursors in every per-stream merge and the same 16-stream
final merge, with a quarter of the rows per block. EXPLAIN PIPELINE of
each original and its copy is identical (16 streams).

Measured on official MasterCI release builds, two servers pinned to 24
cores of one NUMA node, perf.py, 25 runs: copy / original time 0.248
(#2) and 0.252 (#3), projected CI medians 380 / 487 ms amd, 298 / 483 ms
arm. On the builds before/after ClickHouse#115869 (sorted array of cursors) #2 is
1.161x faster and its copy 1.159x; on those before/after ClickHouse#126829
(cheaper collation) 2.179x and 2.111x; #3 and its copy show no change
on either pair (1.005 / 1.008, 1.004 / 1.001), as the heap guard should.

#0 and #1 stay as they are: on this rig the ClickHouse#115869 change did not show
on them beyond the A/A resolution, so there was no measured guarantee
that copies would keep their sensitivity.

About 32 s (amd) and 29 s (arm) of query time less per master
performance job; 9 queries stay enabled, so all of them still run.

Related: ClickHouse#129258

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant