Repository navigation
Stabilize the nested-array queries of the array_first_last performance test - #122691
Conversation
Query ClickHouse#7 of tests/performance/array_first_last.xml (arrayLast over Array(Array(UInt64))) takes a different time in each server process of the same build. In 14 days of Performance Comparison runs on amd it moved by more than 15% between the two servers in 50 of 633 runs, 36 of them master against master, while ClickHouse#6 (arrayFirst over the same column) moved in 0 of 641 and the tuple queries ClickHouse#4/ClickHouse#5 in 2 and 3; arm is quiet. Per run, ClickHouse#6 and ClickHouse#7 move in opposite directions (r = -0.53 over 524 amd runs; in 33 of the 37 runs where ClickHouse#7 moved by more than 15%, ClickHouse#6 moved the other way), while ClickHouse#4/ClickHouse#5 move together (r = +0.42). Each nested_values row holds 32 inner arrays of 2 UInt64, so rows are 256 bytes apart in the inner offsets and 512 bytes apart in the data. ClickHouse#6 and ClickHouse#7 read one inner array per row, so for the whole query every row is read at the same position modulo 256/512 bytes, i.e. at the same few offsets inside every memory page. Which offsets those are depends on where the column is allocated: jemalloc is built with cache_oblivious, which puts every large allocation at a random multiple of 64 bytes inside its first page, and the table is filled once per server. So each server reads the column at its own fixed page offsets. Fill nested_values with 31 inner arrays per row. Rows are then 248/496 bytes apart and the read position walks through every offset of the page within one query, so the timing no longer depends on the allocation. The query texts and the per-row work (one copy of a 2-element array per row, 250000 rows) are unchanged. Local check with the official master build 26.10.1.906 on a Xeon 6975P-C: 16 separately filled copies of the table per arm in one server, measured round-robin for 20 rounds. This machine does not show the spread with either layout (ClickHouse#7 across copies: 14.14-14.68 ms with 32 elements and random allocation offsets, 13.93-14.27 ms page-aligned with MALLOC_CONF=cache_oblivious:false, 13.95-14.32 ms with 31 elements), so it cannot confirm the mechanism and the change rests on the CI data. The level of ClickHouse#7 stays (31 vs 32 elements: 0.98x); ClickHouse#7/ClickHouse#6 goes from 1.11 to 1.03. Related: ClickHouse#120510 Co-Authored-By: Claude Opus 5.5 <[email protected]>
Internal second-model review: adjudication log (click to expand)Pre-publication review by an independent model (engine: codex): 0 findings on this head. My own cold review of the diff, done before reading the implementation's evidence, found no blocker or major. I re-derived the table and the Session id: cron:clickhouse-review-slot-49:20260928-142200 |
|
Workflow [PR], commit [5ae9ce9] Summary: ❌
AI ReviewSummaryThis PR changes Findings
Final VerdictChanges requested: the benchmark update still needs a before/after measurement on the new |
| SELECT | ||
| arrayMap(x -> (x, x), range(32)), | ||
| arrayMap(x -> [x, x], range(32)) | ||
| arrayMap(x -> [x, x], range(31)) |
There was a problem hiding this comment.
This changes the benchmark workload to claim better stability, but this PR is not labeled pr-performance, so all six Performance Comparison shards are skipped and the new 31-element layout never gets measured on the amd runner that showed the inter-server variance. The existing evidence proves the old 32-element layout is noisy; it does not yet prove that this replacement is stable. Please attach a focused before/after run for this layout or rerun with perf CI enabled.
…st-last-nested Co-Authored-By: Claude Opus 5.5 <[email protected]>
CI finish ledger - 5ae9ce9Every failure below has an owner: a fixing PR (mine or external), or a full-effort fix task
This PR's own queries ran on the amd 2/6 shard and were not flagged: All 146 check runs completed (16 passed, 128 not selected, 2 red), Session id: cron:our-pr-ci-monitor:20260928-200457 |
ce7f8c1
Related: #120510
Changelog category (leave one):
Changelog entry (a user-readable short description of the changes that goes into CHANGELOG.md):
Not required: CI-only change.
Description
array_first_last #7(arrayLast(x -> 1, nested_values)) takes a different time in each server process. On #120510 it was the only red of amd 6/6: 30 of 30 runs took 12.60-13.98 ms on the old server, 14.73-16.49 ms on the new one (dashboard: +15.5%,confirmed_regression), while#6(arrayFirst, same column) went 14.40 -> 13.61 ms. Master too: amd 1/6 @66276279, 13.18 -> 15.67 ms.Runs moving >15% between the servers (amd, 14 days, raw samples):
arm: at most 1 of ~1300 runs each. Over 524 runs measuring both,
#6and#7move in opposite directions (r = -0.53; in 33 of 37 where#7moved,#6moved the other way), while the tuple twins#4/#5move together (+0.42).Each
nested_valuesrow holds 32 inner arrays, so rows are 256/512 bytes apart (inner offsets/data) and every row is read at the same few offsets of each memory page. Which offsets depends on the allocation: jemalloc (cache_oblivious) puts each large allocation at a random multiple of 64 bytes within its first page, once per server fill.I changed the rows to 31 inner arrays: rows are 248/496 bytes apart, so one query walks through every page offset. Query texts and per-row work are unchanged;
#4/#5keep 32 elements.Locally (x86, official master build, 16 separately filled copies per layout in one server, 20 rounds) no layout shows the spread, so this machine cannot confirm the mechanism:
#7across copies 14.14-14.68 ms (32, random offsets), 13.93-14.27 ms (32, page-aligned), 13.95-14.32 ms (31). The level of#7stays (0.98x);#7/#6goes from 1.11 to 1.03.🤖 Generated with Claude Code
Workflow [PR]
Sync PR [sync-upstream/pr/122691]
Version info
26.10.1.945-master(included in26.10and later)