apache / apache/iceberg

Spark: No metric for time spent reading data in a scan task

Open
#17,563 0 comments 0 reactions 0 assignees View on GitHub
Dominant language
Java
Stars
9.2k
Forks
3.5k
Avg merge
2d 11h
Merged PRs (30d)
132

Description

### Feature Request / Improvement

Iceberg publishes scan bytes and file/manifest counts per task, but the only timer in the metrics system is `totalPlanningDuration`, which is started in `SnapshotScan` around driver-side planning. `CommitMetrics.totalDuration` covers commit, not data movement.

The result is that scan throughput cannot be derived from Iceberg metrics alone. Bytes are available, elapsed read time is not, and task duration is a poor proxy because it also includes everything the query does after the scan (in one workload we looked at, shuffle write was ~94% of task runtime).

This matters when the question is about the read path itself, for example comparing the same table read from two clusters to see whether one is crossing regions, or telling a slow scan apart from a slow downstream operator.

For reference, Spark exposes `scanTime` on `FileSourceScanExec`, but it is defined only for that operator, so a DSv2 `BatchScan` gets nothing. `lance-spark` publishes `batchLoadTimeNs` for the equivalent read path.

Proposal: add a per-task scan-duration metric alongside the existing counters, aggregated to the stage in the same way as `totalPlanningDuration`. Nanoseconds rather than milliseconds, since a single split can be read in well under a millisecond.

PR: https://github.com/apache/iceberg/pull/17562

### Query engine

Spark

### Willingness to contribute

- [x] I can contribute this improvement/feature independently
- [ ] I would be willing to contribute this improvement/feature with guidance from the Iceberg community
- [ ] I cannot contribute this improvement/feature at this time

Contributor guide

Open the contributing guide

Research direction

Start by tracing SnapshotScan and the existing totalPlanningDuration metric, then compare Spark's FileSourceScanExec scanTime with the DSv2 BatchScan path. Done means a per-task scan-duration value in nanoseconds is added alongside the existing counters and aggregated to the stage; PR #17562 is already linked.

Written by the indexing model from the issue text.

Assessment

Tech stack
java, spark
Domain
data-engineering, observability-sre
Issue type
Feature
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
25/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.