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

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
}

Leave a Comment