feat(reader): Add read_with_metrics() for scan I/O metrics#2349
Open
mbutrovich wants to merge 8 commits intoapache:mainfrom
Open
feat(reader): Add read_with_metrics() for scan I/O metrics#2349mbutrovich wants to merge 8 commits intoapache:mainfrom
mbutrovich wants to merge 8 commits intoapache:mainfrom
Conversation
Collaborator
Author
|
@blackmwk I'm trying really hard not to add more to |
CTTY
reviewed
Apr 20, 2026
Collaborator
CTTY
left a comment
There was a problem hiding this comment.
Just took a quick pass, love the direction!
blackmwk
reviewed
Apr 21, 2026
Contributor
blackmwk
left a comment
There was a problem hiding this comment.
Thanks @mbutrovich for this pr!
Collaborator
Author
Collaborator
Author
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Which issue does this PR close?
What changes are included in this PR?
Add always-on per-scan I/O metrics to
ArrowReader.Motivation: Downstream engines need per-scan byte counts for their UIs. For example, DataFusion Comet uses this to populate
bytes_scannedon its Iceberg scan operator, which flows through to Spark UI viaTaskMetrics.inputMetrics.setBytesRead(). This must be per-scan, not global. Concurrent scans against the sameFileIOneed independent counters. The approach matches DataFusion's pattern of wrappingAsyncFileReaderwith a counting layer and is storage-backend agnostic.ArrowReader::read()now returnsScanResultScanResultwraps the record batch stream andScanMetrics. Accessors:stream(),metrics(),into_parts().fetch_add(Relaxed)per I/O request, negligible overhead.read()call, so cloned readers get independent metrics.New file:
crates/iceberg/src/arrow/scan_metrics.rsCountingFileRead<F: FileRead>: generic wrapper that increments a sharedAtomicU64on eachread().ScanMetrics: public handle exposingbytes_read().ScanResult: public struct returned byArrowReader::read().FileReadblanket impl forBox<dyn FileRead>CountingFileRead<F>to wrap the boxed reader returned byFileIO::reader().Single
open_parquet_filewith countingopen_parquet_filewrapped withCountingFileRead, sobytes_readreflects total scan I/O.build_parquet_reader(): shared internals for reader construction and metadata loading.FileScanTaskReaderstruct (refactor)process_file_scan_task's parameters into aClonestruct with aprocess(self, task)method, resolving aclippy::too_many_argumentsviolation. Struct and impl are co-located.Re-exports
ScanMetricsandScanResultre-exported fromiceberg::arrowandiceberg::scan.Are these changes tested?
test_scan_metrics_bytes_readinreader.rs: assertsbytes_read() == 0before stream consumption (the stream is lazy) andbytes_read() > 0after.test_scan_metrics_includes_delete_file_bytes: reads the same data file with and without a positional delete file and assertsbytes_readis strictly greater when deletes are present. All existing reader and scan tests pass (updated to useScanResult::stream()).