Skip to content

Stop the Iceberg rw_features perf UPDATE queries #5 and #9 from growing the table on every run - #127380

Merged
alexey-milovidov merged 1 commit into
ClickHouse:masterfrom
groeneai:iceberg-perf-update-idempotent
Oct 23, 2026
Merged

alexey-milovidov merged 1 commit into
ClickHouse:masterfrom
groeneai:iceberg-perf-update-idempotent

Conversation

@groeneai

@groeneai groeneai commented Oct 22, 2026 •

Copy link
Copy Markdown
Collaborator

Related: #100759
Related: #116065

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):

Queries #5 and #9 of the iceberg_suite_local_rw_features and iceberg_suite_s3_rw_features performance tests no longer rewrite the same rows on every measured run, so their timings no longer drift upward within a run series.

Description

iceberg_suite_{local,s3}_rw_features #5 and #9 were the noisiest queries in #100759: flagged unstable on 63-87% of master commits from 2026-10-08 to 10-19, on both arches. Example: arm_release 5/6, 2026-10-15.

Both are Iceberg ALTER TABLE ... UPDATEs whose WHERE still matches after they ran: #5 matches the rows it already moved to partition X, and #9 matches l_partkey % 10 = 0 forever. Every run therefore commits another data file and position-delete file that the next run has to scan, and nothing resets the table between runs. In query_metric_runs_v1 (master, 10-21), the files read per run are 6, 8, ..., 18 for #5 and 4, 6, ..., 16 for #9.

With this change the prewarm run does the one real rewrite and the measured runs match nothing (AND l_returnflag != 'X'; l_quantity + 100 ... AND l_quantity < 100), which is how the suite already handles delete_position_deletes, modify_column and optimize_manifests. The rewrite and the cross-partition move still execute once per server. The measured runs now time the mutation's planning and its merge-on-read scan over a table that no longer changes.

Validation: I ran a local master build with 16 executions per variant. In the old variant, files read grow by 2 and snapshots by 1 per execution, and duration correlates with the run index at 0.99 (#5) and 0.92 (#9). In the new variant, both counts are constant after the first measured run (correlation -0.47 / -0.45). perf.py --print-queries shows every other query index unchanged in both suites.

The #9 comment no longer says the table has three data files. iceberg_insert_max_rows_in_data_file only splits at block boundaries, so it has one, on CI too.

🤖 Generated with Claude Code


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

Version info

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

…ouse#9 from growing the table

Queries ClickHouse#5 (update_partition_key_move) and ClickHouse#9 (update_every_file) of
iceberg_suite_{local,s3}_rw_features are Iceberg ALTER ... UPDATEs whose
WHERE still matches after they ran: ClickHouse#5 re-matches the rows it moved to
partition 'X', ClickHouse#9 matches l_partkey % 10 = 0 forever. Iceberg UPDATE is
merge-on-read, so every execution commits another data file and
position-delete file that the next execution scans, and perf.py has no
per-run reset. Run time therefore grows monotonically within a series
(query_metric_runs_v1, master 2026-10-21: files read per run 6, 8, ..., 18
for ClickHouse#5 and 4, 6, ..., 16 for ClickHouse#9), and the comparison reported both as
unstable on 63-87% of master commits (2026-10-08..10-19, issue ClickHouse#100759).

Make the prewarm run do the one real rewrite and later runs match nothing,
as the suite already does for delete_position_deletes, modify_column and
optimize_manifests: ClickHouse#5 adds `AND l_returnflag != 'X'`, ClickHouse#9 becomes
`l_quantity + 100 ... AND l_quantity < 100` (TPC-H l_quantity is 1..50, and
the predicate stays idempotent for any non-negative value). A mutation that
matches nothing commits nothing, so the measured runs time the mutation's
planning and merge-on-read scan over a fixed table; the rewrite itself
still executes once per server.

The ClickHouse#9 comment no longer claims three data files: the Iceberg writer only
starts a new file at a block boundary, so the 30000-row single-block INSERT
with iceberg_insert_max_rows_in_data_file = 10000 produces one file, on CI
as well (ClickHouse#9 measured run0 reads 4 = 2 passes x 2 files).

Validated locally on a master build, 16 executions per variant: the old
text grows by 2 files read and 1 snapshot per execution (corr(run,
duration) 0.99 / 0.92), the new text is constant after the first measured
run (corr -0.47 / -0.45) with the expected row counts; perf.py
--print-queries shows every other query index unchanged in both suites.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
@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 review (1 nit).

# Sev Finding Verdict Evidence / action
1 💡 The measured runs of #5/#9 no longer time the rewrite; it runs once per server, in the prewarm AGREE, noted-not-blocking Merge-on-read only (MetadataGenerator.cpp), and perf.py has no untimed per-run reset, so a timed rewrite cannot keep the file set fixed. The trade-off is stated in the description.

Severity: ❌ blocker / ⚠️ major / 💡 nit.

Session id: cron:clickhouse-review-slot-9:20261022-111300

@groeneai

Copy link
Copy Markdown
Collaborator Author
Pre-PR validation gate (click to expand)
# Question Answer
a Deterministic repro? Yes. A local master build runs each query's setup verbatim and then the statement 16 times (prewarm + 15). With the old text every execution reads 2 more files and adds 1 snapshot, the same +2 per run that query_metric_runs_v1 shows on CI (#5: 6, 8, ..., 18; #9: 4, 6, ..., 16).
b Root cause explained? Yes. Both are merge-on-read Iceberg UPDATEs whose WHERE still matches after they ran. Each run commits a data file and a position-delete file that the next run must scan, and perf.py never resets the table, so time grows monotonically within a run series and the comparison reports unstable.
c Fix matches root cause? Yes. The WHERE now excludes the rows the prewarm rewrote, so measured runs commit nothing and the table stays fixed. No bound widened, no data reduced, no query dropped.
d Test intent preserved / new tests added? Yes. Both rewrites, including the cross-partition move, still execute once per server (prewarm), and the measured runs still time the mutation over the same tables. The perf XML is the deliverable.
e Both directions demonstrated? Yes, in the same run. Old: files and snapshots grow every execution, corr(run, duration) 0.99 / 0.92. New: both constant after the first measured run, corr -0.47 / -0.45. Row counts are as expected after the last run.
f Fix is general across code paths? Yes. Every state-changing query of the suite was checked: modify_column, delete_position_deletes and optimize_manifests already commit nothing after the prewarm (flat on CI). The S3 variant shares the same .inc.
g Fix generalizes across inputs (params/datatypes/wrappers)? N/A for types (test-only). #9 stays idempotent for any l_quantity >= 0, since the prewarm lifts every match to >= 100. #5 does not depend on the data.
h Backward compatible? (maintainer-approved exception only) Yes, test-only. Query indices are unchanged (perf.py --print-queries on both suites).
i Invariants and contracts preserved? Yes. A timed query now leaves the table it reads unchanged, which is the suite's own invariant for its other mutations. Each rewrite still happens exactly once per server.

Session id: cron:clickhouse-impl-slot-7:20261022-105700

@clickhouse-gh

clickhouse-gh Bot commented Oct 22, 2026 •

Copy link
Copy Markdown
Contributor

Workflow [PR], commit [9115e99]

Summary: ✅


AI Review

Summary

The PR makes queries #5 and #9 in both Iceberg read/write performance suites idempotent: warmup performs the update, and measured executions scan a fixed table without adding data files, position-delete files, or snapshots. The change intentionally measures mutation planning and scanning after warmup; the author documents that tradeoff and provides before/after measurements. No actionable findings.

Missing context / blind spots
  • ⚠️ Performance-comparison jobs were still queued at review time, and no local ClickHouse binary was available. The reported 16-execution measurements were not independently reproduced; completed local and S3 CI runs would confirm stability in the CI environment.
Final Verdict

Status: ✅ Approve.

@clickhouse-gh clickhouse-gh Bot added the pr-ci label Oct 22, 2026
@clickhouse-gh clickhouse-gh Bot added the comp-testing Test content only (no production code). label Oct 22, 2026
@alexey-milovidov alexey-milovidov added the can be tested Allows running workflows for external contributors label Oct 22, 2026
@alexey-milovidov alexey-milovidov self-assigned this Oct 23, 2026
@alexey-milovidov
alexey-milovidov added this pull request to the merge queue Oct 23, 2026
Merged via the queue into ClickHouse:master with commit b49341c Oct 23, 2026
527 of 529 checks passed
@robot-ch-test-poll3 robot-ch-test-poll3 added the pr-synced-to-cloud The PR is synced to the cloud repo label Oct 23, 2026
opensource-fork-sync Bot pushed a commit to cla7aye15I4nd/opensource-ClickHouse__ClickHouse that referenced this pull request Nov 10, 2026
…wer run over run

perf.py repeats every measured query on the same tables without a reset. A
query that changes what its next run reads (a growing table, an UPDATE that
rewrites its own rows, a file each run appends to) gets slower run over run
and is then noisy on master for weeks: 8 of the 10 noisiest tests of the last
round in ClickHouse#100759 were this class, all fixed after merge. A PR run could not
notice: its status ignores slower/unstable rows, and the A/B diff of a new
test mixes noise with the PR's own change.

In master_head PR runs (not nightly, not the Iceberg configuration), read the
job's own analyze/query-runs.tsv for the tests the PR adds or changes and fail
Check Results when a query has, on the tested server, at least 5 runs with
corr(run, time) > 0.8 and last/first > 1.2. Only the tested server counts:
after the merge both master servers run that code, and requiring both servers
drops recall to 0.34-0.94 of heads on last round's offenders against
0.60-0.98. One FAIL child per query carries both servers' run times. A missing
file or a malformed row of a changed test fails the check; unknown changed
files add a workflow warning instead. test_discovery.changed_tests is the
selection, which changed_iceberg_tests now reuses.

Validated on 16 real job logs: flagged on master before ClickHouse#127696 / ClickHouse#127380 and
on all 8 head jobs of ClickHouse#119147, not flagged after the fixes, 1 of 273 tests on
today's master (a query rising on both servers).

Related: ClickHouse#100759

Co-Authored-By: Claude Opus 5.5 <[email protected]>
@clickhouse-gh clickhouse-gh Bot added comp-iceberg Apache Iceberg tables: reading and writing Iceberg metadata (snapshots, manifests, schema evoluti... 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-iceberg Apache Iceberg tables: reading and writing Iceberg metadata (snapshots, manifests, schema evoluti... 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