Skip to content

Serialize iceberg metadata log content lazily - #110437

Merged
alexey-milovidov merged 23 commits into
ClickHouse:masterfrom
andybradshaw:iceberg-metadata-log-lazy-content
Aug 12, 2026
Merged

alexey-milovidov merged 23 commits into
ClickHouse:masterfrom
andybradshaw:iceberg-metadata-log-lazy-content

Conversation

@andybradshaw

@andybradshaw andybradshaw commented Jul 14, 2026 •

Copy link
Copy Markdown
Contributor

Alternative approach to #105823, where instead of hoisting this check to each call site, have callers provide a function to get the row if it passes the level check. This prevents callers from inadvertently regressing here if they miss adding this level check.

Changelog category (leave one):

  • Performance Improvement

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

Avoid eager JSON serialization of Iceberg manifest entries when iceberg_metadata_log_level is below the call site's threshold.

Version info

  • Backported to: 26.7.7.7, 26.6.5.21, 26.3.33.40

insertRowToLogTable took the content as an eagerly built String, so every
call site serialized to JSON even when iceberg_metadata_log_level
(default none) discarded the row.

Related: ClickHouse#105823
Related: ClickHouse#104169
@CLAassistant

CLAassistant commented Jul 14, 2026 •

Copy link
Copy Markdown

CLA assistant check
All committers have signed the CLA.

@scanhex12 scanhex12 self-assigned this Jul 14, 2026
@scanhex12 scanhex12 added the can be tested Allows running workflows for external contributors label Jul 14, 2026
@clickhouse-gh

clickhouse-gh Bot commented Jul 14, 2026 •

Copy link
Copy Markdown
Contributor

Workflow [PR], commit [feaf306]

Summary: ✅


AI Review

Summary

This PR makes Iceberg metadata-log serialization lazy with respect to iceberg_metadata_log_level and adds a focused performance benchmark for manifest-entry planning. The lazy logging change itself looks sound in the current code, but the new benchmark is still not self-healing after failed runs because it hides stale IcebergLocal directories behind a timestamped path instead of making drop-1 able to clean them up.

Findings

⚠️ Majors

  • [tests/performance/iceberg_manifest_entries.xml:13,30] The benchmark now creates a fresh .../iceberg_manifest_entries_<ts>/ directory on every run, while perf.py executes drop_query before it applies the XML <settings> block (tests/performance/scripts/perf.py:696-720) and only reaches drop-2 on success (tests/performance/scripts/perf.py:1117-1123). If the run aborts after CREATE TABLE, the next rerun cannot discover the old timestamped path, so the 100000-file Iceberg dataset is orphaned permanently on persistent perf hosts. Use a deterministic path and put iceberg_delete_data_on_drop = 1 on the DROP TABLE query itself so drop-1 can clean stale state.
Final Verdict

Needs changes before merge: the performance test cleanup path is still broken for failed runs.

LLVM Coverage Report

Metric Baseline Current Δ
Lines 86.60% 86.60% +0.00%
Functions 91.90% 91.90% +0.00%
Branches 78.90% 78.90% +0.00%

Changed lines: Changed C/C++ lines covered: 33/44 (75.00%) · Uncovered code

Full report · Diff report

@clickhouse-gh clickhouse-gh Bot added the pr-performance Pull request with some performance improvements label Jul 14, 2026
Comment thread src/Interpreters/IcebergMetadataLog.cpp Outdated

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Am I right that the reason in this if statement?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, in the other approach, this check was added to every call site, which seemed worse than keeping it here.

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR optimizes Iceberg metadata logging by making the metadata payload generation lazy, so expensive JSON serialization is only performed when iceberg_metadata_log_level actually admits the requested log row level.

Changes:

  • Updated insertRowToLogTable to accept a callable that produces the metadata content string, and only invoke it after the log-level check passes.
  • Updated all Iceberg call sites to pass lambdas instead of eagerly-built strings.
  • Added a performance test intended to exercise manifest entry processing overhead.

Reviewed changes

Copilot reviewed 6 out of 6 changed files in this pull request and generated 2 comments.

Show a summary per file
File Description
tests/performance/iceberg_manifest_entries.xml Adds a performance benchmark for Iceberg manifest entry processing.
src/Storages/ObjectStorage/DataLakes/Iceberg/StatelessMetadataFileGetter.cpp Switches metadata-log insertion to lazy payload generation for manifest list metadata and entries.
src/Storages/ObjectStorage/DataLakes/Iceberg/ManifestFileIterator.cpp Switches metadata-log insertion to lazy payload generation for manifest file metadata and entries.
src/Storages/ObjectStorage/DataLakes/Iceberg/IcebergMetadata.cpp Switches metadata-log insertion to lazy payload generation for overall Iceberg metadata.
src/Interpreters/IcebergMetadataLog.h Changes insertRowToLogTable API to accept a callable (lazy content).
src/Interpreters/IcebergMetadataLog.cpp Implements lazy content evaluation after log-level gating.

Comment thread src/Interpreters/IcebergMetadataLog.h Resolved
No performance test exercised the Iceberg metadata path before. The
test creates a local Iceberg table whose single snapshot has 100000
manifest entries (one row per data file) and measures a query whose
filter matches nothing, so planning over manifest entries dominates.

Locally, the measured query takes ~27ms with lazily serialized log
content versus ~1.2s when every entry is serialized to JSON, which is
what happened eagerly before insertRowToLogTable took a closure.

Co-Authored-By: Claude Fable 5 <[email protected]>
@clickhouse-gh

clickhouse-gh Bot commented Jul 14, 2026 •

Copy link
Copy Markdown
Contributor

📊 Cloud Performance Report

✅ AI verdict: no_change — no significant changes across 37 queries analysed

no significant changes detected. K_source=6 K_base=30 flagged=0/65

clickbench

🟢 No significant changes

tpch_adapted_1_official

🟢 No significant changes

Debug info
  • StressHouse run: 7b83d462-1656-4ed2-bf9f-c3aa14f04032
  • MIRAI run: 473b2ce7-c930-48b9-a0f5-a5b5979d02a3
  • PR check IDs:
    • clickbench_483428_1786298361
    • clickbench_483434_1786298361
    • clickbench_483444_1786298361
    • tpch_adapted_1_official_483457_1786298361
    • tpch_adapted_1_official_483471_1786298361
    • tpch_adapted_1_official_483498_1786298361

@scanhex12
scanhex12 enabled auto-merge July 15, 2026 08:40
@scanhex12
scanhex12 added this pull request to the merge queue Jul 15, 2026
@scanhex12
scanhex12 removed this pull request from the merge queue due to a manual request Jul 15, 2026
@andybradshaw

Copy link
Copy Markdown
Contributor Author

👋 Hey @scanhex12! I see this was added and then removed from the merge queue. Is there anything else we're waiting for on this? Was it just because of the test flake that we're holding this?

@andybradshaw

Copy link
Copy Markdown
Contributor Author

@scanhex12 bump on this

@clickhouse-gh

clickhouse-gh Bot commented Aug 1, 2026

Copy link
Copy Markdown
Contributor

LLVM Coverage Report

Metric Baseline Current Δ
Lines 86.50% 86.50% +0.00%
Functions 91.90% 91.90% +0.00%
Branches 78.70% 78.70% +0.00%

Changed lines: Changed C/C++ lines covered: 33/44 (75.00%) · Uncovered code

Full report · Diff report

@andybradshaw

Copy link
Copy Markdown
Contributor Author

@scanhex12 looks like we finally got a green build

@alexey-milovidov
alexey-milovidov added this pull request to the merge queue Aug 12, 2026
Merged via the queue into ClickHouse:master with commit 21c106a Aug 12, 2026
355 of 356 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 Aug 12, 2026
@scanhex12 scanhex12 added the pr-must-backport Pull request should be backported intentionally. Use this label with great care! label Sep 1, 2026
@robot-clickhouse-ci-2 robot-clickhouse-ci-2 added the pr-backports-created Backport PRs are successfully created, it won't be processed by CI script anymore label Sep 1, 2026
@scanhex12 scanhex12 added v26.2-affected and removed pr-backports-created Backport PRs are successfully created, it won't be processed by CI script anymore labels Sep 1, 2026
@robot-ch-test-poll4 robot-ch-test-poll4 added the pr-must-backport-synced The `*-must-backport` labels are synced into the cloud Sync PR label Sep 1, 2026
@robot-ch-test-poll robot-ch-test-poll added the pr-backports-created Backport PRs are successfully created, it won't be processed by CI script anymore label Sep 1, 2026
clickhouse-gh Bot added a commit that referenced this pull request Sep 1, 2026
Backport #110437 to 26.7: Serialize iceberg metadata log content lazily
clickhouse-gh Bot added a commit that referenced this pull request Sep 1, 2026
Backport #110437 to 26.6: Serialize iceberg metadata log content lazily
PedroTadim added a commit that referenced this pull request Sep 10, 2026
Backport #110437 to 26.3: Serialize iceberg metadata log content lazily
kewin-robetti pushed a commit to viasoftkorp/ClickHouse that referenced this pull request Sep 11, 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 pr-backports-created Backport PRs are successfully created, it won't be processed by CI script anymore pr-must-backport Pull request should be backported intentionally. Use this label with great care! pr-must-backport-synced The `*-must-backport` labels are synced into the cloud Sync PR pr-performance Pull request with some performance improvements pr-synced-to-cloud The PR is synced to the cloud repo v26.2-affected

Projects

None yet

Development

Successfully merging this pull request may close these issues.

9 participants