-
Notifications
You must be signed in to change notification settings - Fork 9.2k
HDFS-16949 Introduce inverse quantiles for metrics where higher numer… #5495
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
Merged
Merged
Changes from all commits
Commits
Show all changes
7 commits
Select commit
Hold shift + click to select a range
b5ce564
HDFS-16949 Introduce inverse quantiles for metrics where higher numer…
0fceb1b
fix build errors
51be61b
review comments
b58e617
more review comments
3b06c5b
fix style errors
a4cc0c1
allow decimals in percentile in description
ce586db
Encapsulate common logic for MutableQuantile constructor
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
89 changes: 89 additions & 0 deletions
89
...t/hadoop-common/src/main/java/org/apache/hadoop/metrics2/lib/MutableInverseQuantiles.java
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 |
|---|---|---|
| @@ -0,0 +1,89 @@ | ||
| /** | ||
| * 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.hadoop.metrics2.lib; | ||
|
|
||
| import org.apache.hadoop.classification.InterfaceAudience; | ||
| import org.apache.hadoop.classification.InterfaceStability; | ||
| import org.apache.hadoop.classification.VisibleForTesting; | ||
| import org.apache.hadoop.metrics2.util.Quantile; | ||
| import org.apache.hadoop.metrics2.util.SampleQuantiles; | ||
| import java.text.DecimalFormat; | ||
| import static org.apache.hadoop.metrics2.lib.Interns.info; | ||
|
|
||
| /** | ||
| * Watches a stream of long values, maintaining online estimates of specific | ||
| * quantiles with provably low error bounds. Inverse quantiles are meant for | ||
| * highly accurate low-percentile (e.g. 1st, 5th) metrics. | ||
| * InverseQuantiles are used for metrics where higher the value better it is. | ||
| * ( eg: data transfer rate ). | ||
| * The 1st percentile here corresponds to the 99th inverse percentile metric, | ||
| * 5th percentile to 95th and so on. | ||
| */ | ||
| @InterfaceAudience.Public | ||
| @InterfaceStability.Evolving | ||
| public class MutableInverseQuantiles extends MutableQuantiles{ | ||
|
|
||
| static class InversePercentile extends Quantile { | ||
| InversePercentile(double inversePercentile) { | ||
| super(inversePercentile/100, inversePercentile/1000); | ||
| } | ||
| } | ||
|
|
||
| @VisibleForTesting | ||
| public static final Quantile[] INVERSE_QUANTILES = {new InversePercentile(50), | ||
| new InversePercentile(25), new InversePercentile(10), | ||
| new InversePercentile(5), new InversePercentile(1)}; | ||
|
|
||
| /** | ||
| * Instantiates a new {@link MutableInverseQuantiles} for a metric that rolls itself | ||
| * over on the specified time interval. | ||
| * | ||
| * @param name of the metric | ||
| * @param description long-form textual description of the metric | ||
| * @param sampleName type of items in the stream (e.g., "Ops") | ||
| * @param valueName type of the values | ||
| * @param intervalSecs rollover interval (in seconds) of the estimator | ||
| */ | ||
| public MutableInverseQuantiles(String name, String description, String sampleName, | ||
| String valueName, int intervalSecs) { | ||
| super(name, description, sampleName, valueName, intervalSecs); | ||
| } | ||
|
|
||
| /** | ||
| * Sets quantileInfo and estimator. | ||
| * | ||
| * @param ucName capitalized name of the metric | ||
| * @param uvName capitalized type of the values | ||
| * @param desc uncapitalized long-form textual description of the metric | ||
| * @param lvName uncapitalized type of the values | ||
| * @param df Number formatter for inverse percentile value | ||
| */ | ||
| void setQuantiles(String ucName, String uvName, String desc, String lvName, DecimalFormat df) { | ||
| // Construct the MetricsInfos for inverse quantiles, converting to inverse percentiles | ||
| setQuantileInfos(INVERSE_QUANTILES.length); | ||
| for (int i = 0; i < INVERSE_QUANTILES.length; i++) { | ||
| double inversePercentile = 100 * (1 - INVERSE_QUANTILES[i].quantile); | ||
| String nameTemplate = ucName + df.format(inversePercentile) + "thInversePercentile" + uvName; | ||
| String descTemplate = df.format(inversePercentile) + " inverse percentile " + lvName | ||
| + " with " + getInterval() + " second interval for " + desc; | ||
| addQuantileInfo(i, info(nameTemplate, descTemplate)); | ||
| } | ||
|
|
||
| setEstimator(new SampleQuantiles(INVERSE_QUANTILES)); | ||
| } | ||
| } | ||
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
Oops, something went wrong.
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.