-
Notifications
You must be signed in to change notification settings - Fork 29k
SPARK-2380: Support displaying accumulator values in the web UI #1309
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from 12 commits
0b72660
ad85076
7a63abc
9f18bad
5d8b156
64d405f
8407308
be97261
e95bf69
0ec4ac7
0bb0e33
9860c55
1da15e3
c5ace9e
9a9ba3c
c991b1b
cc43f68
93fbe0f
8815308
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,38 @@ | ||
| /* | ||
| * Licensed to the Apache Software Foundation (ASF) under one or more | ||
| * contributor license agreements. See the NOTICE file distributed with | ||
| * this work for additional information regarding copyright ownership. | ||
| * The ASF licenses this file to You under the Apache License, Version 2.0 | ||
| * (the "License"); you may not use this file except in compliance with | ||
| * the License. You may obtain a copy of the License at | ||
| * | ||
| * http://www.apache.org/licenses/LICENSE-2.0 | ||
| * | ||
| * Unless required by applicable law or agreed to in writing, software | ||
| * distributed under the License is distributed on an "AS IS" BASIS, | ||
| * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
| * See the License for the specific language governing permissions and | ||
| * limitations under the License. | ||
| */ | ||
|
|
||
| package org.apache.spark.scheduler | ||
|
|
||
| import org.apache.spark.annotation.DeveloperApi | ||
|
|
||
| /** | ||
| * :: DeveloperApi :: | ||
| * Information about an [[org.apache.spark.Accumulable]] modified during a task or stage. | ||
| */ | ||
| @DeveloperApi | ||
| class AccumulableInfo ( | ||
| val id: Long, | ||
| val name: String, | ||
| val update: Option[String], // represents a partial update within a task | ||
| val value: String) { } | ||
|
|
||
| object AccumulableInfo { | ||
| def apply(id: Long, name: String, update: Option[String], value: String) = | ||
| new AccumulableInfo(id, name, update, value) | ||
|
|
||
| def apply(id: Long, name: String, value: String) = new AccumulableInfo(id, name, None, value) | ||
| } |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -791,8 +791,14 @@ class DAGScheduler( | |
| val task = event.task | ||
| val stageId = task.stageId | ||
| val taskType = Utils.getFormattedClassName(task) | ||
| listenerBus.post(SparkListenerTaskEnd(stageId, taskType, event.reason, event.taskInfo, | ||
| event.taskMetrics)) | ||
|
|
||
| // The success case is dealt with separately below, since we need to compute accumulator | ||
| // updates before posting. | ||
| if (event.reason != Success) { | ||
| listenerBus.post(SparkListenerTaskEnd(stageId, taskType, event.reason, event.taskInfo, | ||
| event.taskMetrics)) | ||
| } | ||
|
|
||
| if (!stageIdToStage.contains(task.stageId)) { | ||
| // Skip all the actions if the stage has been cancelled. | ||
| return | ||
|
|
@@ -809,12 +815,27 @@ class DAGScheduler( | |
| listenerBus.post(SparkListenerStageCompleted(stageToInfos(stage))) | ||
| runningStages -= stage | ||
| } | ||
|
|
||
| event.reason match { | ||
| case Success => | ||
| logInfo("Completed " + task) | ||
| if (event.accumUpdates != null) { | ||
| // TODO: fail the stage if the accumulator update fails... | ||
| Accumulators.add(event.accumUpdates) // TODO: do this only if task wasn't resubmitted | ||
| event.accumUpdates.foreach { case (id, partialValue) => | ||
| val acc = Accumulators.originals(id).asInstanceOf[Accumulable[Any, Any]] | ||
| // To avoid UI cruft, ignore cases where value wasn't updated | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Do you think this will make things hard to debug -- e.g., if someone's accumulator doesn't show up in the UI and they don't realize it's because the value wasn't updated as opposed to because they didn't set the show-in-ui variable correctly? |
||
| if (acc.name.isDefined && partialValue != acc.zero) { | ||
| val name = acc.name.get | ||
| val stringPartialValue = "%s".format(partialValue) | ||
| val stringValue = "%s".format(acc.value) | ||
| stageToInfos(stage).accumulables(id) = AccumulableInfo(id, name, stringValue) | ||
| event.taskInfo.accumulables += | ||
| AccumulableInfo(id, name, Some(stringPartialValue), stringValue) | ||
| } | ||
| } | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Can this be moved to a method on the Accumulators companion object or something? These details about AccumulableInfo, prettyPartialValues, etc. aren't things that need to appear in the DAGScheduler.
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. @markhamstra yeah we can move these elsewhere, good idea. |
||
| listenerBus.post(SparkListenerTaskEnd(stageId, taskType, event.reason, event.taskInfo, | ||
| event.taskMetrics)) | ||
| } | ||
| pendingTasks(stage) -= task | ||
| task match { | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -17,6 +17,8 @@ | |
|
|
||
| package org.apache.spark.scheduler | ||
|
|
||
| import scala.collection.mutable.ListBuffer | ||
|
|
||
| import org.apache.spark.annotation.DeveloperApi | ||
|
|
||
| /** | ||
|
|
@@ -41,6 +43,13 @@ class TaskInfo( | |
| */ | ||
| var gettingResultTime: Long = 0 | ||
|
|
||
| /** | ||
| * Intermediate updates to accumulables during this task. Note that it is valid for the same | ||
| * accumulable to be updated multiple times in a single task or for two accumulables with the | ||
| * same name but different ID's to exist in a task. | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. super nit: no apostrophe in IDs |
||
| */ | ||
| val accumulables = ListBuffer[AccumulableInfo]() | ||
|
|
||
| /** | ||
| * The time when the task has completed successfully (including the time to remotely fetch | ||
| * results, if necessary). | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should there be (maybe you were planning to add it later since I know this is still WIP) a similar new accumulable method?