Repository navigation
Remove dead string_columns code in BufferedV1 WASM UDF executor - #11
Conversation
Created using spr 1.3.7
bacek
pushed a commit
that referenced
this pull request
May 14, 2026
`norm_distance #9` (`BFloat16 L1Distance`) regressed ~10% and `#11` (`BFloat16 LinfDistance`) regressed ~7-12% on AMD release. The hot loop is the auto-vectorised `states[VEC_SIZE]` accumulator in `FunctionArrayDistance::executeWithLeftArgConst`. At `-march=x86-64-v3` clang collapses the 8 separate scalar accumulators into a single 256-bit YMM register and emits `vpmovzxwd` + `vpslld 16` for the BF16->Float32 expansion (vs master's `pxor`/`punpcklwd` against XMM with two parallel accumulators). `perf stat` confirms the resulting code runs *fewer* instructions (-40%) but at *much* lower IPC (3.40 -> 1.89) - the longer per-iteration latency chain on `vaddps`/`vmaxps` is the bottleneck. Tweaking the source - bumping `VEC_SIZE` from 8 to 16, or splitting into two parallel `states_a`/`states_b` arrays - made things *worse* (clang re-collapses them), so the fix is the same file-level `-march=x86-64-v2` override already used for `arrayNorm.cpp`. The `accumulateCombineBF16` AVX-512 specialisation for `L2Distance`/ `CosineDistance` is guarded by `__attribute__((target("...")))` and keeps its Sapphire Rapids codegen even with the file-level flag. Bench (Sapphire Rapids LTO, single-threaded, server-side): - `L1Distance(BF16)`: master 0.239s, PR 0.240s (was 0.264s, +10%) - `LinfDistance(BF16)`: master 0.290s, PR 0.289s (was 0.311s, +7%) Co-Authored-By: Claude Opus 4.7 (1M context) <[email protected]>
bacek
pushed a commit
that referenced
this pull request
Nov 16, 2026
clang 23 vectorizes the row loop of `BinaryOperation::process` for `PlusImpl` and `MinusImpl` with a 256-bit result on AArch64: interleaved `ld4`/`st4` of two rows and a `cmhi` per limb to recover the carry, instead of the scalar `adds`/`adcs` chain that clang 22 emits. `wide_integer_add_sub` #9 and #11 are 1.48 and 1.24 times slower on AArch64. Set `no_vectorize` for these two operations when the result is wider than 16 bytes. Other operations on 256-bit integers, such as the bitwise ones, stay vectorized. https://s3.amazonaws.com/clickhouse-test-reports/praktika.html?PR=117346&sha=8f5f84ea035e5a7555cce45519db14963ea8fb59&name_0=PR ClickHouse#117346 Co-Authored-By: Claude Fable 5.2 <[email protected]>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
In
UserDefinedWebAssemblyFunctionBufferedV1::executeOnBlockthere wasa loop that collected pointers to
ColumnStringcolumns into a localvector, but the vector was never read after the loop — making the entire
block dead code.
The loop logic was also incorrect: the
elsebranch calledstring_columns.clear(), erasing all previously collected pointerswhenever 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