JkSelf commented on a change in pull request #28175:
[SPARK-31253][SQL][FOLLOW-UP] Improve the partition data size metrics in
CustomShuffleReaderExec
URL: https://github.com/apache/spark/pull/28175#discussion_r409221388
##########
File path:
sql/core/src/main/scala/org/apache/spark/sql/execution/adaptive/CustomShuffleReaderExec.scala
##########
@@ -128,6 +106,33 @@ case class CustomShuffleReaderExec private(
Map("numSkewedPartitions" -> metrics)
}
+ private def sendPartitionDataSizeMetrics(executionId: String): Unit = {
+ val mapStats = shuffleStage.get.mapStats
+ val partitionMetrics = metrics("partitionDataSize")
+
+ if (mapStats.isEmpty) {
+ partitionMetrics.set(0)
+ SQLMetrics.postDriverMetricUpdates(sparkContext, executionId,
Seq(partitionMetrics))
+ } else {
+ val sizes = ArrayBuffer[Long]()
+ partitionSpecs.foreach {
+ case CoalescedPartitionSpec(startReducerIndex, endReducerIndex) =>
+ sizes += startReducerIndex.until(endReducerIndex).map(
+ mapStats.get.bytesByPartitionId(_)).sum
+ case p: PartialReducerPartitionSpec =>
+ sizes += p.dataSize
+ case p => throw new IllegalStateException("unexpected " + p)
+ }
+
+ val id = partitionMetrics.id
+ val accumUpdates = sizes.map(value => (id, value))
+ SQLMetrics.postDriverMetricsUpdatedByValue(sparkContext, executionId,
accumUpdates)
Review comment:
make sense. And already updated.
----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
For queries about this service, please contact Infrastructure at:
[email protected]
With regards,
Apache Git Services
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]