-
Notifications
You must be signed in to change notification settings - Fork 29.1k
[SPARK-31271][UI] fix web ui for driver side SQL metrics #28037
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
Closed
Closed
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -116,26 +116,23 @@ object SQLMetrics { | |
| // data size total (min, med, max): | ||
| // 100GB (100MB, 1GB, 10GB) | ||
| val acc = new SQLMetric(SIZE_METRIC, -1) | ||
| acc.register(sc, name = Some(s"$name total (min, med, max (stageId: taskId))"), | ||
| countFailedValues = false) | ||
| acc.register(sc, name = Some(name), countFailedValues = false) | ||
| acc | ||
| } | ||
|
|
||
| def createTimingMetric(sc: SparkContext, name: String): SQLMetric = { | ||
| // The final result of this metric in physical operator UI may looks like: | ||
| // duration(min, med, max): | ||
| // duration total (min, med, max): | ||
| // 5s (800ms, 1s, 2s) | ||
| val acc = new SQLMetric(TIMING_METRIC, -1) | ||
| acc.register(sc, name = Some(s"$name total (min, med, max (stageId: taskId))"), | ||
| countFailedValues = false) | ||
| acc.register(sc, name = Some(name), countFailedValues = false) | ||
| acc | ||
| } | ||
|
|
||
| def createNanoTimingMetric(sc: SparkContext, name: String): SQLMetric = { | ||
| // Same with createTimingMetric, just normalize the unit of time to millisecond. | ||
| val acc = new SQLMetric(NS_TIMING_METRIC, -1) | ||
| acc.register(sc, name = Some(s"$name total (min, med, max (stageId: taskId))"), | ||
| countFailedValues = false) | ||
| acc.register(sc, name = Some(name), countFailedValues = false) | ||
| acc | ||
| } | ||
|
|
||
|
|
@@ -150,8 +147,7 @@ object SQLMetrics { | |
| // probe avg (min, med, max): | ||
| // (1.2, 2.2, 6.3) | ||
| val acc = new SQLMetric(AVERAGE_METRIC) | ||
| acc.register(sc, name = Some(s"$name (min, med, max (stageId: taskId))"), | ||
| countFailedValues = false) | ||
| acc.register(sc, name = Some(name), countFailedValues = false) | ||
| acc | ||
| } | ||
|
|
||
|
|
@@ -164,13 +160,15 @@ object SQLMetrics { | |
| metricsType != SUM_METRIC | ||
| } | ||
|
|
||
| private val METRICS_NAME_SUFFIX = "(min, med, max (stageId: taskId))" | ||
|
|
||
| /** | ||
| * A function that defines how we aggregate the final accumulator results among all tasks, | ||
| * and represent it in string for a SQL physical operator. | ||
| */ | ||
| def stringValue(metricsType: String, values: Array[Long], maxMetrics: Array[Long]): String = { | ||
| // stringMetric = "(driver)" OR (stage ${stageId}.${attemptId}: task $taskId) | ||
| val stringMetric = if (maxMetrics.isEmpty) { | ||
| // taskInfo = "(driver)" OR (stage ${stageId}.${attemptId}: task $taskId) | ||
| val taskInfo = if (maxMetrics.isEmpty) { | ||
| "(driver)" | ||
| } else { | ||
| s"(stage ${maxMetrics(1)}.${maxMetrics(2)}: task ${maxMetrics(3)})" | ||
|
|
@@ -180,18 +178,20 @@ object SQLMetrics { | |
| numberFormat.format(values.sum) | ||
| } else if (metricsType == AVERAGE_METRIC) { | ||
| val validValues = values.filter(_ > 0) | ||
| val Seq(min, med, max) = { | ||
| val metric = if (validValues.isEmpty) { | ||
| val zeros = Seq.fill(3)(0L) | ||
| zeros.map(v => toNumberFormat(v)) | ||
| } else { | ||
| // When there are only 1 metrics value (or None), no need to display max/min/median. This is | ||
| // common for driver-side SQL metrics. | ||
| if (validValues.length <= 1) { | ||
| toNumberFormat(validValues.headOption.getOrElse(0)) | ||
| } else { | ||
| val Seq(min, med, max) = { | ||
| Arrays.sort(validValues) | ||
| Seq(toNumberFormat(validValues(0)), toNumberFormat(validValues(validValues.length / 2)), | ||
| s"${toNumberFormat(validValues(validValues.length - 1))} $stringMetric") | ||
| Seq( | ||
| toNumberFormat(validValues(0)), | ||
| toNumberFormat(validValues(validValues.length / 2)), | ||
| toNumberFormat(validValues(validValues.length - 1))) | ||
| } | ||
| metric | ||
| s"$METRICS_NAME_SUFFIX:\n($min, $med, $max $taskInfo)" | ||
| } | ||
| s"\n($min, $med, $max)" | ||
| } else { | ||
| val strFormat: Long => String = if (metricsType == SIZE_METRIC) { | ||
| Utils.bytesToString | ||
|
|
@@ -204,19 +204,21 @@ object SQLMetrics { | |
| } | ||
|
|
||
| val validValues = values.filter(_ >= 0) | ||
| val Seq(sum, min, med, max) = { | ||
| val metric = if (validValues.isEmpty) { | ||
| val zeros = Seq.fill(4)(0L) | ||
| zeros.map(v => strFormat(v)) | ||
| } else { | ||
| // When there are only 1 metrics value (or None), no need to display max/min/median. This is | ||
| // common for driver-side SQL metrics. | ||
| if (validValues.length <= 1) { | ||
| strFormat(validValues.headOption.getOrElse(0)) | ||
dongjoon-hyun marked this conversation as resolved.
Show resolved
Hide resolved
|
||
| } else { | ||
| val Seq(sum, min, med, max) = { | ||
| Arrays.sort(validValues) | ||
| Seq(strFormat(validValues.sum), strFormat(validValues(0)), | ||
| Seq( | ||
| strFormat(validValues.sum), | ||
| strFormat(validValues(0)), | ||
| strFormat(validValues(validValues.length / 2)), | ||
| s"${strFormat(validValues(validValues.length - 1))} $stringMetric") | ||
| strFormat(validValues(validValues.length - 1))) | ||
| } | ||
| metric | ||
| s"total $METRICS_NAME_SUFFIX\n$sum ($min, $med, $max $taskInfo)" | ||
| } | ||
| s"\n$sum ($min, $med, $max)" | ||
|
Member
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. Just a question: In this case, it seems that we didn't have
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. |
||
| } | ||
| } | ||
|
|
||
|
|
||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.