Repository navigation
Conversation
Add `no-darwin` tag to `clickhouse-test`: tests tagged with `no-darwin` are skipped when running on Darwin (macOS). Document the tag in `docs/en/development/tests.md`. This prepares the ground for migrating macOS skip lists from `fast_test.py` into individual test files. Co-Authored-By: Claude Sonnet 4.6 <[email protected]>
leshikus
pushed a commit
that referenced
this pull request
Apr 27, 2026
…079-3df0) `LimitSeekableReadBuffer::seek` used the expression `pos + position_change` inside its in-buffer fast-path check. When the inner buffer has not materialized its memory yet — as is the case for `EmptyReadBuffer`, `ParallelReadBuffer`, and `ReadWriteBufferFromHTTP`, all of which start with `pos == nullptr` — and a non-zero seek is requested before the first `next()`, this triggers undefined behavior per [expr.add]: "applying non-zero offset N to null pointer". On master BuzzHouse (arm_asan_ubsan) this surfaced from the BACKUP write path as STID 3079-3df0: ``` src/IO/LimitSeekableReadBuffer.cpp:97:34: runtime error: applying non-zero offset 1178 to null pointer #0 DB::LimitSeekableReadBuffer::seek(long, int) #1 DB::BackupWriterDefault::copyDataToFile(...) #2 DB::BackupImpl::writeFile(...) #3 DB::BackupsWorker::writeBackupEntries(...) ``` Replace the pointer-arithmetic comparison with an equivalent check expressed via pointer *differences* and integer arithmetic, which is well-defined regardless of whether `pos` is null. The condition is mathematically identical to the original for all legal inputs. Add `gtest_limit_seekable_read_buffer.cpp` covering the null-`pos` regression plus two sanity tests for the in-buffer and out-of-buffer seek paths. Without the fix the first test reproduces the exact UBSan error from CI; with the fix all three pass cleanly under `-fsanitize=address,undefined`. CI report: https://s3.amazonaws.com/clickhouse-test-reports/json.html?REF=master&sha=4b8132993ce0625e9c0ed0bf15ed16eb6df8262b&name_0=MasterCI&name_1=BuzzHouse+%28arm_asan_ubsan%29
leshikus
pushed a commit
that referenced
this pull request
May 13, 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]>
leshikus
pushed a commit
that referenced
this pull request
May 13, 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]>
leshikus
pushed a commit
that referenced
this pull request
May 13, 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]>
leshikus
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.
leshikus
pushed a commit
that referenced
this pull request
Jun 8, 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.
leshikus
pushed a commit
that referenced
this pull request
Jul 6, 2026
The "Docker server image" job builds the distroless/alpine/ubuntu images with `docker buildx build`. buildx resolves the SBOM scanner image (docker/buildkit-syft-scanner, pulled because of --sbom=true) and base images from docker.io. When docker.io has a transient outage, the build fails at: #2 resolve image config for docker-image://docker.io/docker/buildkit-syft-scanner:stable-1 #2 ERROR: unexpected status from HEAD request to https://registry-1.docker.io/... and the downstream "docker library image test" then reports "image does not exist!" as a secondary victim. praktika's Shell.run / Result.from_commands_run already support retries with exponential backoff and an error allowlist, but the buildx build and the imagetools merge commands ran with no retries. Wire retries=5 and an allowlist of transient registry/network signatures into both. The allowlist keeps fail-fast behavior for genuine Dockerfile/build errors. This mirrors the existing retry hardening for the in-Dockerfile wget downloads (ClickHouse#105139) and the keeper image S3 artifact fetch (ClickHouse#108675). Co-Authored-By: Claude Opus 4.8 <[email protected]>
leshikus
pushed a commit
that referenced
this pull request
Jul 14, 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]>
leshikus
pushed a commit
that referenced
this pull request
Jul 28, 2026
leshikus
pushed a commit
that referenced
this pull request
Jul 31, 2026
The fix in this PR makes three FilterTransform call sites compose their
applied filter into ChunkInfoRowNumbers. Only the two stripped-PREWHERE
fallback filters were covered by 04615; the Iceberg equality-delete
notIn filter was not, so the equality-delete half of the contract was
unproven.
Reverting only the equality-delete call site to the old behaviour makes
the new test fail, and pristine master fails it too: on a table that
carries equality delete files the _row_number column is built from a
stale mask, which either aborts with a column length mismatch
("Expected the argument #2 ('__table1._row_number' of type Int64) to
have 423 rows, but it has 470") or silently yields compacted post-filter
indices instead of physical row positions. Those indices are what the
mutation path writes into positional delete files, so a wrong value
deletes the wrong rows.
The test uses the existing committed fixtures: deletes_db/eq_deletes_table
(equality plus position deletes, also read under PREWHERE so the fallback
filter stacks on top of the notIn filter) and
deletes_db/eq_deletes_required_table (equality deletes only, where the
exact physical row numbers are asserted). The per-file offset assertion is
independent of the engine path: it is checked against the raw Parquet data
files read directly through s3().
Co-Authored-By: Claude Fable 5 <[email protected]>
alexey-milovidov
pushed a commit
that referenced
this pull request
Aug 20, 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
leshikus
pushed a commit
that referenced
this pull request
Sep 25, 2026
Review asked to keep the block sizes always a power of two, so the fill's `max_block_size` moves from 65409 to 65536. It now matches the `max_insert_block_size` beside it and tests/performance/join_convert_full_to_left_or_right.xml, which pins the same pair at 65536. 65409 was the current default of the setting (`DEFAULT_BLOCK_SIZE` in src/Core/Defines.h, 65536 minus the SIMD padding), so the pinned value is now a deliberate round number instead of a restatement of that default. The comment dropped the sentence naming 65409 as the default, which the swap makes false, and states the invariant the pin buys instead. Nothing the test asserts or measures changes. Both tables still write 16 active parts, so the `throwIf` oracles stand; the cut moves from 15 x 65409 rows + 18865 to 15 x 65536 + 16960. Measured with `EXPLAIN indexes = 1` on all three queries, 65409 -> 65536: #0 parts 3/16 unchanged, index range 39246 -> 39321 granules, read 3 -> 3 #1 parts 1/16 unchanged, read 1 -> 1 #2 parts 12/16 unchanged, 156984 -> 157284 granules, read 133114 -> 133110 The +0.19% is the range the skip index walks, not the data read. With both sides at one layout the worst arm spread measured on #0 is +9.6% over 5537 jobs, against the check's 15% floor, so the shift is far below either.
leshikus
pushed a commit
that referenced
this pull request
Oct 10, 2026
…ce test Query #1 cast a String to JSON inside the measured query, so most of its CPU (about 80% in the arm CI profile, 72% on x86 locally) went to the JSON parser rather than to the serializing hash the test exists for. The parse has a per-server-process slow mode, so a slow draw on the tested server read as a hashing regression and turned unrelated PRs red (Performance Comparison on ClickHouse#117318: +15.8%, gone after a server restart). Build the JSON column once at fill time in a Memory table and hash the stored column, single-threaded as before and as in query #2. JSON parsing itself stays measured by new_json_type. Co-Authored-By: Claude Opus 5.5 <[email protected]>
leshikus
pushed a commit
that referenced
this pull request
Oct 13, 2026
SipHash kept the current partial 8-byte word as a union of a UInt64 and UInt8[8]. `update` wrote a short tail byte by byte into the byte array (the remainder of a previous update too, which clang emits as a `memcpy`), and `finalize` stored the `cnt` byte into the last position and then read the whole word with one 8-byte load. An 8-byte load that overlaps several narrower in-flight stores cannot be store-forwarded on x86: it waits until the stores commit (`ld_blocks.store_forward`). When the hash state lives in memory across a call, e.g. `UniqVariadicHash::apply` -> virtual `IColumn::updateHashWithValue` -> `get128`, every row pays this. How often the blocked load is replayed depends on code placement, so the same machine code is fast in one build and ~55% slower in another: this is why `entropy #2` of the performance comparison flips between ~0.33 s and ~0.52 s per build on amd (master builds 4f8c9f2..a0b6517, and PR builds of ClickHouse#117704, ClickHouse#114690, ClickHouse#119760). Now `current_word` is a plain UInt64 holding the received bytes of the current word in little-endian order, the bytes not received yet being zero (the same numeric value the union had on both endiannesses, so CURRENT_BYTES_IDX is gone). `loadTail` assembles up to 7 bytes in a register with overlapping 4/1-byte loads, the remainder path ORs it in at the right shift, the main loop keeps the word in a local, and `finalize` folds `cnt` into the top byte in a register. Every access to `current_word` is now a whole-word store followed by a whole-word load. Hash values are unchanged. Validation (release build, CMAKE_BUILD_TYPE=None without ThinLTO, Xeon 6975P, `SELECT entropy(MobilePhoneModel)` over 100M rows of a 92%-empty sparse String column, max_threads=16, medians of 18 runs): - base 0.218 s, fix 0.150 s; official master builds 562bdc1 0.204 s (fast layout) and 4f8c9f2 0.285 s (slow layout). - 15 queries: ld_blocks.store_forward base 1.54e9, fix 2.7e7 (slow official 6.07e9); cycles 1.44e11 -> 8.98e10; instructions 5.27e11 -> 4.71e11. - `uniqExact(toString(number % 1000), toString(number % 7))` over 2e8 rows 5.23 s -> 2.98 s; sipHash64/sipHash128 of 1..5-byte strings -6.4%/-4.8%; sipHash64 of 10..50-byte strings +1.1% (instructions +1.8%); GROUP BY two String keys unchanged. - Hash identity: a throwaway differential gtest against the verbatim previous class (every length 0..80 x every 3-way split, 3 key pairs, get64/get128/get128Reference, double get, update after get, the ColumnString row shape, 300k random streams of raw and typed updates): 2,038,362 cases, 0 mismatches; a planted mutation (wrong value for 4-byte tails only) gives 808,592 mismatches. 02534_keyed_siphash and 02552_siphash128_reference (official vectors) pass, and SQL sums of sipHash64/128, keyed and reference variants over 2e7 strings are equal on both binaries. Co-Authored-By: Claude Opus 5.5 <[email protected]>
leshikus
pushed a commit
that referenced
this pull request
Oct 13, 2026
The performance test `uniq_stored` query #2 (merging 2 million stored single-element `uniq` states) regressed by 22% on ARM: the chunked read and the batched merge add overhead that does not pay off for tiny states. Restore the scalar read for `m_size <= 1` and use the plain merge loop when the right-hand state has fewer than `insert_many_batch_size` elements. https://s3.amazonaws.com/clickhouse-test-reports/praktika.html?PR=111493&sha=f844d188b1bf6c9c553a5346b12da46a93d601ed&name_0=PR&name_1=Performance%20Comparison%20%28arm_release%2C%20master_head%2C%201%2F6%29 ClickHouse#111493 Co-Authored-By: Claude Opus 5.5 <[email protected]>
leshikus
pushed a commit
that referenced
this pull request
Oct 13, 2026
…ance test With `optimize_rewrite_like_perfect_affix=0`, every row of the fixture matches, so `MatchImpl` calls the dispatched StringZilla `sz_find` once per row, 10M times per query. On amd the cost of that call varies by 5-10% between binaries and between server processes (the red run's extra CPU samples are all in `sz_find_skylake`), so over 30 days the old/new ratio of `#0` crossed 15% in 29 of 1,193 master-vs-master runs and 26 of 1,316 PR runs (median 1.001), and reddened `Performance Comparison (amd_release, master_head, 2/6)` on unrelated ClickHouse#122420 (+20.9%, +17.2% after restart). `#2` behaves the same. The rewrite-on arms never crossed 15% on amd (0 of 2,518, p99 1.109 / 1.081). The harness compares the same query index across builds, never one arm against another, so the `=1` arms are the detector for the rewrite: if it stopped applying they would get 1.6x to 1.7x slower. The rewrite-off LIKE path stays measured by the two `optimize_rewrite_like_perfect_affix = 0` arms of `regexp_anchored_literal.xml` (0 runs above 12% in over 1,050 amd runs each), and correctness by `03594_like_perfect_affix_rewrite_pass`. Same shape as ClickHouse#122156. The survivors renumber to #0/#1, so their learned thresholds reset to the 0.15 floor, which is above their p99. Co-Authored-By: Claude Opus 5.5 <[email protected]>
leshikus
pushed a commit
that referenced
this pull request
Oct 30, 2026
…ee stack placements Since ClickHouse#126977 both perf servers start with ASLR disabled, so every start of a binary puts its thread stacks at the same place. A change that only moves the query threads' frames within their stack pages (on ClickHouse#112928, `ThreadPool` worker frames 32 bytes larger) then reproduces at every restart: `set_in_clustered_keys` #2/#3 were 28-32% slower on arm with an instruction-identical `keys256` probe and equal static TLS, and the confirmation rerun reproduced them (+27.1%, +29.8%), so the shard stayed red. `confirm_changes` now reruns the flagged queries at three placements: the main run's own, and with `glibc.rtld.optional_static_tls` = 512 + 21*64 and 512 + 43*64 for both servers (glibc puts the static TLS block at the top of every thread stack, so all thread stacks move 1344 and 2752 bytes lower). `restart` takes the surplus as an optional argument; without it nothing changes. `eqmed.sql` runs separately per placement, step 5's rule is evaluated per placement, and `query-metric-stats.tsv` gets, per query, an actual placement row on the side of the two-of-three majority (the one farthest from the thresholds), so step 5 and the dashboard check in `performance_tests.py`, which are unchanged, reach the majority verdict. With fewer than three placements measured (a failed restart or rerun, the time budget), the placement 0 row is used, which is the previous behaviour; without it the original verdict stands. The per-placement verdicts go to `placement-verdicts.tsv` and the job log. Co-Authored-By: Claude Opus 5.5 <[email protected]>
leshikus
pushed a commit
that referenced
this pull request
Nov 13, 2026
9 of the 11 queries of sparse_grams and sparse_grams_index_build ran 1-8.3 s on the CI amd runner (14-day MasterCI medians). Following the disabled-marker rule for performance tests (no existing query text or number changes), the 9 long queries get disabled="1" and the same 9 queries are appended on fewer rows: - sparse_grams: #1/#2 10M -> 1M rows (#6/ClickHouse#7), #4 10M -> 700k (ClickHouse#8), #5 4M -> 250k (ClickHouse#9). - sparse_grams_index_build: #0-#4 run again as #5-ClickHouse#9 on a 60_000-row sg_src_small (same randomPrintableASCII(200) generator) instead of the 150_000-row sg_src; the text-index INSERT takes LIMIT 2_500 instead of 30_000. sg_src was read only by the disabled queries, so its create, fill and drop are replaced by sg_src_small's. Function, string generator and length, index definitions, granularity and settings are unchanged; only the row counts change. Related: ClickHouse#129258 Co-Authored-By: Claude Opus 5.5 <[email protected]>
leshikus
pushed a commit
that referenced
this pull request
Nov 13, 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]>
leshikus
pushed a commit
that referenced
this pull request
Nov 13, 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 ClickHouse#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-ClickHouse#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-ClickHouse#7 100 groups 0.86-1.03, no CI lower bound above 1.0 (4-15 ms)
ClickHouse#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; ClickHouse#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 / ClickHouse#8, so the direct staging is 4.3x and
2.3x faster than that on #0 and ClickHouse#8.
Co-Authored-By: Claude Opus 5.5 <[email protected]>
alexey-milovidov
pushed a commit
that referenced
this pull request
Nov 15, 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]>
leshikus
pushed a commit
that referenced
this pull request
Nov 19, 2026
`writeRowEndDelimiter` and the other delimiters wrote two pieces, so the first `writeSlow` call was not a tail call and the functions needed a stack frame; with PAC on AArch64 that is a signed return address per row. Graviton4, PAC + BTI build, `json_key_formatting` before -> after: #0 0.526 s -> 0.498 s, #1 0.529 s -> 0.498 s, #2 0.968 s -> 0.936 s; CI master without branch protection: 0.495 s, 0.498 s, 0.916 s. Output of all `JSONEachRow`-family formats is unchanged, with and without pretty printing and `output_format_json_array_of_rows`. https://s3.amazonaws.com/clickhouse-test-reports/praktika.html?PR=130510&sha=latest&name_0=PR ClickHouse#130510 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.
Add
no-darwintag support toclickhouse-test: tests tagged withno-darwinare skipped when running on Darwin (macOS). Document thetag in
docs/en/development/tests.md.Prepares the ground for migrating macOS skip lists from
fast_test.pyinto individual test files using
-- Tags: no-darwin.Changelog category (leave one):