Github user maropu commented on a diff in the pull request:

    https://github.com/apache/spark/pull/11720#discussion_r57547815
  
    --- Diff: core/src/main/scala/org/apache/spark/scheduler/DAGScheduler.scala 
---
    @@ -403,25 +403,37 @@ class DAGScheduler(
         parents.toList
       }
     
    -  /** Find ancestor shuffle dependencies that are not registered in 
shuffleToMapStage yet */
    -  private def getAncestorShuffleDependencies(rdd: RDD[_]): 
Stack[ShuffleDependency[_, _, _]] = {
    -    val parents = new Stack[ShuffleDependency[_, _, _]]
    +  /**
    +   * Find ancestor shuffle dependencies that are not registered in 
shuffleToMapStage yet,
    +   * in topological order to ensure building ancestor stages first.
    +   */
    +  private def getAncestorShuffleDependencies(rdd: RDD[_]): 
Seq[ShuffleDependency[_, _, _]] = {
    +    val parents = new ArrayBuffer[ShuffleDependency[_, _, _]]
         val visited = new HashSet[RDD[_]]
         // We are manually maintaining a stack here to prevent 
StackOverflowError
         // caused by recursively visiting
         val waitingForVisit = new Stack[RDD[_]]
         def visit(r: RDD[_]) {
           if (!visited(r)) {
    -        visited += r
    -        for (dep <- r.dependencies) {
    -          dep match {
    -            case shufDep: ShuffleDependency[_, _, _] =>
    -              if (!shuffleToMapStage.contains(shufDep.shuffleId)) {
    -                parents.push(shufDep)
    -              }
    -            case _ =>
    +        val deps = r.dependencies.filter {
    +          case shufDep: ShuffleDependency[_, _, _] =>
    +            !shuffleToMapStage.contains(shufDep.shuffleId)
    +          case _ => true
    +        }
    +        if (deps.forall(dep => visited(dep.rdd))) {
    +          visited += r
    +          for (dep <- deps) {
    +            dep match {
    +              case shufDep: ShuffleDependency[_, _, _] =>
    +                parents += shufDep
    +              case _ =>
    +            }
    +          }
    +        } else {
    +          waitingForVisit.push(r)
    --- End diff --
    
    This pr adds extra push&pop against the original codes.
    To mitigate this overhead, how about poping a rdd in case of all the 
dependent rdds visited?


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at [email protected] or file a JIRA ticket
with INFRA.
---

---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to