What do the numbers on the progress bar mean in spark-shell?

前端 未结 2 527
清酒与你
清酒与你 2020-12-04 12:08

In my spark-shell, what do entries like the below mean when I execute a function ?

[Stage7:===========>                              (14174 + 5) / 62500         


        
2条回答
  •  既然无缘
    2020-12-04 12:16

    What you get is a Console Progress Bar, [Stage 7: shows the stage you are in now, and (14174 + 5) / 62500] is (numCompletedTasks + numActiveTasks) / totalNumOfTasksInThisStage]. The progress bar shows numCompletedTasks / totalNumOfTasksInThisStage.

    It will be shown when both spark.ui.showConsoleProgress is true (by default) and log level in conf/log4j.properties is ERROR or WARN (!log.isInfoEnabled is true).

    Let's see the code in ConsoleProgressBar.scala that shows it out:

    private def show(now: Long, stages: Seq[SparkStageInfo]) {
      val width = TerminalWidth / stages.size
      val bar = stages.map { s =>
        val total = s.numTasks()
        val header = s"[Stage ${s.stageId()}:"
        val tailer = s"(${s.numCompletedTasks()} + ${s.numActiveTasks()}) / $total]"
        val w = width - header.length - tailer.length
        val bar = if (w > 0) {
          val percent = w * s.numCompletedTasks() / total
          (0 until w).map { i =>
            if (i < percent) "=" else if (i == percent) ">" else " "
          }.mkString("")
        } else {
        ""
        }
        header + bar + tailer
      }.mkString("")
    
      // only refresh if it's changed of after 1 minute (or the ssh connection will be closed
      // after idle some time)
      if (bar != lastProgressBar || now - lastUpdateTime > 60 * 1000L) {
        System.err.print(CR + bar)
        lastUpdateTime = now
      }
      lastProgressBar = bar
    }
    

提交回复
热议问题