maryannxue commented on a change in pull request #28022: [SPARK-31253][SQL] Add
metrics to AQE shuffle reader
URL: https://github.com/apache/spark/pull/28022#discussion_r398665306
##########
File path:
sql/core/src/main/scala/org/apache/spark/sql/execution/adaptive/CustomShuffleReaderExec.scala
##########
@@ -62,20 +61,113 @@ case class CustomShuffleReaderExec private(
}
}
- override def stringArgs: Iterator[Any] = Iterator(description)
+ override def stringArgs: Iterator[Any] = {
+ val desc = if (isLocalReader) {
+ "local"
+ } else {
+ if (hasCoalescedPartition && hasSkewedPartition) {
+ "coalesced and skewed"
+ } else if (hasCoalescedPartition) {
+ "coalesced"
+ } else if (hasSkewedPartition) {
+ "skewed"
+ } else {
+ ""
+ }
+ }
+ Iterator(desc)
+ }
- private var cachedShuffleRDD: RDD[InternalRow] = null
+ def hasCoalescedPartition: Boolean = {
+ partitionSpecs.exists(_.isInstanceOf[CoalescedPartitionSpec])
+ }
- override protected def doExecute(): RDD[InternalRow] = {
- if (cachedShuffleRDD == null) {
- cachedShuffleRDD = child match {
- case stage: ShuffleQueryStageExec =>
- new ShuffledRowRDD(
- stage.shuffle.shuffleDependency, stage.shuffle.readMetrics,
partitionSpecs.toArray)
- case _ =>
- throw new IllegalStateException("operating on canonicalization plan")
+ def hasSkewedPartition: Boolean = {
+ partitionSpecs.exists(_.isInstanceOf[PartialReducerPartitionSpec])
+ }
+
+ def isLocalReader: Boolean = {
+ if (partitionSpecs.exists(_.isInstanceOf[PartialMapperPartitionSpec])) {
+ assert(partitionSpecs.forall(_.isInstanceOf[PartialMapperPartitionSpec]))
+ true
+ } else {
+ false
+ }
+ }
+
+ private def shuffleStage = child match {
+ case stage: ShuffleQueryStageExec => Some(stage)
+ case _ => None
+ }
+
+ override lazy val metrics = {
+ if (shuffleStage.isDefined) {
+ val numPartitions = SQLMetrics.createMetric(sparkContext, "number of
partitions")
+ numPartitions.set(partitionSpecs.length)
+ Map("numPartitions" -> numPartitions) ++ {
+ if (isLocalReader) {
+ // We split the mapper partition evenly when creating local shuffle
reader, so no
+ // data size info is available.
+ Map.empty
+ } else {
+ val maxSize = SQLMetrics.createSizeMetric(sparkContext, "max data
size of partitions")
Review comment:
nit: max partition size, min partition size, avg partition size
----------------------------------------------------------------
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]