Skip to content

fix: report native shuffle read metrics - #5554

Merged
comphead merged 5 commits into
apache:mainfrom
peterxcli:fix/native-shuffle-read-metrics
Sep 5, 2026
Merged

fix: report native shuffle read metrics#5554
comphead merged 5 commits into
apache:mainfrom
peterxcli:fix/native-shuffle-read-metrics

Conversation

@peterxcli

@peterxcli peterxcli commented Aug 29, 2026

Copy link
Copy Markdown
Member

Which issue does this PR close?

Part of #3996.

Rationale for this change

The direct native shuffle-read path bypasses Spark's normal decode path, so its records-read metric was not updated and temporary shuffle-read metrics were not merged into task metrics. This left the Spark Stage and SQL UIs with missing or zero native shuffle-read values.

What changes are included in this PR?

  • Pass the existing SQL shuffle-read metrics callback through CometShuffleBlockIterator.
  • Update Spark's records-read metric after each successfully decoded native shuffle batch.
  • Merge temporary shuffle-read metrics when a direct native shuffle task completes.
  • Extend task-metrics regressions to require the direct native ShuffleScan path, assert SQL/Stages UI aggregates, and preserve metrics on failed attempts.

How are these changes tested?

  • cargo build
  • cargo fmt --all -- --check
  • ./mvnw test -Dtest=none -Dsuites='org.apache.spark.sql.comet.CometTaskMetricsSuite native shuffle read' -Dscalastyle.skip=true (2 tests)
  • verified with a built Comet JAR on a fresh Spark 4.1.2 standalone cluster with two workers:
    • executor logs confirmed ShuffleScanExec
    • the Stage UI showed Shuffle Read Size / Records: 2004.6 KiB / 500000
    • the SQL UI showed 500,000 records, 2004.6 KiB read, and 32 local blocks

before: (shuffle read didn't appear)
image
after:

image image image

@comphead

Copy link
Copy Markdown
Contributor

I'm on it today, thanks @peterxcli

@comphead comphead left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks @peterxcli would you mind to attach a screenshot on what is changed? SparkUI shows currently records from shuffle read stages, just wondering what part of metrics is addressed

@peterxcli

Copy link
Copy Markdown
Member Author

@comphead updated the screenshot to show the parquet scan result in ui against before/after patch, please take another look, thanks!

@peterxcli
peterxcli requested a review from comphead September 4, 2026 06:37
@comphead

comphead commented Sep 4, 2026

Copy link
Copy Markdown
Contributor

Thanks @peterxcli for the test, I believe it might have sense to compare against Spark metrics. The same way is done for the input scan metrics.

@peterxcli

Copy link
Copy Markdown
Member Author

@comphead
pure spark:

image image image

looks like they have different shuffle read byte but I think it's because Spark uses row/serializer shuffle data; Comet uses compressed Arrow IPC, so identical bytes are neither expected nor desirable. Spark itself derives this counter from each fetched buffer’s physical size (Spark source)

@comphead

comphead commented Sep 4, 2026

Copy link
Copy Markdown
Contributor

rows should be the same so we can check it with Spark metrics, bytes can be checked it is the same ballpark. Please check input scan metrics test, the approach was adopted there

@peterxcli

Copy link
Copy Markdown
Member Author

@comphead thanks for the direction, added test to check # of rows

@comphead comphead left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks @peterxcli
CI pending

@comphead
comphead merged commit a88288b into apache:main Sep 5, 2026
198 of 201 checks passed
@peterxcli
peterxcli deleted the fix/native-shuffle-read-metrics branch September 5, 2026 18:31
@peterxcli peterxcli mentioned this pull request Sep 5, 2026
6 tasks
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