Skip to content

Parallelize Iceberg data manifest decoding - #116723

Merged
scanhex12 merged 27 commits into
ClickHouse:masterfrom
aaron276h:iceberg-data-manifest-decode-concurrency
Sep 5, 2026
Merged

scanhex12 merged 27 commits into
ClickHouse:masterfrom
aaron276h:iceberg-data-manifest-decode-concurrency

Conversation

@aaron276h

@aaron276h aaron276h commented Aug 27, 2026 •

Copy link
Copy Markdown
Contributor

Related: #106127
Related: #112679

Changelog category (leave one):

  • Performance Improvement

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

Decode Iceberg data manifest files concurrently while the list of data files for a query is produced. The setting iceberg_manifest_decode_concurrency (default 4) bounds how many manifests — delete and data alike — are decoded at a time; it replaces iceberg_delete_manifest_decode_concurrency, which is kept as an alias.

Description

On tables with many data manifests, the walk that produces the list of data files is dominated by per-manifest decode work — the Avro parse plus the per-entry partition/min-max pruning in ManifestFileIterator — which ran serially in the single producer thread. The one-ahead prefetch (#108543) overlapped only the next manifest's fetch, not its decode. Benchmarked in #106127 against a production table (18 data manifests, 113 MB, ~75k entries, 82 columns) with the metadata cache disabled: the serial walk took 8.45 s, of which the raw Avro parse was only ~0.8 s; the rest was per-entry processing. Parallel decode brought it to 2.55 s at 4 threads and 1.68 s at 16.

What this PR does:

  • The data-manifest streaming lives in a new Iceberg::DataFileEntriesStream: its producer thread keeps up to iceberg_manifest_decode_concurrency decode tasks in flight, and each task owns the full pipeline for one DATA manifest — fetch (getManifestFile), deserialize, per-entry pruning — and streams each surviving entry into a bounded queue as it is produced (capacity iceberg_file_entries_queue_size, default 100). Backpressure therefore applies within a manifest at every concurrency, no batch of entries is ever materialized, and peak memory is the in-flight manifests' decoded contents plus the queue. The producer iterates the snapshot's manifest list by index — no copies. Entries from concurrently decoded manifests interleave in the queue; nothing consumes their relative order.
  • The streaming tasks run on a dedicated pool (max_iceberg_manifest_decode_thread_pool_size, default 100) rather than the IO pool: a streaming task can block until the query consumes its entries, while ensureDeletesReady waits for delete decode tasks it schedules on the IO pool before any entry is consumed — on one shared pool, enough queries parking data tasks could leave no thread for the delete tasks whose completion would unblock them.
  • One setting bounds both windows: iceberg_manifest_decode_concurrency (NonZeroUInt64, default 4) is read by the delete-manifest window from Parallelize delete manifests reads #112679 and by the new data-manifest window. iceberg_delete_manifest_decode_concurrency becomes an alias, so existing configurations keep working and compatibility below 26.8 still restores its old default through the existing 26.8 history entry.
  • The per-manifest fetch/iterator setup is factored into createManifestIterator, shared by the delete and data paths (both already evaluated identical filter DAG clones; they now share one manifest_filter_dag). Sharing one clone is no wider than before: ActionsDAG::clone shares the underlying ColumnSet/FutureSet objects between clones anyway, and Parallelize delete manifests reads #112679 already evaluates a single clone from several concurrent tasks. Delete manifests keep the collect-into-batch helper — they must all be decoded before the first row.
  • SingleThreadIcebergKeysIterator and its prefetch machinery are removed — the streaming window subsumes them (1 decodes one manifest at a time, like the old walk).
  • Teardown is bounded: tasks check the stop condition before the fetch, and ManifestFileIterator takes an optional stop condition checked every 256 rows inside its row loop (so long stretches of pruned rows cannot hide it); the data paths pass the queue's finished state. Cancellation waits for at most the in-flight fetches plus a few milliseconds of decoding per task. Delete decodes deliberately keep draining — the data producer finishes the queue during normal execution, before the lazy delete decode may even start. Constructor failure handling is also simpler than in Add iceberg_parallel_manifest_decode_threads for parallel manifest decoding #106127: only one thread is spawned, and the tasks are created inside it.
  • FutureSetFromSubquery::buildOrderedSetInplace is serialized with a per-set mutex. Concurrent decode tasks build per-manifest KeyConditions against the shared DAG, and for an IN (SELECT ...) predicate they could enter the unguarded in-place build simultaneously — racing on set_and_key->set and on source (one caller resets it while another's speculative pipeline still relies on the resources it keeps alive). This shape is already reachable on master through the delete-manifest window of Parallelize delete manifests reads #112679 (merge-on-read table + subquery filter); this PR makes it reachable for any Iceberg read, so it fixes the shared class the same way Fix data race in FutureSetFromTuple #104673 fixed the tuple sibling. A mutex rather than callOnce because a build that stopped without creating the set (for example a subquery timeout with overflow_mode = 'break') may legitimately be retried while source is preserved.

Tests:

  • test_data_manifest_decode_concurrency.py (integration): result invariance across concurrency 1/2/4/16 on a Spark-written table with one manifest per commit, including a partition-column IN filter so every concurrent decode task evaluates the shared filter DAG; manifest count is verified through system.iceberg_metadata_log. A merge-on-read case runs concurrent delete- and data-manifest decode together against the shared DAG. A subquery case runs part IN (SELECT ...) under concurrency, exercising the now-serialized FutureSetFromSubquery build from several decode tasks. A large-manifest case reads a single manifest with three times the queue capacity in entries (pushes block mid-manifest at every concurrency) and a fully pruned variant of it keeps the row loop busy without yielding. A failpoint case proves the setting drives the window: with iceberg_slow_manifest_read active, = 1 cannot finish faster than one delay per manifest (lower bound), and = 16 must beat the measured serial run (comparative bound); timing asserts are skipped on instrumented builds. Modeled on test_delete_manifest_decode_concurrency.py and test_manifest_read_performance.py.
  • tests/performance/iceberg_data_manifests.xml: sibling of iceberg_delete_manifests.xml, 200 single-commit inserts, query with the metadata cache disabled.
  • The existing test_manifest_read_performance.py failpoint test now guards the window's fetch overlap instead of the prefetch.

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

Version info

  • Merged into: 26.9.1.797 (included in 26.9 and later)
  • Backported to: 26.8.9.5

Reading an Iceberg snapshot's data files walked the data manifests one
at a time in the producer thread: the one-ahead prefetch overlapped the
next manifest's fetch with the current parse, but the decode itself -
the Avro parse plus per-entry partition and min-max pruning - stayed
serial. On tables with many manifest files this dominates the time
before all data files are known.

Follow up ClickHouse#112679, which introduced a bounded sliding window of decode
tasks on the IO pool for delete manifests, by decoding data manifests
through the same pattern: each task owns the full pipeline for one
manifest (fetch, deserialize, prune), futures are consumed in manifest
list order, and entries stream into the existing bounded queue, whose
blocking `push` bounds read-ahead. The per-manifest decode body is
shared between the delete and data paths (`decodeManifest`), and
`SingleThreadIcebergKeysIterator` with its one-manifest prefetch is
removed: a window of size 2 gives the closest equivalent of the
previous overlap, and 1 decodes the manifests one at a time.

The new setting `iceberg_data_manifest_decode_concurrency` (default 4)
bounds the window, mirroring `iceberg_delete_manifest_decode_concurrency`.
@aaron276h
aaron276h marked this pull request as ready for review August 27, 2026 13:55
@aaron276h

Copy link
Copy Markdown
Contributor Author

Hi @asya-ch, following up on our discussion in #106127, this is the data-manifest side built on top of the worker-pool approach you merged in #112679

@alesapin alesapin added the can be tested Allows running workflows for external contributors label Aug 27, 2026
@clickhouse-gh

clickhouse-gh Bot commented Aug 27, 2026 •

Copy link
Copy Markdown
Contributor

Workflow [PR], commit [1ace1b6]

Summary: ❌

job_name test_name status info comment
AST fuzzer (amd_debug, targeted) FAIL
Logical error: Shard number is greater than shard count: shard_num=A shard_count=B cluster=C (STID: 5066-457d) FAIL cidb
Docker keeper image FAIL
clickhouse/clickhouse-keeper:head-distroless-arm64 FAIL cidb

AI Review

Summary

The PR replaces the serial Iceberg data-manifest walk with a pooled DataFileEntriesStream, adds a dedicated decode pool, and unifies the delete/data concurrency setting. The current head still has one upgrade-compatibility blocker, one GLOBAL IN correctness blocker, and two major issues around the new prewarm/chunking design, so I do not think this is ready to merge.

Findings

❌ Blockers

  • [src/Core/Settings.cpp:6035] [dismissed by author -- https://github.com/Parallelize Iceberg data manifest decoding #116723#discussion_r3918183198] Turning iceberg_delete_manifest_decode_concurrency into a plain alias of iceberg_manifest_decode_concurrency changes the behavior of an existing setting. DECLARE_WITH_ALIAS resolves the old name to the canonical setting, so any existing profile or query that explicitly sets the old knob now also changes ordinary data-manifest reads; applyCompatibilitySetting then refuses to overwrite that explicit value. Suggested fix: keep the old name delete-only for at least one compatibility cycle, or add explicit migration logic that preserves the old setting's scope for existing users.
  • [src/Storages/ObjectStorage/DataLakes/Iceberg/IcebergIterator.cpp:357] The new producer-side prewarm calls VirtualColumnUtils::buildOrderedSetsForDAG, which eagerly builds every subquery-backed set in the manifest filter DAG. ReadFromObjectStorageStep::applyFilters already has a dedicated buildSetsForDAGExcludingGlobalIn path because GLOBAL IN / GLOBAL JOIN sets are not safe to build before ReadFromRemote attaches their external tables; re-running the unconditional builder here reopens exactly that LOGICAL_ERROR path for Iceberg filters using GLOBAL IN. Suggested fix: reuse buildSetsForDAGExcludingGlobalIn, or at least skip sets with external_table_expected during this prewarm.

⚠️ Majors

  • [src/Storages/ObjectStorage/DataLakes/Iceberg/IcebergIterator.cpp:357] The new "bounded teardown" contract does not hold for subquery-backed filters. data_files_stream->clearAndFinish() only reaches manifest tasks through stopped, but the producer runs buildOrderedSetsForDAG synchronously before any task is scheduled, so a delete-decode exception or iterator destruction still has to wait for the full subquery set build to finish. Suggested fix: thread the same stop/cancel signal through the prewarm path, or defer that work until deletes are known-good and query cancellation can abort it.
  • [src/Storages/ObjectStorage/DataLakes/Iceberg/IcebergIterator.cpp:193,289-302] The chunked producer no longer preserves either advertised bound: each worker can materialize up to iceberg_file_entries_queue_size entries off-queue, and run always waits on and reschedules only in_flight.front(). On manifests larger than one chunk, that means later manifests sit ready while only the front manifest keeps decoding, so sustained decode parallelism collapses to one manifest at a time even as RAM/read-ahead exceed the queue size contract. Suggested fix: drain whichever future becomes ready, or have workers push directly into the bounded queue so concurrency and backpressure stay coupled.
Tests
  • ⚠️ Add a focused GLOBAL IN Iceberg regression. Current coverage exercises local IN (SELECT ...), but it does not prove the new producer prewarm stays away from the external-table path that ReadFromObjectStorageStep explicitly skips.
  • ⚠️ Add a teardown regression where ensureDeletesReady() fails or clearAndFinish() fires while the producer is still inside buildOrderedSetsForDAG. Current tests cover stop checks inside manifest iteration, not the new synchronous prewarm.
  • ⚠️ Add a performance/behavior test with several manifests larger than iceberg_file_entries_queue_size. The current large-manifest integration test uses one manifest, and tests/performance/iceberg_data_manifests.xml uses one data file per manifest, so neither one proves multi-manifest decode stays parallel past the first chunk.
Final Verdict

Changes required.

LLVM Coverage Report

Measured on commit 1ace1b6.

Metric Baseline Current Δ
Lines 88.70% 88.70% +0.00%
Functions 92.10% 92.10% +0.00%
Branches 81.10% 81.10% +0.00%

Changed lines: Changed C/C++ lines covered: 262/269 (97.40%) · Uncovered code

Full report · Diff report

@clickhouse-gh clickhouse-gh Bot added the pr-performance Pull request with some performance improvements label Aug 27, 2026
@scanhex12 scanhex12 self-assigned this Aug 27, 2026
@clickhouse-gh

clickhouse-gh Bot commented Aug 27, 2026 •

Copy link
Copy Markdown
Contributor

Build profile diff (arm_release)

Comparing 1ace1b6e1 with master d1adb9f9f (stripped binary size, per-symbol sizes and ThinLTO time; compile times per translation unit against the most recent warmup build that recompiled it).

✅ No significant changes.

Binary sizes

programs/clickhouse-stripped: smaller than the master baseline by the known offset between the two builds, so the difference is not shown. A delta that differs from the offset by more than 50% of it is shown, in either direction.

The official master build is compiled with -g and a pull request build is not, and XRay counts debug instructions towards its instrumentation threshold, so master instruments thousands of functions more and its binary is ~0.4% larger no matter what the pull request does.

Object file sizes

70 object files changed (-5.23 KiB total), 0 added.

Object file Master PR Δ
src/CMakeFiles/dbms.dir/Storages/ObjectStorage/DataLakes/Iceberg/IcebergIterator.cpp.o 360.61 KiB 342.85 KiB -17.76 KiB (-4.92%)

716 more object files are built by the master warmup baseline only (it builds every object-file target, a pull request build only clickhouse-bundle) and not compared.

Compile time of recompiled translation units

640 translation units recompiled, 5063 s compile time in total, 640 of them have a recent master baseline.

Job report

Concurrent index analyses can share one `FutureSetFromSubquery`
through cloned filter DAGs: `ActionsDAG::clone` keeps the underlying
sets shared, and the delete- and data-manifest decode tasks in
`IcebergIterator` evaluate such clones simultaneously. Nothing
synchronized `buildOrderedSetInplace`: two builders raced on
`set_and_key->set`, and one could reset `source` while the other's
speculative pipeline still relied on the resources the source plan
keeps alive.

Guard the build with a per-set mutex: the winner builds, later callers
take the created-set fast path under the lock. A mutex rather than
`callOnce` (the `FutureSetFromTuple` fix) because a build that
stopped without creating the set may legitimately be retried while
`source` is preserved.

Also cover `IN (SELECT ...)` under parallel manifest decode in the
integration test; literal tuple `IN` goes through the already-guarded
`FutureSetFromTuple` and was covered before.
With `iceberg_data_manifest_decode_concurrency = 1` decode the
manifests on the producer thread and push each entry as it is produced,
instead of materializing a whole manifest's batch first. The bounded
queue's backpressure then applies within a manifest, keeping the
previous serial iterator's memory profile: at most the queue capacity
plus one entry (and one decoded manifest) are held, however many
entries a manifest has. The windowed path keeps whole-manifest tasks.

Also cover a single manifest with three times the queue capacity in
entries in the integration test.
A data-manifest decode task drained its whole manifest even after the
query was cancelled or delete decoding failed, so teardown waited for
up to `iceberg_data_manifest_decode_concurrency` full manifest
decodes. The drain loop now checks `blocking_queue.isFinished()` every
256 entries and returns early; the check takes the queue's mutex, so it
stays off the per-entry path, bounding the wait at a few milliseconds
of decoding per task.

Delete-manifest decodes deliberately keep draining: the data producer
finishes the queue once everything is pushed while the query is still
consuming, and the lazy delete decode may run only after that, so a
finished queue does not mean the delete entries are unneeded.
`ManifestFileIterator::next` skips pruned rows internally, so the
teardown check between yielded entries never fired while a manifest was
being fully pruned - and fully pruned manifests are the shape this
setting exists for. `ManifestFileIterator` now takes an optional stop
condition, checked every 256 claimed rows inside the loop, and returns
nullptr as on EOF once it fires. The data-manifest paths pass the
queue's finished state; delete decodes still pass nothing and always
drain fully.

Also cover a fully pruned large manifest in the integration test.
aaron276h and others added 2 commits August 28, 2026 10:53
A decode task queued behind its siblings can begin after the queue is
already finished; it still fetched its manifest before the row-loop
stop check could fire. Check the stop condition once before the fetch,
so only fetches already in flight are waited for on teardown.

@scanhex12 scanhex12 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.

Thanks for your contribution!
I wrote some comments

Comment thread src/Core/SettingsChangesHistory.cpp Outdated
{"min_rows_ratio_for_hash_join_row_store", 5.0, 5.0, "New setting to control the minimum estimated ratio of join output rows to build-side rows to enable transforming hash join payload to row-major. 0 means the transformation is always allowed."},
{"enable_sharding_aggregator", false, false, "Obsolete setting, the sharded aggregator has been removed in favor of the adaptive aggregator (`enable_adaptive_aggregator`)."},
{"query_plan_fuse_filter_into_array_join", false, true, "New optimization to fuse a filter on ARRAY JOINed columns into the ARRAY JOIN step, enabled by default."},
{"iceberg_data_manifest_decode_concurrency", 2, 4, "New setting bounding how many Iceberg data manifest files are decoded concurrently while the list of data files for a query is produced. Before 26.9 one manifest was decoded at a time with the next one's fetch already in flight, so `2` is the closest equivalent of the previous behavior."},

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.

As I remember there was a similar setting to decode delete manifest, maybe we can somehow unite them? Having both is inconvenient.

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.

Good call, switched everything over to iceberg_manifest_decode_concurrency


void IcebergIterator::decodeDataManifests()
{
std::vector<ManifestFileCacheKey> data_manifests;

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.

I think such materialization can be rich in terms of RAM

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 should do it in a streaming way as it was before, but we also need to keep max_in_flight in RAM to prefetch them

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.

Reworked in fdccaf5, each decode task now pushes entries into the bounded queue as they are produced, so nothing materializes a manifest's entries and the queue's backpressure applies within a manifest at every concurrency. This also helped us simplify and get rid of the iceberg_manifest_decode_concurrency=1 workaround.

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.

The current refactor is back to chunk materialization. chunk_size is set to queue_size_ at src/Storages/ObjectStorage/DataLakes/Iceberg/IcebergIterator.cpp:193, and each pool task fills manifest.chunk up to that size before the producer touches the queue (src/Storages/ObjectStorage/DataLakes/Iceberg/IcebergIterator.cpp:307-324).

So with iceberg_manifest_decode_concurrency = 4 and iceberg_file_entries_queue_size = 1, four manifests can each hold one unread entry off-queue at the same time; the "second data file ... has to wait for the query to consume the first one" claim in tests/integration/test_iceberg_manifest_decode_pool/test.py:88-90 is no longer true. That means the earlier streaming/backpressure fix does not hold on the current head: iceberg_file_entries_queue_size no longer bounds unread entries the way the setting docs and the previous comment describe.

<create_query>CREATE TABLE perf_iceberg_data_manifests (id Int64, data String) ENGINE = IcebergLocal(concat(getServerSetting('user_files_path'), '/perf_iceberg_data_manifests/'))</create_query>
<create_query>INSERT INTO perf_iceberg_data_manifests SELECT number + {n} * 500, toString(number) FROM numbers(500) SETTINGS allow_insert_into_iceberg = 1</create_query>

<query>SELECT max(id) FROM perf_iceberg_data_manifests SETTINGS use_iceberg_metadata_files_cache = 0</query>

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.

Nice


ProcessedManifestFileEntryPtr ManifestFileIterator::next()
{
static constexpr size_t stop_check_period = 256;

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.

why do we need this? Could you please write a comment?

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.

Added a comment. We want to be able to notice cancellation while a manifest file is being processed, including while its rows are being pruned, which yields no entries the caller could check on. Checking on every row would be needless overhead, so it runs every 256 rows.

Each decode task now pushes entries into the bounded queue as they are
produced instead of materializing a whole manifest's batch first, so
the queue's backpressure applies within a manifest at every concurrency
and peak memory is the in-flight manifests' decoded contents plus the
queue - a task blocked on `push` holds its pool slot only while the
query is not consuming. The dedicated serial branch for a concurrency
of `1` is gone: a window of one streaming task now has the same memory
profile. Entries from concurrently decoded manifests interleave in the
queue; nothing consumes their relative order.

Delete manifests keep the batch helper - they are collected, not
streamed.

Also add the review-requested comment at the stop check in
`ManifestFileIterator::next`.
One setting, `iceberg_manifest_decode_concurrency`, now bounds both
the delete- and data-manifest decode windows.
`iceberg_delete_manifest_decode_concurrency` (released in 26.8) is
kept as an alias, so existing configurations keep working and
`compatibility` below 26.8 still restores its old default through the
26.8 history entry.
…st-decode-concurrency

# Conflicts:
#	src/Storages/ObjectStorage/DataLakes/Iceberg/IcebergIterator.cpp
On format-version 3 tables the manifest iterator's constructor
materializes every entry's inherited `first_row_id` before `next` is
ever entered, so the walk must honor the stop condition itself; `next`
then stops on its first row and the incomplete ids are never read.

Also cover a format-version 3 table in the integration test: the
`_row_id` column and the result must not depend on the concurrency.
…urrency' into iceberg-data-manifest-decode-concurrency
@aaron276h
aaron276h requested a review from scanhex12 August 31, 2026 21:02

@scanhex12 scanhex12 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.

Ok looks much better, thanks

/// Cap concurrency: each in-flight manifest holds its decoded contents.
const size_t max_in_flight = local_context->getSettingsRef()[Setting::iceberg_manifest_decode_concurrency];

auto stream_runner = threadPoolCallbackRunnerUnsafe<void>(getIOThreadPool().get(), DB::ThreadName::ICEBERG_ITERATOR);

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.

Let's use another pool for data files. As I understood there could be deadlock as we use the same pool as in delete manifest decoding

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.

yeah great catch, added a separate pool


void IcebergIterator::decodeDataManifests()
{
std::vector<ManifestFileCacheKey> data_manifests;

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.

Is it possible to store only indices from data_snapshot->manifest_list_entries to reduce RAM consumption?

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.

Done in 67009b8

data_snapshot_,
persistent_components_)
, manifest_filter_dag(makeManifestFilterDag(filter_dag_, local_context_))
, blocking_queue(100)

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.

I know that it's not your code, but could you please do a separate setting for this 100?

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.

Done in 4e924d5

return batch;
}

void IcebergIterator::streamManifest(const ManifestFileCacheKey & manifest_list_entry)

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.

For now seems much better - it's streaming for data files
But I want to propose a small refactoring
Is it possible to move the logic with blocking queue, streamManifest, decodeDataManifests to a separate class?

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.

Done in 67009b8

The bounded queue, the producer thread, the decode window and the
per-manifest streaming now live in one class; `IcebergIterator` keeps
the delete machinery and delegates. The producer also iterates the
snapshot's manifest list by index instead of copying the DATA entries
into a separate vector.
A streaming decode task can block until the query consumes the entries
it has produced, while `ensureDeletesReady` waits for the delete decode
tasks it schedules on the IO pool before any entry is consumed. With
both kinds of tasks on the IO pool, enough queries could park their
data tasks there to leave no thread for the delete tasks whose
completion would unblock them.

The new pool is sized by `max_iceberg_manifest_decode_thread_pool_size`
(default 100), with the usual free-size and queue-size companions.
scanhex12 and others added 3 commits September 4, 2026 17:24
`DataFileEntriesStream::run` default-constructed `InFlightManifest`, which
made the implicit default constructor of `ManifestFileCacheKey` defined and
tripped `cppcoreguidelines-pro-type-member-init`: five of its fields have no
initializer.

Construct the key instead of assigning it afterwards, so it never exists in
an uninitialized state and `content_type` does not get a meaningless `DATA`
default.

Co-Authored-By: Claude Opus 5 <[email protected]>
Comment on lines +289 to +302
auto & manifest = *in_flight.front();
manifest.future.get();

auto fetch = [this, path = manifest_list_entry.manifest_file_path]()
for (auto & entry : manifest.chunk)
{
return Iceberg::getManifestFile(object_storage, persistent_components, local_context, log, path);
};
prefetched_manifest = PrefetchedManifest{index, prefetch_runner(std::move(fetch), Priority{})};
return;
if (!queue.push(std::move(entry)))
return;
}
manifest.chunk.clear();

if (manifest.exhausted)
in_flight.pop_front();
else
manifest.future = stream_runner([this, scheduled = &manifest] { decodeChunk(*scheduled); }, Priority{});

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.

iceberg_manifest_decode_concurrency stops buying you parallel decode as soon as a manifest needs a second chunk. This loop always waits on in_flight.front(), pushes that chunk, and then reschedules the same manifest, while the later manifests sit in the deque with their first chunks already ready. With chunk_size = iceberg_file_entries_queue_size, any manifest larger than the queue size ends up being decoded essentially serially after the warm-up chunk, so the expensive per-entry pruning path is still single-threaded on exactly the multi-entry-manifest shape this PR is meant to speed up.

I think the producer needs to drain whichever future becomes ready, or the workers need to stream directly into the bounded queue, instead of pinning progress to manifest-list order here.

@clickhouse-gh

clickhouse-gh Bot commented Sep 5, 2026

Copy link
Copy Markdown
Contributor

📊 Cloud Performance Report

⚠️ AI verdict: not_sure — no significant changes across 41 queries analysed

1 query inconclusive (baseline era shift, segment too thin). K_source=6 K_base=30 flagged=0/65

clickbench

🟢 No significant changes

tpch_adapted_1_official

⚠️ 1 inconclusive

Flagged queries (1 of 22)
Query Verdict Baseline median (ms) PR median (ms) Change q-value Hint
⚠️ 17 not_sure 100 66 -34.0% <0.0001

Change = percent below ×2; the ratio of medians (×N faster/slower) beyond, where percent understates the scale. q-value = BH-FDR adjusted p; smaller is stronger evidence. MIRAI flags a query when q < fdr_q (default 0.10) — the value the verdict is based on.

Debug info
  • StressHouse run: a943aa71-e994-4413-b9ab-178d43b1e8f8
  • MIRAI run: ec9ff76c-c987-45cc-befc-2caa94ea45a5
  • PR check IDs:
    • clickbench_1315915_1788625371
    • clickbench_1315921_1788625371
    • clickbench_1315927_1788625371
    • tpch_adapted_1_official_1315938_1788625371
    • tpch_adapted_1_official_1315949_1788625371
    • tpch_adapted_1_official_1315987_1788625371

@scanhex12
scanhex12 enabled auto-merge September 5, 2026 17:45
@scanhex12
scanhex12 added this pull request to the merge queue Sep 5, 2026
Merged via the queue into ClickHouse:master with commit 24916a7 Sep 5, 2026
172 of 175 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 Sep 5, 2026
@aaron276h

Copy link
Copy Markdown
Contributor Author

@scanhex12 thank you for the reviews and your help landing this, it is very appreciated!

@scanhex12

Copy link
Copy Markdown
Member

@aaron276h nice to hear, thanks for your contribution once again!)

@scanhex12 scanhex12 added the pr-must-backport Pull request should be backported intentionally. Use this label with great care! label Sep 16, 2026
@robot-clickhouse-ci-2 robot-clickhouse-ci-2 added the pr-must-backport-synced The `*-must-backport` labels are synced into the cloud Sync PR label Sep 16, 2026
alexey-milovidov pushed a commit that referenced this pull request Sep 19, 2026
Merge backport/26.8/116723 into cherrypick/26.8/116723 to finish the robot
cherry-pick of #116723 "Parallelize Iceberg data manifest decoding", which
GitHub reports as CONFLICTING.

Five of the nineteen paths needed a decision; the other fourteen land as the
merge produced them.

src/Storages/ObjectStorage/DataLakes/Iceberg/IcebergIterator.cpp: the rewrite
consolidated both manifest-iterator call sites into createManifestIterator, so
the resolved file is master's file plus two argument-level edits. 26.8's
Iceberg::getManifestFile still takes the bytes_size parameter that master
dropped in #116564, so manifest_list_entry.manifest_file_byte_size is passed;
26.8's ManifestFileIterator::create has no row-lineage parameter, so
manifest_list_entry.first_row_id is not passed.

src/Storages/ObjectStorage/DataLakes/Iceberg/ManifestFileIterator.cpp: the
incoming constructor body materializes per-entry first_row_id values for
format-version 3 manifests. Iceberg row lineage does not exist on 26.8, so the
26.8 (empty) side is taken. The cancellation check the PR adds between rows in
next() sits outside the conflict and is kept, so the new stop flag still
reaches the decode loop rather than being dropped with the walk.

src/Interpreters/PreparedSets.h: include union only. 26.8 keeps its own include
block plus <mutex> for the mutex member the PR adds.

src/Core/SettingsChangesHistory.cpp: a plain merge resolves this file by
importing master's whole "26.9" section, which names settings that do not exist
on 26.8, so applyCompatibilitySetting() throws UNKNOWN_SETTING for every SET
compatibility and a server with compatibility in a profile exits with code 115
at startup. That was fixed once already on this branch, by 0debf7d. The
imported section is therefore dropped and the two new entries are appended to
the branch's own "26.8" block, without master's "pre-26.9" and "compatibility
at or below 26.8" clauses, which are false here. The branch's existing
iceberg_delete_manifest_decode_concurrency entry is unchanged, so compatibility
at or below 26.7 yields 2 for both the data and the delete path, and an
unpinned server yields 4 for both. Leaving the entries out entirely is not an
option: 03999_stateless_settings_history requires every setting absent from the
frozen baseline to be recorded, and neither new setting is in the baseline.

tests/integration/test_storage_iceberg_with_spark/test_data_manifest_decode_concurrency.py:
test_data_manifest_decode_concurrency_row_lineage writes a format-version 3
table and selects _row_id, a virtual column 26.8 does not have. It is excised
and the other five tests are unchanged. Nothing on 26.8 loses coverage, because
the behavior it pins, per-entry first_row_id materialization under concurrency,
has no implementation on this branch.

Related: #116723
Related: #120406
alexey-milovidov added a commit that referenced this pull request Sep 19, 2026
…723-resolved

Resolve the 26.8 cherry-pick conflicts of #116723
clickhouse-gh Bot added a commit that referenced this pull request Sep 19, 2026
Backport #116723 to 26.8: Parallelize Iceberg data manifest decoding
@robot-ch-test-poll2 robot-ch-test-poll2 added the pr-backports-created Backport PRs are successfully created, it won't be processed by CI script anymore label Sep 26, 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-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

Projects

None yet

Development

Successfully merging this pull request may close these issues.

8 participants