Skip to content
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

[SPARK-8702][WebUI]Avoid massive concating strings in Javascript #7082

Closed
wants to merge 1 commit into from
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
88 changes: 44 additions & 44 deletions core/src/main/scala/org/apache/spark/ui/jobs/StagePage.scala
Original file line number Diff line number Diff line change
Expand Up @@ -572,55 +572,55 @@ private[ui] class StagePage(parent: StagesTab) extends WebUIPage("stage") {
val attempt = taskInfo.attempt
val timelineObject =
s"""
{
'className': 'task task-assignment-timeline-object',
'group': '$executorId',
'content': '<div class="task-assignment-timeline-content"' +
'data-toggle="tooltip" data-placement="top"' +
'data-html="true" data-container="body"' +
'data-title="${s"Task " + index + " (attempt " + attempt + ")"}<br>' +
'Status: ${taskInfo.status}<br>' +
'Launch Time: ${UIUtils.formatDate(new Date(launchTime))}' +
'${
|{
|'className': 'task task-assignment-timeline-object',
|'group': '$executorId',
|'content': '<div class="task-assignment-timeline-content"
|data-toggle="tooltip" data-placement="top"
|data-html="true" data-container="body"
|data-title="${s"Task " + index + " (attempt " + attempt + ")"}<br>
|Status: ${taskInfo.status}<br>
|Launch Time: ${UIUtils.formatDate(new Date(launchTime))}
|${
if (!taskInfo.running) {
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)
}
"""
}
|<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.replaceAll("\n", " ")
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We don't need stripMargin right?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It's necessary. stripMargin removes the prefix "        |".

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I misunderstood the effect of "|" and stripMargin. Yes it's needed.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The \n isn't working on Windows if Git decides to check out the file using \r\n line-endings. May want to change it to [\r\n] instead.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I see. Did you see it does not work? I think, it's better to replace it with a system property line.separator?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Right. It complained ILLEGAL character and that string is still shown as multiline in developer console. I think the line.separator wouldn't work at least for my case where I'm compiling on Windows but deploying on Linux. Don't ask me why :)

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks I opened a new PR #7133 for the issue you mentioned.

timelineObject
}.mkString("[", ",", "]")

Expand Down