Repository navigation
Description
What's the feature are you trying to implement?
As @colinmarc mention in https://apache-iceberg.slack.com/archives/C05HTENMJG4/p1753476472857519 , performance of iceberg-datafusion integration is lower than pure datafusion reading parquet file directly. As mention by @liurenjie1024 , it's caused by iceberg-datafusion integration only use one thread now. This issue propose a design to support parallel scan in iceberg-datafusion integration. And thanks to https://github.com/colinmarc/iceberg-datafusion-benchmarks from @colinmarc let us can dive into the bottleneck!
Row group based parallel scan
This parallel scan is row group based. The basic idea is to prune the file need scan into several group and pack them based on the parallism set by datafusion. The benefit of row group base parallel:
- Parallel scan even in less file scene
- More even distribute the read load after prune some row group in the file, e.g.
let mut selected_row_group_indices = None;
The process can be describe as following:
- 1 is our plan_file now, prune the iceberg metadata and get the FileScanTask finally. It's one data file bind with several delete file related to it.
- 2 We introduce a
GroupPruner, which can attach the group info at FileScanTask and prune the some group based on predicate. We can implement group pruner for specific file format, e.g.ParquetGroupPrunerto process different format of FileScanTask. - 3 FileScanTask with group info can be split into multilple FileScanTask or merge. Base on the parallesim, we can repartition the FileScanTask into multiple PartitionTask which contain several FileScanTask.
Each partition task return as a RecordBatchStream when we execute using corresponding partition.
Willingness to contribute
Yes
Activity
ZENOTME commentedon Aug 17, 2025
I draft the implementation of design above #1610, test on local machine(mac m1 pro). Although the latency is high and not stable but we can see that the performance of iceberg-rust is much closer to datafusion-parquet. I will build a local test env to bench it next step.
ZENOTME commentedon Aug 18, 2025
Feel free for any suggestion for this cc @liurenjie1024 @sdd @Xuanwo @Fokko @kevinjqliu
liurenjie1024 commentedon Aug 19, 2025
Thanks @ZENOTME for raising this, but I have concern to do the filter in task planning phase, as opening data files is typically slow. There are several places to improve:
iceberg-rust/crates/integrations/datafusion/src/physical_plan/scan.rs
Line 105 in 6e21b7f
iceberg-rust/crates/integrations/datafusion/src/table/mod.rs
Line 152 in 36cc120
As with row group pruning, it should be pushed to parquet reader.
ZENOTME commentedon Aug 19, 2025
Thanks feedback from @liurenjie1024! Here are my consideration: Datafusion is static partition at plan phase, so comparing size base planning, row group plan may achieve a more balanced partitioning at data skew scene.
I think the overall execution time remains the same—we’re essentially moving the group pruning logic from the reader stage to the planning stage. If metadata is retrieved during planning, it can be reused by the reader to avoid fetching it again (though we need to weigh the memory overhead).
I think this could be an optional behavior, allowing users to make the tradeoff: either spend more time during planning and to achieve a more balanced partitioning, or use a size-based plan for faster planning. The best choice will depend on the actual data distribution.
I also agree we don’t need to introduce too many optimizations upfront. Still, I’m curious whether this is a realistic need in practice—if so, it may be worth making some room for it in the design so that we can extend in this direction later if necessary.
liurenjie1024 commentedon Aug 20, 2025
Please remember that this library is not designed for datafusion only, but for all compute engines. Pruning row group at planning phase helps a little for data skew, but not that much in most cases. Remember that we have more filters such as page level filtering, deletion vector, eq deletes to further remove records. There are many problems with row group pruning at planning phase:
Compared with the problems it brings, I don't see much benefit it brings. There are many ways to deal with data skew, and this approach doesn't help that much.
Fokko commentedon Aug 20, 2025
@ZENOTME Are you benchmarking against a local FS? I think one of the important objectives is to be efficient against Object-Stores, something that isn't taken into consideration with a local FS.
I share @liurenjie1024's concern of opening up the Parquet file in the driver/kernel, since the overhead of opening a file is significant (miliseconds until first byte).
That's true, but not always the case. For exameple, Spark leverages distributed planning. Each manifest file has a target size of 8MB, which could be dispatched for distributed planning.
I would flip it around, what's the problem if an executor opens up a Parquet file and reads very little data. This is unlikely since we have the min/max of the file, but the row-group could still be skipped if it doesn't hit the min/max there. Parsing the Parquet footer is also pretty slow, especially for wide schema's, so I would be reluctant to send that over the wire.
ZENOTME commentedon Aug 20, 2025
Thanks for the suggestions from @Fokko and @liurenjie1024, I learned a lot!
It's close to my initial thought for the distributed case. Wee can push the row group pruning down to the executors, and at the same time cache the metadata they read there, so we don’t have to pay the cost of opening the data file twice. But number of data files is much more than manifest files so the cache size need to be consideration.
This does make things more complex and the benefit is still uncertain. Let’s stick to the size-based planning for now. I'd like to implement it if no one implement it now and bench it again to see what happen.
ZENOTME commentedon Aug 20, 2025
Let’s stick to the size-based planning for now. #128