-
Notifications
You must be signed in to change notification settings - Fork 28.6k
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 all 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,46 @@ | ||
/* | ||
* 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) { | ||
|
||
override def equals(other: Any): Boolean = other match { | ||
case acc: AccumulableInfo => | ||
this.id == acc.id && this.name == acc.name && | ||
this.update == acc.update && this.value == acc.value | ||
case _ => false | ||
} | ||
} | ||
|
||
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 |
---|---|---|
|
@@ -883,8 +883,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 | ||
|
@@ -906,12 +912,26 @@ class DAGScheduler( | |
if (event.accumUpdates != null) { | ||
try { | ||
Accumulators.add(event.accumUpdates) | ||
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 | ||
if (acc.name.isDefined && partialValue != acc.zero) { | ||
val name = acc.name.get | ||
val stringPartialValue = Accumulators.stringifyPartialValue(partialValue) | ||
val stringValue = Accumulators.stringifyValue(acc.value) | ||
stage.info.accumulables(id) = AccumulableInfo(id, name, stringValue) | ||
event.taskInfo.accumulables += | ||
AccumulableInfo(id, name, Some(stringPartialValue), stringValue) | ||
} | ||
} | ||
} catch { | ||
// If we see an exception during accumulator update, just log the error and move on. | ||
case e: Exception => | ||
logError(s"Failed to update accumulators for $task", e) | ||
} | ||
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. 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)) | ||
stage.pendingTasks -= task | ||
task match { | ||
case rt: ResultTask[_, _] => | ||
|
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?