Repository navigation
Conversation
c25fe90 to
88cfea7
Compare
|
Hi @kssenii — first-time contributor here, so I think CI needs a maintainer to enable it on this PR. Could you kick off CI or point me to the right reviewer? It's a small, opt-in change to IcebergIterator: a new experimental setting iceberg_parallel_manifest_decode_threads (default 1 = current behavior) that decodes a snapshot's data manifests across N threads, improving performance for tables with many manifest files. Happy to address any feedback, thanks! |
…coding Reading an Iceberg snapshot's data files requires walking the snapshot's manifest list and decoding each manifest file. IcebergIterator does this with a single background producer thread, so for tables with many manifest files the manifest walk is serial and can dominate query planning time. Add a setting iceberg_parallel_manifest_decode_threads (UInt64, default 1, EXPERIMENTAL). With the default value of 1 the behavior is unchanged: a single producer walks the manifest list as before. With a value greater than 1, IcebergIterator builds N SingleThreadIcebergKeysIterator instances that share one atomic counter over the snapshot's manifest_list_entries and spawns N producer tasks; each producer claims the next manifest index via fetch_add, so the manifests are decoded cooperatively with no overlap. The last producer to finish closes the queue. The effective thread count is clamped to the number of manifest files, so an oversized value has no extra effect. SingleThreadIcebergKeysIterator takes an optional shared atomic index; when null (the default) it uses its private index, preserving the single-threaded path exactly. Delete-file manifests are still drained serially on the calling thread, since the data-file pruning logic depends on the full delete set. If spawning a producer throws (for example, the global thread pool is saturated), the constructor drains and joins the producers already started before rethrowing, so a partially-constructed iterator does not abort the process via ThreadFromGlobalPool's destructor. Add a ProfileEvent IcebergParallelManifestDecodeThreadsSpawned counting the producer threads spawned, a unit test for the shared-index claim contract, a stateless test for the setting, and an integration test that checks result parity across thread counts (including a query with an IN filter, which exercises concurrent lazy materialization of the shared filter set).
88cfea7 to
3a0a1fc
Compare
|
Friendly bump, this has been open ~3 weeks and waiting on CI be enabled. @Algunenano, would you be able to kick off CI or point me to the right reviewer? It's a small, opt-in IcebergIterator change: a new experimental setting `iceberg_parallel_manifest_decode_threads. Happy to address any feedback, thanks! |
|
Workflow [PR], commit [d155c84] Summary: ❌
AI ReviewSummaryThis PR adds the experimental setting Final Verdict
|
The previous clamp used the total size of manifest_list_entries, which includes delete manifests. Delete manifests are drained serially before the producers start and never participate in the parallel decode, so on delete-heavy snapshots the clamp allowed spawning producers that could never claim useful work while still occupying global thread pool slots. Count only content_type == DATA entries instead; the content type is already available in the in-memory manifest list, so this is a single pass over a vector. Update the setting docstring and test comments to describe the tighter bound.
|
Updating the branch to fix the |
The fixture previously contained only data manifests, so the spawn-counter assertion could not distinguish clamping on the DATA manifest count from clamping on the total manifest-list entry count. Create the table with write.delete.mode = merge-on-read and add a final phase that deletes one row, producing a snapshot with 8 data manifests plus 1 positional-delete manifest. The phase asserts that the spawn counter at 16 requested threads still equals 8 (the DATA count) rather than 9 (the total), and that query results match the serial run in the presence of positional deletes.
| @@ -0,0 +1,203 @@ | |||
| """ | |||
There was a problem hiding this comment.
The contract of this PR is lower planning latency on manifest-heavy Iceberg snapshots, but this suite only proves result parity and the IcebergParallelManifestDecodeThreadsSpawned accounting. Because the new path adds extra scheduling, queueing, and manifest-list scanning, we still need focused before/after evidence that it actually improves the intended workload instead of just moving work around.
Please add a small benchmark or representative threads=1 vs threads>1 measurements for a table with many manifests.
There was a problem hiding this comment.
Added measurements. Setup: single node, this PR's CI binary, synthetic Iceberg v2 table with 8000 data files across 295 manifests (one bulk Spark insert with REPARTITION_BY_RANGE, then commit.manifest.target-size-bytes=1024 + rewrite_manifests to fan out the manifest list). Query is a selective point lookup (WHERE id = ..., prunes to a single file) with use_iceberg_metadata_files_cache = 0 so every run pays the full manifest walk. Two storage configurations: minio directly (near-zero RTT), and the same minio behind a forwarding proxy adding a fixed 25 ms per request to emulate object-storage round-trip latency. Median of 3 runs, server-side query_duration_ms:
| threads | 25 ms RTT | direct minio |
|---|---|---|
| 1 (default, old code path) | 18.3 s | 0.93 s |
| 4 | 4.9 s (3.7x) | 0.53 s |
| 8 | 2.7 s (6.7x) | 0.67 s |
| 16 | 1.7 s (10.7x) | 1.09 s |
The serial walk pays ~(requests x RTT) against the metadata store, and the producers divide exactly that term, so the speedup tracks per-request latency: large on real object storage, modest on a local store — and at high thread counts against a zero-latency store the extra scheduling shows up as mild overhead, which is why the setting defaults to 1 and is opt-in per query. IcebergMetadataReadWaitTimeMicroseconds (consumer wait on the manifest queue) shows the same shape: 88 s cumulative at threads=1 vs 5.6 s at threads=16 in the delayed configuration. Happy to share the exact Spark statements if useful.
At the default iceberg_parallel_manifest_decode_threads = 1 the constructor no longer scans manifest_list_entries to count DATA manifests before concluding that no parallelism is needed: the setting is read first and the count runs only when the query asks for more than one thread. The clamp semantics for the parallel case are unchanged.
…path The constructor's catch block that drains and joins already-started producers when a later ThreadFromGlobalPool spawn throws was untested. Add a ONCE failpoint (iceberg_parallel_manifest_decode_spawn_failure) that makes the second producer spawn throw CANNOT_SCHEDULE_TASK while the first producer is already running, and extend the integration test to verify the query fails with a regular catchable exception, the server stays up, and the same query succeeds immediately afterwards.
A bare SELECT count() on an iceberg table is answered from snapshot metadata by the trivial-count optimization, so the data-file iterator is never constructed and the spawn-failure failpoint never fires, making the pytest.raises assertion fail with DID NOT RAISE in the flaky check. Use the same full-scan query shape as the other phases for the probe, and disable the failpoint explicitly after the expected failure so the recovery check does not depend on ONCE semantics.
|
Hi @Diskein, friendly ping, this one should be ready for review. All the automated review comments have been addressed, and CI finished. The two remaining failures look unrelated to the change: |
LLVM Coverage Report
Changed lines: Changed C/C++ lines covered: 167/168 (99.40%) · Uncovered code |
|
Hey, thanks so much for the hard work here — appreciate the time to benchmark and add fault-injection coverage. My main concern with this approach is that the producer threads spend most of their time parked rather than doing work, and they stay alive for most of the scan duration. We could avoid this by instead implementing a worker pool that only occupies threads when there is work to do. I'm already working on this for #105044. Because of the overlap (and in the interest of keeping the code and settings surface area maintainable), I would prefer to not merge this diff. Thanks again for the effort here, happy to discuss further. |
|
@aaron276h, I just merged an optimization for manifest downloads in #108543. Would this fit your use case? One alternative to using a worker pool for data manifests would be to expand that optimization to prefetch multiple manifests instead of just one. |
|
Hi @asya-ch, thanks for taking a look, really appreciate the review. On whether #108543 covers this use case: I benchmarked against one of our production tables and I don't think it does. The current snapshot has 18 data manifests totaling 113 MB, 82 columns, holding ~75k entries with ~1.5 KB of per-column bounds each. To isolate the walk from data reads I mirrored the snapshot's metadata locally and ran a binary with this PR's change, using a predicate on the identity partition column that prunes every file, with the metadata cache disabled and files in page cache:
Splitting that 8.45 s: since the #108543 prefetch task runs Given that, would it make sense to extend the #105044 worker-pool direction to the data-manifest walk, with each pool task owning fetch + deserialize + entry-processing for one manifest, scheduled only while the output queue has room? It would avoid long-lived parked threads entirely, and could reuse whatever knob your pool introduces, I'd happily drop Happy to close this PR in favor of that direction. Thanks! |
|
I see, thanks for providing the benchmark.
I think this would be good! We might want to make it more granular than each task = "processing for the whole manifest" in order to quickly output the ProcessedManifestFileEntryPtr from I will implement #105044 first, and if you would like to build the data-manifest side on top, that would be great! I will ping you once it lands. |
|
Dear @Diskein, 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. |
|
@aaron276h, #105044 has merged, feel free to proceed with the data-manifest side! (Also, never mind to what I said earlier about "might want to make it more granular than each task = "processing for the whole manifest" in order to quickly output the ProcessedManifestFileEntryPtr from next()", I think that would be overly complicated.) |
Reading an Iceberg snapshot's data files requires walking the snapshot's manifest list and decoding each manifest file.
IcebergIteratorcurrently does this with a single background producer thread, so for tables with many manifest files the manifest walk is serial and can dominate query planning time.This adds an opt-in, experimental setting
iceberg_parallel_manifest_decode_threads(UInt64, default1). At the default value of1behavior is unchanged. With a value greater than1,IcebergIteratorbuilds N data-file iterators that share one atomic counter over the snapshot'smanifest_list_entriesand spawns N producer tasks; each producer claims the next manifest index viafetch_add, so manifests are decoded cooperatively with no overlap, and the last producer to finish closes the queue. The effective thread count is clamped to the number of manifest files. Delete-file manifests are still drained serially, since data-file pruning depends on the full delete set. A newProfileEventIcebergParallelManifestDecodeThreadsSpawnedreports how many producer threads were spawned.Tests: a unit test for the shared-index claim contract, a stateless test for the setting, and an integration test asserting result parity across thread counts (including a query with an
INfilter, which exercises concurrent lazy materialization of the shared filter set).Changelog category:
Changelog entry (a user-readable short description of the changes that goes into CHANGELOG.md):
Added an experimental setting
iceberg_parallel_manifest_decode_threadsthat decodes Iceberg manifest files using multiple threads during query planning, speeding up reads of tables with many manifest files.