Skip to content

Conversation

@mbutrovich
Copy link
Contributor

@mbutrovich mbutrovich commented Jan 6, 2026

Which issue does this PR close?

N/A

Rationale for this change

Profiling Iceberg native scans revealed significant overhead in async stream polling, particularly:

  • tokio::drop_waker and tokio::park::clone consuming substantial time in IcebergStreamWrapper::poll_next
  • futures_util::stream::flatten_unordered::SharedPollState::{start_polling,stop_polling} showing lock contention

I think this is due to competing parallelization logic: IcebergFileStream passed one FileScanTask at a time to iceberg-rust, causing flatten_unordered to coordinate parallelization across a single task (pure overhead). Stream nesting created excessive waker churn.

What changes are included in this PR?

How are these changes tested?

Existing tests.

@mbutrovich mbutrovich marked this pull request as draft January 6, 2026 22:41
@codecov-commenter
Copy link

codecov-commenter commented Jan 6, 2026

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 60.02%. Comparing base (f09f8af) to head (ab21b1e).
⚠️ Report is 857 commits behind head on main.

Additional details and impacted files
@@             Coverage Diff              @@
##               main    #3051      +/-   ##
============================================
+ Coverage     56.12%   60.02%   +3.89%     
- Complexity      976     1429     +453     
============================================
  Files           119      170      +51     
  Lines         11743    15746    +4003     
  Branches       2251     2602     +351     
============================================
+ Hits           6591     9451    +2860     
- Misses         4012     4976     +964     
- Partials       1140     1319     +179     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

# Conflicts:
#	native/core/src/execution/operators/iceberg_scan.rs
@mbutrovich mbutrovich changed the title fix: [WIP] [iceberg] Remove IcebergFileStream and use iceberg-rust's parallelization fix: [iceberg] Remove IcebergFileStream and use iceberg-rust's parallelization Jan 7, 2026
@mbutrovich mbutrovich marked this pull request as ready for review January 9, 2026 23:50
@mbutrovich mbutrovich changed the title fix: [iceberg] Remove IcebergFileStream and use iceberg-rust's parallelization perf: [iceberg] Remove IcebergFileStream and use iceberg-rust's parallelization Jan 12, 2026
@mbutrovich mbutrovich marked this pull request as draft January 13, 2026 20:54
liurenjie1024 added a commit to apache/iceberg-rust that referenced this pull request Jan 20, 2026
…oid waker churn and add determinism to FileScanTask processing (#2020)

## Which issue does this PR close?

- N/A.

## What changes are included in this PR?

- Due to the way Comet maps DataFusion `SessionContext`, the tokio
runtime, and Spark Tasks, we see frequent waker churn when concurrency
is set to 1 in the `ArrowReader`. This adds a fast path that does not
use `try_flatten_unordered` and its internal `replace_waker` calls.
- This also prevents tasks from being reordered at runtime. Several
Iceberg Java tests expect specific query results without an `ORDER BY`,
so this enables those tests to keep working when concurrency is set to
1.

See apache/datafusion-comet#3051 and 
 
<img width="3804" height="754" alt="flamegraph"
src="https://github.com/user-attachments/assets/26b93e85-5835-4bf4-b7f1-b136face940d"
/>

## Are these changes tested?


New test for determinism, also running the entire Iceberg Java Spark
suite via Comet in apache/datafusion-comet#3051.

---------

Co-authored-by: Renjie Liu <liurenjie2008@gmail.com>
@mbutrovich
Copy link
Contributor Author

apache/iceberg-rust#2020 merged so we should be good to review this now.

@mbutrovich mbutrovich marked this pull request as ready for review January 20, 2026 14:39
@mbutrovich mbutrovich requested a review from andygrove January 20, 2026 14:46
@mbutrovich
Copy link
Contributor Author

Thanks for the review @andygrove! Will merge once CI goes green again.

@mbutrovich mbutrovich changed the title perf: [iceberg] Remove IcebergFileStream and use iceberg-rust's parallelization perf: [iceberg] Remove IcebergFileStream, use iceberg-rust's parallelization, bump iceberg-rust to latest Jan 20, 2026
@mbutrovich mbutrovich changed the title perf: [iceberg] Remove IcebergFileStream, use iceberg-rust's parallelization, bump iceberg-rust to latest perf: [iceberg] Remove IcebergFileStream, use iceberg-rust's parallelization, bump iceberg-rust to latest, cache SchemaAdapter Jan 20, 2026
@mbutrovich mbutrovich merged commit 57780bc into apache:main Jan 20, 2026
209 of 210 checks passed
@mbutrovich mbutrovich deleted the more_more_iceberg_file_stream branch January 20, 2026 17:08
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants