Spark 4.1: Add per-task scanDuration metric - #17562
Open
venkata91 wants to merge 1 commit into
Open
Conversation
venkata91
force-pushed
the
spark-task-scan-duration-metric
branch
from
August 9, 2026 02:29
02e75bf to
b88f53d
Compare
Iceberg reports scan bytes and file/manifest counts per task, but the only timer in the metrics system is totalPlanningDuration, which measures driver-side planning. There is no metric for how long a task spent actually reading data, so a scan's throughput cannot be derived from Iceberg metrics alone. Add scanDuration: wall time a task spends in BaseReader.next(), accumulated per call rather than per row so the timer costs nothing measurable relative to the read. Emitted as TaskScanDuration from BatchDataReader and RowDataReader, aggregated by ScanDuration, mirroring the existing TotalPlanningDuration pair. Values are nanoseconds: a single split can be read in well under a millisecond, so a millisecond timer would round most per-task reads to zero. ScanDuration formats the aggregate as ns/us/ms/s for the UI. Generated-by: Claude Opus 5
venkata91
force-pushed
the
spark-task-scan-duration-metric
branch
from
August 9, 2026 02:34
b88f53d to
f1a6f78
Compare
3 tasks
anoopj
reviewed
Aug 10, 2026
anoopj
left a comment
Member
There was a problem hiding this comment.
The code change looks good to me. We might be missing code coverage for the non-vectorized path (RowDataReader) because the Spark read follows the vectorized path?
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.
Summary
Closes #17563.
Iceberg reports scan bytes and file/manifest counts per task, but the only timer is
totalPlanningDuration, which covers driver-side planning. There is no metric for how long a task spent reading, so scan throughput cannot be derived from Iceberg metrics alone.Changes
Add
scanDuration: wall time a task spends inBaseReader.next(), covering split open and row/batch iteration.next()call, not per row. Spark makes the same tradeoff forscanTimeinDataSourceScanExec.finally, so a task that throws mid-scan still reports what it read.TaskScanDurationfromBatchDataReaderandRowDataReader, aggregated byScanDuration, mirroring theTotalPlanningDurationpair.Nanoseconds, not the milliseconds used by
totalPlanningDuration: a split can be read in well under a millisecond, so ms would round most per-task reads to zero. The aggregate is formatted ns/us/ms/s for the UI.Testing done
TestSparkReadMetricsassertsscanDuration > 0for V1, V2 and V3 tables. 3 tests, 0 failures.spotlessCheckandcheckstyleMainpass.Open questions
spark/v4.1. Happy to backport to 4.0 and 3.5 here or in a follow-up.next()to cover both readers. If reviewers prefer it aroundopen()only, excluding iteration, that is a small change.