Github user pwendell commented on a diff in the pull request:
https://github.com/apache/spark/pull/5843#discussion_r30203196
--- Diff: core/src/main/scala/org/apache/spark/ui/jobs/StagePage.scala ---
@@ -460,25 +493,213 @@ private[ui] class StagePage(parent: StagesTab)
extends WebUIPage("stage") {
dagViz ++
maybeExpandDagViz ++
showAdditionalMetrics ++
+ makeTimeline(stageData.taskData.values.toSeq, currentTime) ++
<h4>Summary Metrics for {numCompleted} Completed Tasks</h4> ++
<div>{summaryTable.getOrElse("No tasks have reported metrics
yet.")}</div> ++
<h4>Aggregated Metrics by Executor</h4> ++ executorTable.toNodeSeq
++
maybeAccumulableTable ++
<h4>Tasks</h4> ++ taskTable
-
UIUtils.headerSparkPage(stageHeader, content, parent,
showVisualization = true)
}
}
+ def makeTimeline(tasks: Seq[TaskUIData], currentTime: Long): Seq[Node] =
{
+ val executorsSet = new HashSet[(String, String)]
+ var minLaunchTime = Long.MaxValue
+ var maxFinishTime = Long.MinValue
+ var numEffectiveTasks = 0
+
+ val executorsArrayStr = tasks.filter { taskUIData =>
+ val taskInfo = taskUIData.taskInfo
+ taskInfo.successful || taskInfo.running || taskInfo.failed
+ }.sortWith { (uiDataL, uiDataR) =>
+ val taskInfoL = uiDataL.taskInfo
+ val launchTimeL = taskInfoL.launchTime
+
+ val taskInfoR = uiDataR.taskInfo
+ val launchTimeR = taskInfoR.launchTime
+
+ launchTimeL > launchTimeR
+ }.take(MAX_TIMELINE_TASKS).map { taskUIData =>
+ val taskInfo = taskUIData.taskInfo
+ val executorId = taskInfo.executorId
+ val host = taskInfo.host
+ executorsSet += ((executorId, host))
+
+ val taskId = taskInfo.taskId
+ val taskIdWithIndexAndAttempt = s"Task ${taskId}(${taskInfo.id})"
+
+ val isSucceeded = taskInfo.successful
+ val isFailed = taskInfo.failed
+ val isRunning = taskInfo.running
+ val classNameByStatus = {
+ if (isSucceeded) {
+ "succeeded"
+ } else if (isFailed) {
+ "failed"
+ } else if (isRunning) {
+ "running"
+ }
+ }
+
+ val launchTime = taskInfo.launchTime
+ val finishTime = if (!isRunning) taskInfo.finishTime else currentTime
+ val totalExecutionTime = finishTime - launchTime
+ minLaunchTime = launchTime.min(minLaunchTime)
+ maxFinishTime = launchTime.max(maxFinishTime)
+ numEffectiveTasks += 1
+
+ val metricsOpt = taskUIData.taskMetrics
+ val shuffleReadTime =
+
metricsOpt.flatMap(_.shuffleReadMetrics.map(_.fetchWaitTime)).getOrElse(0L)
+ val shuffleReadTimeProportion =
+ (shuffleReadTime.toDouble / totalExecutionTime * 100).toLong
+ val shuffleWriteTime =
+ (metricsOpt.flatMap(_.shuffleWriteMetrics
+ .map(_.shuffleWriteTime)).getOrElse(0L) / 1e6).toLong
+ val shuffleWriteTimeProportion =
+ (shuffleWriteTime.toDouble / totalExecutionTime * 100).toLong
+ val executorComputingTime =
metricsOpt.map(_.executorRunTime).getOrElse(0L) -
+ shuffleReadTime - shuffleWriteTime
+ val executorComputingTimeProportion =
+ (executorComputingTime.toDouble / totalExecutionTime * 100).toLong
+ val serializationTime =
metricsOpt.map(_.resultSerializationTime).getOrElse(0L)
+ val serializationTimeProportion =
+ (serializationTime.toDouble / totalExecutionTime * 100).toLong
+ val deserializationTime =
metricsOpt.map(_.executorDeserializeTime).getOrElse(0L)
+ val deserializationTimeProportion =
+ (deserializationTime.toDouble / totalExecutionTime * 100).toLong
+ val gettingResultTime = getGettingResultTime(taskUIData.taskInfo)
+ val gettingResultTimeProportion =
+ (gettingResultTime.toDouble / totalExecutionTime * 100).toLong
+ val schedulerDelay = totalExecutionTime -
+ (executorComputingTime + shuffleReadTime + shuffleWriteTime +
+ serializationTime + deserializationTime + gettingResultTime)
+ val schedulerDelayProportion =
+ 100 - executorComputingTimeProportion - shuffleReadTimeProportion -
+ shuffleWriteTimeProportion - serializationTimeProportion -
+ deserializationTimeProportion - gettingResultTimeProportion
+
+ val schedulerDelayProportionPos = 0
+ val deserializationTimeProportionPos =
+ schedulerDelayProportionPos + schedulerDelayProportion
+ val shuffleReadTimeProportionPos =
+ deserializationTimeProportionPos + deserializationTimeProportion
+ val executorRuntimeProportionPos =
+ shuffleReadTimeProportionPos + shuffleReadTimeProportion
+ val shuffleWriteTimeProportionPos =
+ executorRuntimeProportionPos + executorComputingTimeProportion
+ val serializationTimeProportionPos =
+ shuffleWriteTimeProportionPos + shuffleWriteTimeProportion
+ val gettingResultTimeProportionPos =
+ serializationTimeProportionPos + serializationTimeProportion
+
+ val timelineObject =
+ s"""
+ |{
+ | 'className': 'task task-assignment-timeline-object
${classNameByStatus}',
+ | 'group': '${executorId}',
+ | 'content': '<div class="task-assignment-timeline-content"' +
+ | 'data-toggle="tooltip" data-placement="top"' +
+ | 'data-html="true" data-container="body"' +
+ | 'data-title="${taskIdWithIndexAndAttempt}<br>Status:
${taskInfo.status}<br>' +
+ | 'Launch Time: ${UIUtils.formatDate(new Date(launchTime))}'
+
+ | '${
+ if (!isRunning) {
+ s"""<br>Finish Time: ${UIUtils.formatDate(new
Date(finishTime))}"""
+ } else {
+ ""
+ }
+ }' +
+ '<br>Scheduler Delay: ${schedulerDelay} ms' +
+ '<br>Task Deserialization Time:
${UIUtils.formatDuration(deserializationTime)}' +
+ '<br>Shuffle Read Time:
${UIUtils.formatDuration(shuffleReadTime)}' +
+ '<br>Executor Computing Time:
${UIUtils.formatDuration(executorComputingTime)}' +
+ '<br>Shuffle Write Time:
${UIUtils.formatDuration(shuffleWriteTime)}' +
+ '<br>Result Serialization Time:
${UIUtils.formatDuration(serializationTime)}' +
+ '<br>Getting Result Time:
${UIUtils.formatDuration(gettingResultTime)}">' +
+ | '<svg class="task-assignment-timeline-duration-bar">' +
+ | '<rect class="scheduler-delay-proportion" ' +
+ | 'x="${schedulerDelayProportionPos}%" y="0px"
height="26px"' +
+ | 'width="${schedulerDelayProportion}%""></rect>' +
+ | '<rect class="deserialization-time-proportion" '+
+ | 'x="${deserializationTimeProportionPos}%" y="0px"
height="26px"' +
+ | 'width="${deserializationTimeProportion}%"></rect>' +
+ | '<rect class="shuffle-read-time-proportion" ' +
+ | 'x="${shuffleReadTimeProportionPos}%" y="0px"
height="26px"' +
+ | 'width="${shuffleReadTimeProportion}%"></rect>' +
+ | '<rect class="executor-runtime-proportion" ' +
+ | 'x="${executorRuntimeProportionPos}%" y="0px"
height="26px"' +
+ | 'width="${executorComputingTimeProportion}%"></rect>' +
+ | '<rect class="shuffle-write-time-proportion" ' +
+ | 'x="${shuffleWriteTimeProportionPos}%" y="0px"
height="26px"' +
+ | 'width="${shuffleWriteTimeProportion}%"></rect>' +
+ | '<rect class="serialization-time-proportion" ' +
+ | 'x="${serializationTimeProportionPos}%" y="0px"
height="26px"' +
+ | 'width="${serializationTimeProportion}%"></rect>' +
+ | '<rect class="getting-result-time-proportion" ' +
+ | 'x="${gettingResultTimeProportionPos}%" y="0px"
height="26px"' +
+ | 'width="${gettingResultTimeProportion}%"></rect></svg>',
+ | 'start': new Date(${launchTime}),
+ | 'end': new Date(${finishTime})
+ |}
+ """.stripMargin
+ timelineObject
+ }.mkString("[", ",", "]")
+
+ val groupArrayStr = executorsSet.map {
+ case (executorId, host) =>
+ s"""
+ |{
+ | 'id': '${executorId}',
+ | 'content': '${executorId} / ${host}',
+ |}
+ """.stripMargin
+ }.mkString("[", ",", "]")
+
+ var maxWindowInSec = ((maxFinishTime - minLaunchTime) / 1000.0).round
+ if (maxWindowInSec <= 0) maxWindowInSec = 1
+ val tasksPerSecond = numEffectiveTasks / maxWindowInSec
+ var maxZoom = {
+ if (tasksPerSecond > 100) {
+ 1000L / (tasksPerSecond / 100)
+ }
+ else {
+ 1000 * (100 / tasksPerSecond)
+ }
+ }
+
+ if (maxZoom < 0) maxZoom = 1
+
+ <span class="expand-task-assignment-timeline">
+ <span class="expand-task-assignment-timeline-arrow
arrow-closed"></span>
+ <a>Event Timeline (Most recent
{numEffectiveTasks.min(MAX_TIMELINE_TASKS)} tasks)</a>
--- End diff --
Only say "Most recent X" if we have truncated the list. If there are less
than MAX_TIMELINE_TASKS overall, I'd just say "Event Timeline".
---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at [email protected] or file a JIRA ticket
with INFRA.
---
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]