Skip to content

Resolve Iceberg manifest entry fields without enumerating the whole manifest schema - #127782

Merged
alexey-milovidov merged 2 commits into
ClickHouse:masterfrom
groeneai:iceberg-manifest-field-lookup-tuple-walk
Nov 9, 2026
Merged

alexey-milovidov merged 2 commits into
ClickHouse:masterfrom
groeneai:iceberg-manifest-field-lookup-tuple-walk

Conversation

@groeneai

@groeneai groeneai commented Oct 25, 2026 •

Copy link
Copy Markdown
Collaborator

Related: #127100
Related: #127061

Changelog category (leave one):

  • Performance Improvement

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

Reading the manifest files of an Iceberg table is faster: fields of a manifest entry are now taken directly from the parsed record instead of enumerating the whole manifest schema for every field. Listing the files of a table with many manifests that are not in the metadata cache is about 3 times faster.

Description

AvroForIcebergDeserializer::extractSubcolumnWithType resolved every field the manifest entry parser reads (status, data_file.file_path, data_file.lower_bounds, ...) with IDataType::hasSubcolumn, getSubcolumn and getSubcolumnType. Each of them enumerates the streams of the whole manifest_entry type, so a manifest cost about 60 full type walks (~2 ms) whatever its number of entries; this was ~80% of the parse in a profile of 200 one-file manifests (discussed in #127100).

When every component of the path is an element of a named Tuple, the element column and type are taken directly (DataTypeTuple::tryGetPositionByName, ColumnTuple::getColumnPtr). That is the same pointer and type the generic lookup returns for a tuple element. Other paths (through Array, Nullable, Map, or absent fields) use the generic lookup as before.

Local RelWithDebInfo builds of 7f4a629 (master before #127100) with and without the change, icebergLocal, use_iceberg_metadata_files_cache = 0, results identical:

without with
200 manifests, WHERE id < 0, max_threads = 1 0.477 s 0.141 s
same, default threads 0.107 s 0.029 s
200 manifests, count(), sum(id), max_threads = 1 0.430 s 0.129 s
one manifest with 20000 entries, full read, max_threads = 1 4.58 s 4.35 s

The Iceberg and Paimon stateless and integration tests pass with a temporary check (not committed) that compared both lookups on every call: no mismatch.

use_iceberg_metadata_files_cache is read when the table is created, so the existing query of iceberg_data_manifests.xml is served from the metadata cache and does not see this change. I added a twin table created with the cache off, which reads all 200 manifests on every run (local perf.py: 0.106 s -> 0.029 s).

🤖 Generated with Claude Code


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

Version info

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

groeneai and others added 2 commits October 25, 2026 14:23
AvroForIcebergDeserializer parses a manifest into one Tuple column and
resolves every field the entry parser reads (status, data_file.file_path,
data_file.lower_bounds, ...) with IDataType::hasSubcolumn, getSubcolumn and
getSubcolumnType. Each of those enumerates the streams of the whole
manifest_entry type, so a manifest cost ~60 full type walks regardless of
how many entries it has (~2 ms per manifest, ~80% of the parse).

When every component of the path is an element of a named Tuple, take the
element column and type directly. For a tuple element the generic lookup
returns exactly that pointer and type (SerializationTuple passes them to
SerializationNamed, whose subcolumn creator returns its argument), so the
result is unchanged. Paths through Array, Nullable, Map or absent fields
still use the generic lookup.

200 manifests, cache off, one thread: 0.476 s -> 0.141 s.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
use_iceberg_metadata_files_cache is read when the table's metadata object
is created, so the existing query's query-level
use_iceberg_metadata_files_cache = 0 does not reach a table created with
the cache on, and that query is served from the cache. The twin table is
created with the setting, so its query reads all 200 manifests per run.

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; 1 finding) plus my own review (2 nits). Nothing blocking.

# Sev Finding Verdict Evidence / action
1 💡 The header comment of iceberg_data_manifests.xml says the existing query disables the metadata cache, but that table was created with the cache on AGREE, not changed The existing query is served from the cache (205 hits per run locally); the header is existing text, so this PR only adds the cold twin and states its property next to it
2 💡 Fields absent from the manifest schema (data_file.content_offset, data_file.content_size_in_bytes on v2 manifests) still use the generic lookup, about 13% of the remaining per-manifest profile AGREE, not changed Two full type walks per manifest instead of about 60; answering "absent" from the walk would need a third result state for about 0.02 ms per manifest

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

Session id: cron:clickhouse-review-slot-8:20261025-145700

@groeneai

Copy link
Copy Markdown
Collaborator Author
Pre-PR validation gate (click to expand)
# Question Answer
a Deterministic repro? Yes. 200 one-INSERT manifests, SELECT count() FROM icebergLocal(...) WHERE id < 0 SETTINGS use_iceberg_metadata_files_cache = 0, max_threads = 1 with clickhouse benchmark: 0.476 s on master, 0.141 s with the change, same in two rounds. perf.py on the new twin query: 0.105 s -> 0.029 s in two runs (p < 1e-15).
b Root cause explained? Each field the manifest entry parser reads was resolved with hasSubcolumn, getSubcolumn and getSubcolumnType; each runs getSubcolumnInfo, which enumerates the streams of the whole manifest_entry type. About 60 full type walks per manifest.
c Fix matches root cause? Yes. For a path made only of named Tuple elements the element column and type are taken directly; that replaces the enumeration. Other paths keep the generic lookup.
d Test intent preserved / new tests added? No behaviour change, so existing tests and references are unchanged. iceberg_data_manifests.xml is extended (additions only) with a twin table created with the metadata cache off, because its existing query is served from the cache and cannot see the change.
e Both directions demonstrated? Yes: master vs this PR as in (a); an A/A perf.py run of the twin differs by 6.4%; the cached query is unchanged (1.004x, p 0.76). A temporary check comparing both lookups on every call found no mismatch, and returning a wrong element made it fail.
f Fix is general across code paths? All users of AvroForIcebergDeserializer (Iceberg manifest files and manifest lists, compaction, Paimon) go through this one function; the temporary check ran over the Iceberg and Paimon stateless tests and the Spark-based Iceberg and Paimon integration tests.
g Fix generalizes across inputs (params/datatypes/wrappers)? Paths through Nullable(Tuple), Array(Tuple), Map, Variant, absent fields and empty paths use the generic lookup. Covered v1/v2/v3 manifests written by ClickHouse, Spark and Paimon; manifests with 1, 2000 and 20000 entries (no slowdown).
h Backward compatible? (maintainer-approved exception only) Yes. No setting and no format change; the performance test only gains queries.
i Invariants and contracts preserved? The cached (column, type) for a path equals what the generic lookup returns. The lookup runs under the same cache_mutex lock, reads only immutable members and returns pointers into the already parsed column.

Session id: cron:clickhouse-impl-slot-4:20261025-144400

@groeneai

Copy link
Copy Markdown
Collaborator Author

cc @scanhex12 @arsenmuk, could you review this and add the can be tested label so CI runs? Each manifest entry field that is a named Tuple element is now taken directly with DataTypeTuple::tryGetPositionByName and ColumnTuple::getColumnPtr instead of three getSubcolumnInfo walks over the whole manifest_entry type per field; all other paths keep the generic lookup.

@clickhouse-gh

clickhouse-gh Bot commented Oct 25, 2026 •

Copy link
Copy Markdown
Contributor

Workflow [PR], commit [ab44a7e]

Summary: ❌

job_name test_name status info comment
Build profile diff ERROR

AI Review

Summary

Optimizes Iceberg and Paimon manifest field lookup by walking tuple elements directly, and adds a performance query with the metadata cache disabled at table creation. No actionable findings remain in PR #127782 at head ab44a7ead2efb6f603e4ebffe0f69c5d2c13b881.

Missing context / blind spots
  • ⚠️ The current-head CI run is still in progress. The PR supplies local performance measurements and reports equivalence checks across Iceberg and Paimon tests; these were not independently rerun during this review. Completing the relevant functional, sanitizer, and performance jobs would close this validation gap.
Final Verdict

Status: ✅ Approve. No changes requested.

@clickhouse-gh clickhouse-gh Bot added pr-performance Pull request with some performance improvements comp-datalake Data lake table formats (Iceberg/Delta/Hudi) integration. labels Oct 25, 2026
@alexey-milovidov alexey-milovidov added the can be tested Allows running workflows for external contributors label Oct 27, 2026
@groeneai

Copy link
Copy Markdown
Collaborator Author

CI finish ledger - ab44a7e

Every failure below has an owner: a fixing PR (mine or external), or a full-effort fix task
whose fixing-PR link will be posted here when it opens. Only CH Inc sync is exempt.

Check / test Reason Owner / fixing PR
Build profile diff infra, not from this PR: the CI logs cluster never passed the readiness probe, so the job ended with LogClusterNotReady: the endpoint never became ready before comparing anything. 282 of 286 runs since 2026-10-26 22:00 UTC are red, on 236 PRs #126200 (mine, open)
PR praktika rollup of the row above #126200 (the owner of the row above)

The first run of this head stopped at Config Workflow / Pre Hooks because the can be tested label was not set yet; the run after the label was added is the one above. CIDB has no other FAIL or ERROR row on this head.

Session id: cron:our-pr-ci-monitor:20261027-203012

@alexey-milovidov alexey-milovidov self-assigned this Nov 8, 2026
@alexey-milovidov
alexey-milovidov added this pull request to the merge queue Nov 8, 2026
Merged via the queue into ClickHouse:master with commit 167a443 Nov 9, 2026
525 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 Nov 9, 2026
@clickhouse-gh clickhouse-gh Bot added comp-iceberg Apache Iceberg tables: reading and writing Iceberg metadata (snapshots, manifests, schema evoluti... and removed comp-datalake Data lake table formats (Iceberg/Delta/Hudi) integration. 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-performance Pull request with some performance improvements 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