Repository navigation
Conversation
`wasm_exceptions(true)` is required to instantiate modules compiled with `-fexceptions`. Without it, Wasmtime rejects such modules at instantiation. Co-Authored-By: Claude Sonnet 4.6 <[email protected]> commit-id:6d3214c8
This was referenced Mar 13, 2026
bacek
pushed a commit
that referenced
this pull request
May 14, 2026
…tion` regressions `generate_table_function #1` (8 integer column types, 1B rows) regresses ~18% and `#5` (Date/DateTime, 1B rows) regresses ~16% on AMD release. `fillColumnWithRandomData` is a big switch over `TypeIndex` that constructs a fresh column for every block. At `-march=x86-64-v3` the SLP vectorizer lowers the implicit ~32-byte zero-init of each newly-allocated `ColumnVector`/`ColumnString` to a `vpxor xmm0; vmovdqu ymm0` pair (29 occurrences in PR vs 0 in master). Each YMM store dirties the upper YMM state, so clang inserts a `vzeroupper` (30 inserted) before every external call from the dispatcher (`operator new`, `PODArrayBase::reallocPowerOfTwoElements`, etc.) - the per-block dispatch ends up bracketed by ~30 SSE/AVX transitions for no benefit (the inner PCG generation loop is byte-equivalent to master's). The inlined PCG inner loop is the dominant per-row cost, but at v3 the broader function bloats from 16654 to 18241 bytes (+10%) and the cumulative `vzeroupper` overhead in the per-block dispatch is what surfaces as the +15-18% regression. The integer/Date paths are uniformly affected; Decimal/Float paths (#7/#8/#9) do not regress because they go through a different per-element loop with no YMM zero-init. Compiling at v2 keeps the XMM-only zero-init that does not require `vzeroupper`. The hot PCG inner loop's quality is not affected (master is already at v2 and generates the same scalar code). Local Sapphire Rapids LTO (max_threads=12, 10 iter): - `#1`: master 0.521s, PR 0.521s (was 0.614s, +18%) - `#5`: master 0.177s, PR 0.178s (was 0.208s, +16%) Co-Authored-By: Claude Opus 4.7 (1M context) <[email protected]>
bacek
pushed a commit
that referenced
this pull request
May 26, 2026
The point-lookup queries (#4-#7) in apply_patch_parts_join produced 18-30% test noise because the four UPDATE statements that build the patch parts ran with default parallelism. Parallel threads racing into the patch builder produce different patch-part split boundaries on every run, which changes how many patch granules a point lookup at id=5000000 ends up reading. Per-server timing then depends on the random split, not on the code being measured. Force INSERT and UPDATE to use a single thread plus a block size large enough to fit each whole patch, so the patch-part layout is the same on every run. Locally verified deterministic over 20 cycles. Setup time goes from ~4.2s to ~6.3s. Scan queries (#0-#3) still detect patch-apply-path regressions as before. Refs ClickHouse#100759.
bacek
pushed a commit
that referenced
this pull request
Aug 26, 2026
`AggregatingTransform::initGenerate` used `many_data->variants.size()` as the
number of producers to wait for on the finish barrier. That vector is sized at
construction and used to be immutable afterwards, but the adaptive aggregation
made the last finisher append the early-drain routing table to it, so the
vector grows while the producers that are still arriving read its size:
Write of size 8 ... by thread T1033:
#7 DB::AggregatingTransform::initGenerate() src/Processors/Transforms/AggregatingTransform.cpp:1375
Previous read of size 8 ... by thread T1187:
#1 DB::AggregatingTransform::initGenerate() src/Processors/Transforms/AggregatingTransform.cpp:1319
Count the producers with `ManyAggregatedData::num_producers`, fixed at
construction time, so the barrier never reads the vector that the last
finisher grows. The barrier's outcome is unchanged: only the finisher whose
`fetch_add` returns `num_producers - 1` proceeds, and it is the only thread
that touches `variants` afterwards.
CI report:
https://s3.amazonaws.com/clickhouse-test-reports/json.html?REF=master&sha=ed4df189fc08473dd6cee5c84b4fce89d49ca640&name_0=MasterCI&name_1=Stress%20test%20%28arm_tsan%29
Caused by: ClickHouse#111459
bacek
pushed a commit
that referenced
this pull request
Oct 23, 2026
…h set When `hasAny(Array(String), <constant Array(String)>)` does not build the needle hash set for a block (fewer than 4 needles, a needle longer than 256 bytes, or a block too small for the set to pay off), it used to fall back to the generic GatherUtils path. That path makes two virtual calls per row from the per-row loop of `arrayAllAny` (`ColumnString::structureEquals` from `sliceHas`, and `ColumnString::compareAt` per element/needle pair). The speed of that loop turned out to depend on code placement. Three PR builds of 2026-10-18 (ClickHouse#123788, ClickHouse#100394, ClickHouse#63383; their diffs share no file and none touches Functions/ or Columns/) ran `has_any_constant_string_needles` queries #5 and #6 1.2-2.1x slower than the master reference in all three process lifetimes of their perf job, on three different runners, with md5-identical machine code for the four functions involved. Across 24 inspected CI builds, a build is slow exactly when a 64-byte line of `compareAt` or `structureEquals` coincides with a line of the `arrayAllAny` loop modulo 8 KiB (3/3 slow, 0/21 fast). Reproduced locally with the CI binaries: query #6 takes 1.04-1.35 s on the three slow builds vs 0.62 s on three fast ones, at equal instruction counts. Now the declined block compares each element with each needle directly (`getDataAt` + `memequalSmallAllowOverflow15`, the comparison `ColumnString::compareAt` makes), in the generic path's order (needles outer, elements inner, first match wins). The loop has no call left, and it is faster for every declined shape: on a release build, perf test queries #4-#7 take 0.73-0.91x of the base time and #0-#3 (set path) are unchanged. Adds perf query #7 for the fewer-than-4-needles branch, the only declined branch the test did not cover. Non-String columns still use the generic path. 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
filterWithBlanks copied the left key into the right key column of a LEFT JOIN one row at a time, with a virtual insertFrom or insertDefault per row. It now reads the filter 64 rows at a time (bytes64MaskToBits64Mask, as in filterArraysImpl): a chunk whose rows are all kept is one insertRangeFrom, a chunk whose rows are all blank is one insertManyDefaults, and any other chunk keeps the per-row loop. ColumnNullable gets an insertManyDefaults override, so a blank Nullable chunk fills the nested column and the null map in bulk instead of 64 virtual insertDefault calls. Measured on x86 release (8 pinned cores; wall = median of 21 runs, user-space instructions = median of 3 perf stat runs minus startup), base -> this commit: - join_nullable_keys_small_table #4: 0.61x wall, 0.47x instructions; #8: 0.71x / 0.55x; #3: 0.66x / 0.55x; #7: 0.80x / 0.66x. - Alternating rows and runs of 2, 3 and 100 rows: 0.86x-0.99x instructions. - Queries of the same test that do not reach filterWithBlanks: within 0.4% instructions (wall moves up to +23% between the two builds from code placement alone, with the same instruction count). The added perf query covers the per-row path (alternating matched and unmatched rows), which the existing queries of the test do not reach. The test runs all its queries (`run_all_queries`), as it now has more than the 10 that CI samples. Co-Authored-By: Claude Opus 5.5 <[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.
wasm_exceptions(true)is required to instantiate modules compiled with-fexceptions. Without it, Wasmtime rejects such modules at instantiation.Co-Authored-By: Claude Sonnet 4.6 [email protected]
Stack:
clickhouse_log2WebAssembly host function with log level argument #6"env"module imports only #4