Repository navigation
Supporting lazily replicated arrays on arrayElement and arraySlice (reduces memory usage and improves performance) - #112304
Conversation
|
Workflow [PR], commit [8acb190] Summary: ✅
AI ReviewSummaryThis PR teaches Final Verdict✅ No blocking issues found in the current PR head. LLVM Coverage Report
Changed lines: Changed C/C++ lines covered: 180/235 (76.60%) · Uncovered code |
…eplication_stage2
|
📊 Cloud Performance Report ✅ AI verdict: Release-transition baseline: compared against the last 26.8 master because no 26.9 master baseline exists at or before the trusted base-commit anchor. no significant changes detected. K_source=6 K_base=2 flagged=0/65 clickbench🟢 No significant changes tpch_adapted_1_official🟢 No significant changes Debug info
|
LLVM Coverage Report
Changed lines: Changed C/C++ lines covered: 171/216 (79.17%) · Uncovered code |
… with array and indes replicated under the same expression
Build profile diff (arm_release)Comparing Binary sizes
Only the stripped binary is compared: the official master build keeps debug symbols while PR builds strip them, so the other binaries differ by construction. Object file sizes
|
| Object file | Master | PR | Δ |
|---|---|---|---|
src/Functions/GatherUtils/CMakeFiles/clickhouse_functions_gatherutils.dir/sliceDynamicOffsetBounded… |
1.19 MiB | 1.47 MiB | +290.58 KiB (+23.86%) |
src/CMakeFiles/dbms.dir/Functions/GatherUtils/createArraySource.cpp.o |
556.77 KiB | 822.96 KiB | +266.19 KiB (+47.81%) |
src/Functions/GatherUtils/CMakeFiles/clickhouse_functions_gatherutils.dir/sliceDynamicOffsetUnbound… |
968.27 KiB | 1.12 MiB | +178.88 KiB (+18.47%) |
src/Functions/GatherUtils/CMakeFiles/clickhouse_functions_gatherutils.dir/sliceFromRightConstantOff… |
906.73 KiB | 1.04 MiB | +158.40 KiB (+17.47%) |
src/Functions/GatherUtils/CMakeFiles/clickhouse_functions_gatherutils.dir/sliceFromLeftConstantOffs… |
883.97 KiB | 1021.84 KiB | +137.88 KiB (+15.60%) |
src/Functions/GatherUtils/CMakeFiles/clickhouse_functions_gatherutils.dir/sliceFromLeftConstantOffs… |
855.22 KiB | 982.12 KiB | +126.89 KiB (+14.84%) |
src/Functions/GatherUtils/CMakeFiles/clickhouse_functions_gatherutils.dir/sliceFromRightConstantOff… |
855.60 KiB | 982.47 KiB | +126.87 KiB (+14.83%) |
src/Functions/array/CMakeFiles/clickhouse_functions_array.dir/arrayElement.cpp.o |
9.36 MiB | 9.45 MiB | +89.09 KiB (+0.93%) |
src/Functions/GatherUtils/CMakeFiles/clickhouse_functions_gatherutils.dir/has_all.cpp.o |
3.02 MiB | 3.05 MiB | +32.54 KiB (+1.05%) |
src/Functions/GatherUtils/CMakeFiles/clickhouse_functions_gatherutils.dir/has_any.cpp.o |
3.02 MiB | 3.06 MiB | +32.54 KiB (+1.05%) |
src/Functions/GatherUtils/CMakeFiles/clickhouse_functions_gatherutils.dir/starts_with.cpp.o |
3.01 MiB | 3.04 MiB | +32.52 KiB (+1.06%) |
src/Functions/GatherUtils/CMakeFiles/clickhouse_functions_gatherutils.dir/ends_with.cpp.o |
3.01 MiB | 3.04 MiB | +32.51 KiB (+1.05%) |
src/Functions/GatherUtils/CMakeFiles/clickhouse_functions_gatherutils.dir/has_substr.cpp.o |
3.25 MiB | 3.28 MiB | +31.95 KiB (+0.96%) |
737 more object files are built by the master warmup baseline only (it builds every object-file target, a pull request build only clickhouse-bundle) and not compared.
Compile time of recompiled translation units
279 translation units recompiled, 2601 s compile time in total, 279 of them have a recent master baseline.
…ness's own queries After a clean fuzz run (`Fuzzer exit code is 143`), the post-fuzz liveness probe `clickhouse-client --handshake_timeout_ms=30000 --receive_timeout=5 --query 'SELECT 1'` sometimes never returns. status.tsv is then never written, praktika kills the job at its 18000 s timeout before any artifact is uploaded, and the job reports a bare ERROR with no server log. Five such runs in 45 days: PR ClickHouse#112304 (2026-08-18), PR ClickHouse#98670 (2026-08-19), PR ClickHouse#115530 (2026-08-20), true master 9816d0a `AST fuzzer (amd_release, oracle)` (2026-09-24) and PR ClickHouse#119237 `AST fuzzer (amd_debug, targeted, old_compatibility)` (2026-09-25). Only the last one printed the `1`. Two harness defects make the probe unbounded. (a) The probe is itself fuzzed on the server. query-fuzzer-tweaks-users.xml sets ast_fuzzer_runs=5 and ast_fuzzer_any_query=true on the `default` profile, and no harness-owned client call opted out. The server runs the mutated copies in a query-finish callback, and TCPHandler calls io.onFinish() after sending the data and before EndOfStream, so a fuzzed follow-up that does not finish holds the reply open after the `1` was printed. The same pin was part of ClickHouse#113248, which was closed as already integrated, but its run-fuzzer.sh half never reached master. The stress harness (ClickHouse#114127), the log export (ClickHouse#117996) and tests/clickhouse-test already pin it. (b) --receive_timeout does not bound the probe either. On a receive timeout ClientBase::receiveResult only records TIMEOUT_EXCEEDED and cancels the query; from then on it polls the connection until the server sends a packet, with no bound. A server whose connection thread never gets back to the socket holds the probe forever, which is what the four runs that printed nothing show. Pin --ast_fuzzer_runs=0 on every harness-owned client call through one variable; the fuzzer's own client stays unpinned. Run the two post-fuzz probes (the restart liveness check and the probe loop) under `timeout --signal TERM --kill-after=10 60`. A probe killed by timeout (rc 124, or 137 after the kill) is counted like the client's own "Timeout exceeded while", so a server that stops answering reaches the existing "treating server as hung" verdict after 12 retries (about 14 minutes) and the job keeps its logs. 60 s covers the probe's own worst case (30 s handshake, 5 s receive timeout, the cancel round trip) with room for a slow sanitizer server. The fallback branch now prints the probe's exit code instead of the last grep's. The pre-fuzz probes are not wrapped: the check after attaching gdb waits for gdb to load debug info on purpose, and the server is fresh there. One server-side hang the fuzzer produces, a self-deadlock when one query builds two system.stack_trace sources, is fixed separately in ClickHouse#120216. Co-Authored-By: Claude Opus 5.5 <[email protected]>
… to 26.9 The memory regression (ClickHouse#123756) is fixed in 26.9 by ClickHouse#112304, so `compatibility` below 26.9 restores the previous measurement.
Backport #112304 to 26.8: Supporting lazily replicated arrays on arrayElement and arraySlice (reduces memory usage and improves performance)
…ys on arrayElement and arraySlice (reduces memory usage and improves performance)
arrayElement and arraySlice now consume lazily replicated arrays (ColumnReplicated, produced by lazy ARRAY JOIN and JOIN under enable_lazy_columns_replication) without materializing them.
Follow up of : #111581 and #111749
Closes: #54967
Implementation:
Measured on the test workload (1000-element String arrays, 50× replication by ARRAY JOIN, 100 rows): peak memory drops from 1.12 GB to 29 MB (38×).
First Query
Second Query
MEMORY_LIMIT_EXCEEDED: tries to allocate 121.83 GiB for one 65536-row blockmax_block_size=512, 1 thread, 16384 rowsTests: a stateless test covering numeric/String/Nullable/Tuple elements, dynamic and constant offsets, negative and Nullable indexes, empty arrays, ARRAY JOIN and JOIN producers, UInt16 replication indexes, plus a performance test comparing both settings.
Changelog category (leave one):
Changelog entry (a user-readable short description of the changes that goes into CHANGELOG.md):
arrayElement and arraySlice now read lazily replicated arrays (produced by ARRAY JOIN and JOIN when enable_lazy_columns_replication is enabled) directly, without materializing them. This greatly reduces memory usage
and improves performance of queries that index or slice a large array.
Workflow [PR]
Sync PR [sync-upstream/pr/112304]
Version info
26.9.1.195-master(included in26.9and later)26.8.22.8