关注 spark技术分享,
撸spark源码 玩spark最佳实践

ConsoleProgressBar

ConsoleProgressBar

ConsoleProgressBar shows the progress of active stages to standard error, i.e. stderr. It uses SparkStatusTracker to poll the status of stages periodically and print out active stages with more than one task. It keeps overwriting itself to hold in one line for at most 3 first concurrent stages at a time.

The progress includes the stage id, the number of completed, active, and total tasks.

Tip
ConsoleProgressBar may be useful when you ssh to workers and want to see the progress of active stages.

ConsoleProgressBar is created when SparkContext starts with spark.ui.showConsoleProgress enabled and the logging level of org.apache.spark.SparkContext logger as WARN or higher (i.e. less messages are printed out and so there is a “space” for ConsoleProgressBar).

To print the progress nicely ConsoleProgressBar uses COLUMNS environment variable to know the width of the terminal. It assumes 80 columns.

The progress bar prints out the status after a stage has ran at least 500 milliseconds every spark.ui.consoleProgress.update.interval milliseconds.

Note
The initial delay of 500 milliseconds before ConsoleProgressBar show the progress is not configurable.

See the progress bar in Spark shell with the following:

  1. Make sure spark.ui.showConsoleProgress is true. It is by default.

  2. Disable (OFF) the root logger (that includes Spark’s logger)

  3. Make sure org.apache.spark.SparkContext logger is at least WARN.

  4. Run a job with 4 tasks with 500ms initial sleep and 200ms sleep chunks to see the progress bar.

Tip
Watch the short video that show ConsoleProgressBar in action.

You may want to use the following example to see the progress bar in full glory – all 3 concurrent stages in console (borrowed from a comment to [SPARK-4017] show progress bar in console #3029):

Creating ConsoleProgressBar Instance

ConsoleProgressBar requires a SparkContext.

When being created, ConsoleProgressBar reads spark.ui.consoleProgress.update.interval configuration property to set up the update interval and COLUMNS environment variable for the terminal width (or assumes 80 columns).

ConsoleProgressBar starts the internal timer refresh progress that does refresh and shows progress.

Note
ConsoleProgressBar is created when SparkContext starts, spark.ui.showConsoleProgress configuration property is enabled, and the logging level of org.apache.spark.SparkContext logger is WARN or higher (i.e. less messages are printed out and so there is a “space” for ConsoleProgressBar).
Note
Once created, ConsoleProgressBar is available internally as _progressBar.

finishAll Method

Caution
FIXME

stop Method

stop cancels (stops) the internal timer.

Note
stop is executed when SparkContext stops.

refresh Internal Method

refresh…​FIXME

Note
refresh is used when…​FIXME
赞(0) 打赏
未经允许不得转载:spark技术分享 » ConsoleProgressBar
分享到: 更多 (0)

关注公众号:spark技术分享

联系我们联系我们

觉得文章有用就打赏一下文章作者

支付宝扫一扫打赏

微信扫一扫打赏