-
Notifications
You must be signed in to change notification settings - Fork 29.3k
[SPARK-21051][SQL] Add hash map metrics to aggregate #18258
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 3 commits
Commits
Show all changes
5 commits
Select commit
Hold shift + click to select a range
e4cfe1c
Report average hashmap probe when the config is enabled.
viirya 55cd6ad
Remove the config flag.
viirya ee3d88f
Improve code comment.
viirya 250054c
Fix typo. Remove `enablePerfMetrics` param.
viirya c7de74c
Remove unused method.
viirya 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
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -68,11 +68,11 @@ class SQLMetric(val metricType: String, initValue: Long = 0L) extends Accumulato | |
| } | ||
| } | ||
|
|
||
|
|
||
| object SQLMetrics { | ||
| private val SUM_METRIC = "sum" | ||
| private val SIZE_METRIC = "size" | ||
| private val TIMING_METRIC = "timing" | ||
| private val AVERAGE_METRIC = "average" | ||
|
|
||
| def createMetric(sc: SparkContext, name: String): SQLMetric = { | ||
| val acc = new SQLMetric(SUM_METRIC) | ||
|
|
@@ -102,6 +102,22 @@ object SQLMetrics { | |
| acc | ||
| } | ||
|
|
||
| /** | ||
| * Create a metric to report the average information (including min, med, max) like | ||
| * avg hashmap probe. Because `SQLMetric` stores long values, we take the ceil of the average | ||
| * values before storing them. This metric is used to record an average value computed in the | ||
| * end of a task. It should be set once. The initial values (zeros) of this metrics will be | ||
| * excluded after. | ||
| */ | ||
| def createAverageMetric(sc: SparkContext, name: String): SQLMetric = { | ||
| // The final result of this metric in physical operator UI may looks like: | ||
| // probe avg (min, med, max): | ||
| // (1, 6, 2) | ||
|
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. med is medium? why 6?
Member
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. oh. right. will fix this typo. :) |
||
| val acc = new SQLMetric(AVERAGE_METRIC) | ||
| acc.register(sc, name = Some(s"$name (min, med, max)"), countFailedValues = false) | ||
| acc | ||
| } | ||
|
|
||
| /** | ||
| * A function that defines how we aggregate the final accumulator results among all tasks, | ||
| * and represent it in string for a SQL physical operator. | ||
|
|
@@ -110,6 +126,20 @@ object SQLMetrics { | |
| if (metricsType == SUM_METRIC) { | ||
| val numberFormat = NumberFormat.getIntegerInstance(Locale.US) | ||
| numberFormat.format(values.sum) | ||
| } else if (metricsType == AVERAGE_METRIC) { | ||
| val numberFormat = NumberFormat.getIntegerInstance(Locale.US) | ||
|
|
||
| val validValues = values.filter(_ > 0) | ||
| val Seq(min, med, max) = { | ||
| val metric = if (validValues.isEmpty) { | ||
| Seq.fill(3)(0L) | ||
| } else { | ||
| val sorted = validValues.sorted | ||
| Seq(sorted(0), sorted(validValues.length / 2), sorted(validValues.length - 1)) | ||
| } | ||
| metric.map(numberFormat.format) | ||
| } | ||
| s"\n($min, $med, $max)" | ||
| } else { | ||
| val strFormat: Long => String = if (metricsType == SIZE_METRIC) { | ||
| Utils.bytesToString | ||
|
|
||
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.
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.
Always turn it on?
If we decide to always turn it on, why we still keep this parm?
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.
Yeah, based on the benchmark, seems the performance degradation is not an issue. We can completely remove this parameter.