Skip to content

Iceberg: skip eager getContent() JSON serialization when metadata log is disabled - #105823

Closed
starpact wants to merge 8 commits into
ClickHouse:masterfrom
starpact:fix-iceberg-eager-log-content
Closed

starpact wants to merge 8 commits into
ClickHouse:masterfrom
starpact:fix-iceberg-eager-log-content

Conversation

@starpact

@starpact starpact commented May 26, 2026 •

Copy link
Copy Markdown
Contributor

AvroForIcebergDeserializer::getContent(row_index) was passed as an argument to insertRowToLogTable and serialized a manifest entry to JSON on every call, even when iceberg_metadata_log_level (default none) discarded the result. Hoist the level check above the five call sites so the payload is only built when the log will consume it.

CPU profile of a query over ~300k pruned manifest entries (max_threads=1): ~59% of CPU was JSON serialization (writeJSONString, SerializationTuple::serializeTextJSON, SerializationObjectPool::getOrCreate and the resulting allocator churn).

┌─samples─┬───pct─┬─function─────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────┐
│    3278 │ 13.15 │ DB::SerializationObjectPool::getOrCreate(wide::integer<128ul, unsigned int>, std::__1::function<DB::ISerialization* ()>)                                                                                                 │
│    2797 │ 11.22 │ DB::WriteBuffer::write(char)                                                                                                                                                                                             │
│    2679 │ 10.75 │ syscall                                                                                                                                                                                                                  │
│    1283 │  5.15 │ DB::writeJSONString(char const*, char const*, DB::WriteBuffer&, DB::FormatSettings const&)                                                                                                                               │
│    1009 │  4.05 │ DB::SerializationTuple::serializeTextJSON(DB::IColumn const&, unsigned long, DB::WriteBuffer&, DB::FormatSettings const&) const                                                                                          │
│     737 │  2.96 │ je_sallocx                                                                                                                                                                                                               │
│     715 │  2.87 │ DB::Iceberg::ManifestFileIterator::processRow(unsigned long)                                                                                                                                                             │
│     635 │  2.55 │ DB::SerializationNamed::getHash(std::__1::shared_ptr<DB::ISerialization const> const&, std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char>> const&, DB::ISerialization::Substream::Type) │
│     632 │  2.53 │ DB::SerializationObjectPool::getOrCreate(wide::integer<128ul, unsigned int>, std::__1::function<DB::ISerialization* ()>)::$_0::operator()(DB::ISerialization const*) const                                               │
│     558 │  2.24 │ CurrentMemoryTracker::allocImpl(long, bool)                                                                                                                                                                              │
│     536 │  2.15 │ DB::Iceberg::(anonymous namespace)::deserializeFieldFromBinaryRepr(std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char>>, std::__1::shared_ptr<DB::IDataType const>, bool)                │
│     499 │     2 │ DB::SerializationTuple::create(std::__1::vector<std::__1::shared_ptr<DB::SerializationNamed const>, std::__1::allocator<std::__1::shared_ptr<DB::SerializationNamed const>>>, bool)                                      │
│     463 │  1.86 │                                                                                                                                                                                                                          │
│     444 │  1.78 │ DB::(anonymous namespace)::writeTraceInfo(DB::TraceType, int, siginfo_t*, void*)                                                                                                                                         │
│     444 │  1.78 │ je_malloc                                                                                                                                                                                                                │
│     420 │  1.68 │ je_nallocx                                                                                                                                                                                                               │
│     383 │  1.54 │ DB::DataTypeTuple::doGetSerialization(DB::SerializationInfoSettings const&) const                                                                                                                                        │
│     381 │  1.53 │ auto DB::Field::dispatch<DB::Field::create(DB::Field const&)::'lambda'(auto&), DB::Field const&>(auto&&, DB::Field const&)                                                                                               │
│     310 │  1.24 │ DB::Iceberg::IcebergSchemaProcessor::tryGetFieldCharacteristics(int, int) const                                                                                                                                          │
│     304 │  1.22 │ rtree_read                                                                                                                                                                                                               │
│     250 │     1 │ CurrentMemoryTracker::free(long)                                                                                                                                                                                         │
│     226 │  0.91 │ DB::Field::~Field()                                                                                                                                                                                                      │
│     220 │  0.88 │ auto DB::Field::dispatch<DB::Field::create(DB::Field&&)::'lambda'(auto&), DB::Field&>(auto&&, DB::Field&)                                                                                                                │
│     195 │  0.78 │ itoa(long, char*)                                                                                                                                                                                                        │
│     188 │  0.75 │ DB::SerializationTuple::supportsPooling() const                                                                                                                                                                          │
│     177 │  0.71 │ je_sdallocx                                                                                                                                                                                                              │
│     172 │  0.69 │ DB::ISerialization::pooled(wide::integer<128ul, unsigned int>, std::__1::function<DB::ISerialization* ()>)                                                                                                               │
│     166 │  0.67 │ DB::SerializationArray::serializeTextJSON(DB::IColumn const&, unsigned long, DB::WriteBuffer&, DB::FormatSettings const&) const                                                                                          │
│     165 │  0.66 │ DB::SerializationNamed::~SerializationNamed()                                                                                                                                                                            │
│     155 │  0.62 │ operator new[](unsigned long)                                                                                                                                                                                            │
└─────────┴───────┴──────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────┘

related to #104169

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.

@alesapin alesapin self-assigned this May 28, 2026
@alesapin alesapin added the can be tested Allows running workflows for external contributors label May 28, 2026
@clickhouse-gh

clickhouse-gh Bot commented May 28, 2026 •

Copy link
Copy Markdown
Contributor

Workflow [PR], commit [2c94be0]

Summary: ✅


AI Review

Summary

This PR moves the iceberg_metadata_log_level checks above Iceberg metadata log payload construction, so dumpMetadataObjectToString, getMetadataContent, and getContent are skipped when the selected log level would discard the row. The current call sites preserve the existing logging thresholds, but the Performance Improvement contract still lacks after-change evidence.

Missing context / blind spots
  • ⚠️ The latest Praktika report linked by the bot for PR=105823 / sha=2c94be099b23d90cedcd7b33ad8e7b55c47707f2 returned no test rows through .claude/tools/fetch_ci_report.js, so I could not validate completed CI status from that report. A completed Praktika report would close this gap.
Findings

⚠️ Majors

  • [src/Storages/ObjectStorage/DataLakes/Iceberg/ManifestFileIterator.cpp:244] [dismissed by author -- https://github.com/Iceberg: skip eager getContent() JSON serialization when metadata log is disabled #105823#discussion_r3323514511] The PR is categorized as Performance Improvement, but the current description still only shows the pre-change CPU profile. There is no after-change query time, CPU profile, or focused benchmark proving that the default iceberg_metadata_log_level = 'none' path no longer spends meaningful CPU in JSON serialization. I still consider this real because the promised user-facing performance impact is unvalidated after the author silently resolved the thread. Please add or link a before/after run for the manifest-entry workload from the description, or another focused measurement that demonstrates the improvement.
Final Verdict

Status: ⚠️ Request changes

Minimum required action: add/link after-change performance evidence for the iceberg_metadata_log_level = 'none' path so the Performance Improvement claim is verifiable.

@clickhouse-gh clickhouse-gh Bot added the pr-performance Pull request with some performance improvements label May 28, 2026

@alesapin alesapin left a comment

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.

We double checks now, but okay.

@clickhouse-gh clickhouse-gh Bot added the manual approve Manual approve required to run CI label May 29, 2026
@starpact

starpact commented Jun 2, 2026

Copy link
Copy Markdown
Contributor Author

Hi @alesapin, thanks for your review. I added level check on every call-sites and remove the inside check.

The CI issue seems irrelevant, I have merged latest the master several times but it the problem persists, can you give some suggestions?

@clickhouse-gh

clickhouse-gh Bot commented Jun 13, 2026

Copy link
Copy Markdown
Contributor

LLVM Coverage Report

Metric Baseline Current Δ
Lines 84.70% 84.70% +0.00%
Functions 92.30% 92.40% +0.10%
Branches 77.30% 77.30% +0.00%

Changed lines: Changed C/C++ lines covered by tests: 19/74 (25.68%) | Lost baseline coverage (was covered on master, now uncovered in this PR): 64 line(s) · Uncovered code

Full report · Diff report

@snicholasbarton

Copy link
Copy Markdown

Hi @alesapin, we would also benefit from this change. Is there any update on when it will get merged? Thanks!

@clickhouse-gh

clickhouse-gh Bot commented Jun 30, 2026

Copy link
Copy Markdown
Contributor

Dear @alesapin, you haven't been active on this PR for 30 days. You will be unassigned. Will you continue working on it? If so, please feel free to reassign yourself.

andybradshaw added a commit to andybradshaw/ClickHouse that referenced this pull request Jul 14, 2026
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
@starpact starpact closed this Aug 13, 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 manual approve Manual approve required to run CI pr-performance Pull request with some performance improvements

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants