cloud-fan commented on a change in pull request #26516: [SPARK-29893] improve
the local shuffle reader performance by changing the reading task number from 1
to multi.
URL: https://github.com/apache/spark/pull/26516#discussion_r347770569
##########
File path:
sql/core/src/main/scala/org/apache/spark/sql/execution/adaptive/OptimizeLocalShuffleReader.scala
##########
@@ -77,26 +76,40 @@ case class OptimizeLocalShuffleReader(conf: SQLConf)
extends Rule[SparkPlan] {
}.length
}
// Check whether additional shuffle introduced. If introduced, revert the
local reader.
- val numExchangeBefore = numExchanges(EnsureRequirements(conf).apply(plan))
- val numExchangeAfter =
numExchanges(EnsureRequirements(conf).apply(withProbeSideLocalReader))
- val optimizedPlan = if (numExchangeAfter > numExchangeBefore) {
- logDebug("OptimizeLocalShuffleReader rule is not applied in the probe
side due" +
+ if (numExchanges(EnsureRequirements(conf).apply(optimizedPlan)) > 0) {
+ logDebug("OptimizeLocalShuffleReader rule is not applied due" +
" to additional shuffles will be introduced.")
plan
} else {
- withProbeSideLocalReader
+ optimizedPlan
}
- // Add the local reader in build side and and do not need to check whether
- // additional shuffle introduced.
- optimizedPlan.transformDown {
- case join @ BroadcastJoinWithShuffleLeft(shuffleStage, BuildLeft) =>
- val localReader = LocalShuffleReaderExec(shuffleStage)
- join.asInstanceOf[BroadcastHashJoinExec].copy(left = localReader)
- case join @ BroadcastJoinWithShuffleRight(shuffleStage, BuildRight) =>
- val localReader = LocalShuffleReaderExec(shuffleStage)
- join.asInstanceOf[BroadcastHashJoinExec].copy(right = localReader)
+ }
+}
+
+object OptimizeLocalShuffleReader {
+
+ object BroadcastJoinWithShuffleLeft {
+ def unapply(plan: SparkPlan): Option[(SparkPlan, BuildSide)] = plan match {
+ case join: BroadcastHashJoinExec if OptimizeLocalShuffleReader.
+ canUseLocalShuffleReader(join.left) =>
+ Some((join.left, join.buildSide))
+ case _ => None
}
}
+
+ object BroadcastJoinWithShuffleRight {
+ def unapply(plan: SparkPlan): Option[(SparkPlan, BuildSide)] = plan match {
+ case join: BroadcastHashJoinExec if OptimizeLocalShuffleReader.
Review comment:
ditto
----------------------------------------------------------------
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]