Skip to content

Parallelize delete manifests reads - #112679

Merged
asya-ch merged 25 commits into
masterfrom
asya/worker_pool
Aug 20, 2026
Merged

asya-ch merged 25 commits into
masterfrom
asya/worker_pool

Conversation

@asya-ch

@asya-ch asya-ch commented Jul 30, 2026 •

Copy link
Copy Markdown
Collaborator

Changelog category (leave one):

  • Performance Improvement

Changelog entry:

Queries on Iceberg tables with many delete files now start faster. ClickHouse reads and decodes the delete manifest files concurrently instead of one at a time, so their storage reads overlap. The new setting iceberg_delete_manifest_decode_concurrency (default 4) controls how many are decoded at the same time.


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

Version info

  • Merged into: 26.8.1.1784 (included in 26.8 and later)

@asya-ch asya-ch changed the title Process delete manifests concurrently Parallelize delete manifests reads Jul 30, 2026
@clickhouse-gh

clickhouse-gh Bot commented Jul 30, 2026 •

Copy link
Copy Markdown
Contributor

Workflow [PR], commit [b4b3061]

Summary: ✅


AI Review

Summary

This PR lazily parallelizes Iceberg delete-manifest decoding so data-manifest prefetch can overlap with delete processing, and it adds a new iceberg_delete_manifest_decode_concurrency setting plus correctness/performance coverage. The direction looks good, but one failure-path regression and one unresolved proof gap still remain, so this is not ready to approve.

Findings

⚠️ Majors

  • [src/Storages/ObjectStorage/DataLakes/Iceberg/IcebergIterator.cpp:370] decodeDeleteManifests can now fail only after producer_task has already started in the constructor. The catch path does blocking_queue.clearAndFinish() and rethrows, but it does not give the in-flight data_files_iterator.next() call any earlier cancellation point, so a bad delete manifest or transient object-store error can still leave the shared iterator doing extra data-manifest fetch/parse work until every source tears it down. That is a real failure-path regression versus the old constructor-time delete decoding. Suggested fix: add an explicit producer cancellation path that data_files_iterator.next() / the producer loop observes before starting or continuing another manifest read, and quiesce that background work before surfacing the fatal delete-manifest exception.
  • [tests/performance/iceberg_delete_manifests.xml:218] [dismissed by author -- https://github.com/Parallelize delete manifests reads #112679#discussion_r3739210058] The only added benchmark runs IcebergLocal with no iceberg_slow_manifest_read latency, so it cannot fail if the remote delete-manifest fetch path becomes serialized again. That leaves the PR's Performance Improvement claim about overlapping object-storage round-trips under-proven. Suggested fix: add the delete-manifest analogue of tests/integration/test_storage_iceberg_with_spark/test_manifest_read_performance.py (remote-backed + failpoint timing), or provide equivalent focused before/after evidence on the remote path.
Final Verdict

Status: ⚠️ Request changes

Minimum required actions:

  • Stop the background data-manifest producer promptly when delete-manifest decoding fails.
  • Add focused evidence for the claimed remote delete-manifest fetch overlap, not just a local IcebergLocal benchmark.

LLVM Coverage Report

Metric Baseline Current Δ
Lines 86.90% 86.90% +0.00%
Functions 91.90% 91.90% +0.00%
Branches 79.20% 79.20% +0.00%

Changed lines: Changed C/C++ lines covered: 115/121 (95.04%) · Uncovered code

Full report · Diff report

@clickhouse-gh clickhouse-gh Bot added the pr-performance Pull request with some performance improvements label Jul 30, 2026
return

# Verify failpoint fired.
serial_floor = 0.8 * DELETE_COUNT * SLEEP_PER_MANIFEST_SECONDS

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.

Perhaps it would be better to add such checks to the performance tests?

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

Perf tests unfortunately can't cover it because that environment has no Spark, minio/s3 disks, or Iceberg tests.

I think it would be nice to eventually add it so that these improvements are more measurable, but this is probably not the place.

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.

has no Spark, minio/s3 disks

I think we can use IcebergLocal

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

Good point, I'll add it.

@clickhouse-gh clickhouse-gh Bot added the submodule changed At least one submodule changed in this PR. label Jul 31, 2026
@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: 114/119 (95.80%) · Uncovered code

Full report · Diff report

@asya-ch

asya-ch commented Aug 5, 2026

Copy link
Copy Markdown
Collaborator Author

I opened a fix for the flake in CI here: #113398.
Once that is merged, will merge master 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 parallelizes decoding of Iceberg delete manifest files so multiple object-storage reads and pruning work can overlap before reading data files, controlled by a new iceberg_delete_manifest_decode_concurrency setting (default 4). It also adds an integration test to validate correctness across different concurrency values and to assert that decoding is actually concurrent under a latency-injection failpoint.

Changes:

  • Parallelize delete-manifest decoding in IcebergIterator using bounded concurrency with the IO thread pool.
  • Add the iceberg_delete_manifest_decode_concurrency setting and register it in settings history for compatibility.
  • Add an integration test covering correctness and concurrency/timing behavior.

Reviewed changes

Copilot reviewed 5 out of 5 changed files in this pull request and generated 3 comments.

Show a summary per file
File Description
tests/integration/test_storage_iceberg_with_spark/test_delete_manifest_decode_concurrency.py Adds correctness + timing-based concurrency coverage for delete manifest decoding using iceberg_slow_manifest_read.
src/Storages/ObjectStorage/DataLakes/Iceberg/IcebergIterator.h Adds delete-manifest lazy init/decode helpers and synchronization state for one-time initialization.
src/Storages/ObjectStorage/DataLakes/Iceberg/IcebergIterator.cpp Implements bounded parallel decode of delete manifests and defers decoding to next via ensureDeletesReady.
src/Core/SettingsChangesHistory.cpp Records the new setting for compatibility behavior across versions.
src/Core/Settings.cpp Documents and defines the new iceberg_delete_manifest_decode_concurrency setting (default 4).

Comment thread src/Core/Settings.cpp Resolved
Comment thread src/Core/SettingsChangesHistory.cpp Resolved
Comment on lines +214 to +218
<create_query>CREATE TABLE perf_iceberg_delete_manifests (id Int64, data String) ENGINE = IcebergLocal(concat(getServerSetting('user_files_path'), '/perf_iceberg_delete_manifests/'))</create_query>
<create_query>INSERT INTO perf_iceberg_delete_manifests SELECT number, toString(number) FROM numbers(100000) SETTINGS allow_insert_into_iceberg = 1</create_query>
<create_query>ALTER TABLE perf_iceberg_delete_manifests DELETE WHERE id = {n} SETTINGS allow_insert_into_iceberg = 1</create_query>

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

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 Performance Improvement claim here is specifically about overlapping object-storage round-trips, but this benchmark only runs IcebergLocal and never injects manifest-read latency. It can stay green even if the remote fetch path becomes accidentally serialized again, because it is only measuring local decode CPU.

Please keep a focused timing check that exercises getManifestFile latency as well, for example by enabling iceberg_slow_manifest_read on a remote-backed Iceberg read path, in addition to this local benchmark.

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

I think it is fine as-is. Perf tests don't support failpoints and must run pretty quickly, so it's more difficult than it's worth to simulate download latency in the perf test. This test does show ~20% improvement, so I think it is good enough as a heuristic.

@clickhouse-gh

clickhouse-gh Bot commented Aug 9, 2026 •

Copy link
Copy Markdown
Contributor

📊 Cloud Performance Report

🟢 AI verdict: improvement — 3 query(s) improved out of 34 analysed

This PR only changes Iceberg delete-manifest decoding (making delete manifests decode concurrently) plus a new iceberg_delete_manifest_decode_concurrency setting. None of the flagged ClickBench or TPC-H queries read Iceberg tables, so they execute none of the changed code. The consistently one-directional improvements are off-path and were downgraded to not_sure where possible; clickbench Q23 (x2.3 faster), tpch Q7 (x8.4 faster) and Q8 (x2.1 faster) are locked by their large deltas but likewise don't correspond to the change, so treat them as build/measurement variance. The two envelope-suppressed rows (clickbench Q12 and Q31) correctly read as no_change and are consistent with this being an Iceberg-only change.

clickbench

🟢 1 improved · ⚠️ 6 inconclusive

Flagged queries (7 of 43)
Query Verdict Baseline median (ms) PR median (ms) Change q-value Hint
🟢 23 improvement 164 72 ×2.3 faster <0.0001 Off the changed Iceberg path, but the x2.3 faster delta with very noisy source samples locks deterministically by magnitude; read it as build/measurement variance rather than this PR.
⚠️ 13 not_sure 422 331 -21.6% <0.0001 This PR only changes Iceberg delete-manifest decoding; this ClickBench MergeTree query runs none of that path, so the -21.6% delta is run-to-run variance, not a PR effect.
⚠️ 15 not_sure 192 158 -17.7% <0.0001 The changed code is Iceberg-only; this ClickBench query never executes it, so the -17.7% shift is not attributable to this PR.
⚠️ 16 not_sure 734 606 -17.4% <0.0001 Off the changed Iceberg delete-manifest path; the -17.4% delta on this MergeTree query is run-to-run variance, not a PR effect.
⚠️ 18 not_sure 1244 1064 -14.5% <0.0001 This query does not touch the Iceberg code changed here; the -14.5% delta (and noisy underlying samples) is variance, not the PR.
⚠️ 30 not_sure 279 216 -22.6% <0.0001 The PR changes only Iceberg delete-manifest decoding; this ClickBench query runs none of it, so the -22.6% delta is run-to-run variance.
⚠️ 33 not_sure 1250 1172 -6.2% <0.0001 Off the changed Iceberg path; the -6.2% delta on this MergeTree query is not attributable to this PR.

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.

tpch_adapted_1_official

🟢 2 improved

Flagged queries (2 of 22)
Query Verdict Baseline median (ms) PR median (ms) Change q-value Hint
🟢 7 improvement 560 67 ×8.4 faster <0.0001 This TPC-H query does not exercise the Iceberg delete-manifest path; the x8.4 faster delta locks by its large magnitude but does not correspond to this change.
🟢 8 improvement 166 78 ×2.1 faster <0.0001 Off the changed Iceberg path; the x2.1 faster delta locks by magnitude but reflects build/measurement variance, not this change.

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: 88a5c37d-4ce8-4fb5-ae35-d8701054df44
  • MIRAI run: c801f94f-8971-4a97-b977-7dc683c41767
  • PR check IDs:
    • clickbench_13365_1787112341
    • clickbench_13371_1787112341
    • clickbench_13390_1787112340
    • tpch_adapted_1_official_13397_1787112341
    • tpch_adapted_1_official_13411_1787112341
    • tpch_adapted_1_official_13456_1787112341

});
}

void IcebergIterator::ensureDeletesReady()

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 lazy decoding? maybe it's better to start it in the constructor?

@asya-ch asya-ch Aug 13, 2026 •

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

The main reason is that you don't need to wait for deletes to be processed to kick off the producer thread that downloads data files, so you get extra overlap.

(I'll add a comment to make it more clear.)

@clickhouse-gh

clickhouse-gh Bot commented Aug 13, 2026 •

Copy link
Copy Markdown
Contributor

Build profile diff (arm_release)

Comparing b4b306185 with master 90e6c433c (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
Binary Master PR Δ
programs/clickhouse-stripped 703.88 MiB 700.86 MiB -3.02 MiB (-0.43%)

Only the stripped binary is compared: the official master build keeps debug symbols while PR builds strip them, so the other binaries differ by construction.

Object file sizes

5 object files changed (+50.78 KiB total), 0 added.

Object file Master PR Δ
src/CMakeFiles/dbms.dir/Storages/ObjectStorage/DataLakes/Iceberg/IcebergIterator.cpp.o 306.53 KiB 354.62 KiB +48.09 KiB (+15.69%)

737 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

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

Job report

}
catch (...)
{
deletes_exception = std::current_exception();

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.

producer_task already starts in the constructor, before any delete manifest is decoded. If decodeDeleteManifests() throws here (bad delete manifest, transient object-store error, etc.), we store the exception but never stop the background data-manifest producer, so this shared iterator can keep prefetching/parsing data manifests until every source tears it down. Before this change the same failure aborted construction before that work existed.

Can we signal cancellation on this path as well (for example blocking_queue.finish() plus any extra producer stop you need) so a fatal delete-manifest error stops the background work immediately?

@asya-ch
asya-ch added this pull request to the merge queue Aug 20, 2026
Merged via the queue into master with commit 0b043a6 Aug 20, 2026
347 of 348 checks passed
@asya-ch
asya-ch deleted the asya/worker_pool branch August 20, 2026 17:17
@robot-ch-test-poll4 robot-ch-test-poll4 added the pr-synced-to-cloud The PR is synced to the cloud repo label Aug 20, 2026
@asya-ch

asya-ch commented Aug 20, 2026

Copy link
Copy Markdown
Collaborator Author

Closes #105044

pull Bot pushed a commit to erickirt/ClickHouse that referenced this pull request Sep 5, 2026
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`.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

pr-performance Pull request with some performance improvements pr-synced-to-cloud The PR is synced to the cloud repo submodule changed At least one submodule changed in this PR.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants