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:

  1. Per-batch schema adapter allocation: Created SparkParquetOptions, SparkSchemaAdapterFactory, and schema adapters for every single batch via .and_then() combinator
  2. 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?

  • Cache schema adapters and Parquet options
  • Remove IcebergFileStream and pass all FileScanTasks directly to iceberg-rust. I tried this in the past but I can't remember why I abandoned it. Let's try again.

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 59.54%. Comparing base (f09f8af) to head (fe72369).
⚠️ Report is 830 commits behind head on main.

Additional details and impacted files
@@             Coverage Diff              @@
##               main    #3051      +/-   ##
============================================
+ Coverage     56.12%   59.54%   +3.42%     
- Complexity      976     1379     +403     
============================================
  Files           119      167      +48     
  Lines         11743    15485    +3742     
  Branches       2251     2573     +322     
============================================
+ Hits           6591     9221    +2630     
- Misses         4012     4966     +954     
- Partials       1140     1298     +158     

☔ 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
Copy link
Contributor Author

mbutrovich commented Jan 7, 2026

The remaining failures have to do with ordering issues on queries that don't have an ORDER BY. iceberg-rust does a flatten_unordered on the scan tasks, so you can get different ordering on scans than what Iceberg Java planned. The resulting behavior is ultimately correct since SELECT results without an ORDER BY are non-deterministic, but I'll wait to see performance improvements before we continue down this path.

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.

2 participants