Skip to content

Make the lazy_columns_replication arrayJoin query measure lazy replication again - #132196

Merged
Algunenano merged 1 commit into
ClickHouse:masterfrom
groeneai:groeneai/perf-lazy-columns-replication-subquery-copy
Nov 17, 2026
Merged

Algunenano merged 1 commit into
ClickHouse:masterfrom
groeneai:groeneai/perf-lazy-columns-replication-subquery-copy

Conversation

@groeneai

@groeneai groeneai commented Nov 17, 2026 •

Copy link
Copy Markdown
Collaborator

Related: #129258

Changelog category (leave one):

  • CI Fix or Improvement (changelog entry is not required)

Changelog entry (a user-readable short description of the changes that goes into CHANGELOG.md):

...

Description

Query 0 of lazy_columns_replication.xml, select randomString(1024 * 1024), arrayJoin(range(10240)) format Null, takes 3.41 s on MasterCI amd and 2.91 s on arm, with 16 GiB of memory; before #122240 it took 0.002-0.003 s. Since #122240 a non-deterministic function next to arrayJoin is evaluated once per output row, so the query builds 10240 strings of 1 MiB and replicates none: with enable_lazy_columns_replication = 0 it takes the same time.

No existing query number or text changes: 1 query is disabled and 1 appended as 2. The copy is the same query with the string from a subquery, which arrayJoin replicates 10240 times, as query 0 did before #122240.

Validation: on the official amd builds right before #122240, of its merge, and of current master, the copy takes 0.002-0.003 s and over 1000x longer (3.6 s) with enable_lazy_columns_replication = 0; query 0 was over 1000x slower without it before #122240 and takes the same time without it after. perf.py on the final file runs only queries 1 and 2, also with CI's --max-queries 10 --soft-max-queries; the copy takes 0.003-0.004 s with 2.9 MB of memory.

This saves about 40 s of query time per master perf job on amd. The copy restarts the history of 1 query.

🤖 Generated with Claude Code


Workflow [PR]
Sync PR [sync-upstream/pr/132196]

Version info

  • Merged into: 26.11.1.2625-master (included in 26.11 and later)

…plication again

No existing query number or text changes: 1 query is disabled and 1 appended as 2.

Since ClickHouse#122240 a non-deterministic function next to `arrayJoin` is evaluated once
per output row, so query 0 builds 10240 strings of 1 MiB (3.41 s amd / 2.91 s arm
on MasterCI, 16 GiB) and replicates none: with `enable_lazy_columns_replication = 0`
it takes the same time. The copy takes the string from a subquery, which is fixed
per source row, so `arrayJoin` replicates it again, as query 0 did before ClickHouse#122240.

On the official amd builds right before ClickHouse#122240, of its merge and of master, the
copy takes 0.002-0.003 s and 3.57-3.69 s (over 1000x) with lazy replication off,
the same eager work as the old query 0 (0.997-1.03); query 0 was over 1000x
slower without lazy replication before ClickHouse#122240 and takes the same time after.
Saves about 40 s of query time per master perf job on amd.

Related: ClickHouse#129258

Co-Authored-By: Claude Opus 5.5 <[email protected]>
@clickhouse-gh

clickhouse-gh Bot commented Nov 17, 2026 •

Copy link
Copy Markdown
Contributor

Workflow [PR], commit [6a35133]

Summary: ✅


AI Review

Summary

Restores the arrayJoin benchmark in lazy_columns_replication.xml by generating its 1 MiB string in a subquery before expanding it into 10240 rows. The obsolete query is disabled with its history index preserved, and the replacement is appended as query 2. No actionable findings; the code trace and reported measurements with enable_lazy_columns_replication enabled and disabled support the change.

Final Verdict

✅ Approve

@clickhouse-gh clickhouse-gh Bot added the pr-ci label Nov 17, 2026
@groeneai

Copy link
Copy Markdown
Collaborator Author
Internal second-model review: adjudication log (click to expand)

Pre-publication review by an independent model (engine: codex; 0 findings) plus my own cold review (1 nit).

# Sev Finding Verdict Evidence / action
1 💡 The description's saving ("about 40 s") is lower than the local measurement (43.5 s per job) DISAGREE The figure is CI's own median times 12 executions (3.41 s x 12 = 40.9 s on amd); none

Severity: ❌ blocker / ⚠️ major / 💡 nit. DISAGREE verdicts carry recorded evidence and are terminal per finding.

Session id: cron:clickhouse-review-slot-8:20261117-015700

@groeneai

Copy link
Copy Markdown
Collaborator Author
Pre-PR validation gate (click to expand)
# Question Answer
a Deterministic repro? Yes. On master (official amd build f0349a6), query 0 takes 3.55-3.65 s and 17.18 GB in every clickhouse local probe run and every perf.py run (CI median 3.41 s amd, 17,180,731,392 bytes).
b Root cause explained? Since #122240 a non-deterministic function next to arrayJoin is evaluated once per output row, so randomString(1024 * 1024) is built 10240 times after the expansion and nothing is replicated: with enable_lazy_columns_replication = 0 query 0 takes the same time (ratio 0.997-1.036).
c Fix matches root cause? Yes. The appended copy takes the string from a subquery, which is fixed per source row on every build, so arrayJoin replicates one 1 MiB string 10240 times again. No input shrunk, no setting pinned.
d Test intent preserved / new tests added? Yes. The copy is 1190-1843x slower with lazy replication off on the builds before #122240, of its merge, and of master, and does the same eager work as the old query 0 (0.997-1.03). Query 1 is untouched. Test-only change.
e Both directions demonstrated? Yes. Query 0 is sensitive to lazy replication before #122240 (1740-1815x) and not after; the copy is sensitive on all three builds; four negative probe inputs make the check fail.
f Fix is general across code paths? Only this perf file has a non-deterministic function next to arrayJoin in the same SELECT; quantile_merge.xml already takes rand() from a subquery.
g Fix generalizes across inputs (params/datatypes/wrappers)? N/A (no engine change); the copy keeps the original 1 MiB x 10240 shape.
h Backward compatible? (maintainer-approved exception only) Yes. The copy uses no setting and runs on builds before and after #122240; no settings or formats change.
i Invariants and contracts preserved? Queries 0 and 1 keep their text and number (perf.py --print-queries), the copy is appended as 2 (a fresh index), and the disabled query never runs (0 query_log rows in both final passes).

Session id: cron:clickhouse-impl-slot-4:20261117-013900

@clickhouse-gh clickhouse-gh Bot added can be tested Allows running workflows for external contributors comp-testing Test content only (no production code). labels Nov 17, 2026
@Algunenano Algunenano self-assigned this Nov 17, 2026
@Algunenano
Algunenano added this pull request to the merge queue Nov 17, 2026
Merged via the queue into ClickHouse:master with commit c464ce5 Nov 17, 2026
571 of 573 checks passed
@robot-ch-test-poll2 robot-ch-test-poll2 added the pr-synced-to-cloud The PR is synced to the cloud repo label Nov 17, 2026
@clickhouse-gh clickhouse-gh Bot added comp-query-execution Runtime execution pipeline, processors, vectorized operators, resource management during execution. and removed comp-testing Test content only (no production code). labels Nov 22, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

can be tested Allows running workflows for external contributors comp-query-execution Runtime execution pipeline, processors, vectorized operators, resource management during execution. pr-ci pr-synced-to-cloud The PR is synced to the cloud repo

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants