[GitHub] [hadoop] goiri commented on a diff in pull request #5556: HDFS-16982 Use the right Quantiles Array for Inverse Quantiles snapshot

2023-04-17 Thread via GitHub


goiri commented on code in PR #5556:
URL: https://github.com/apache/hadoop/pull/5556#discussion_r1169028613


##
hadoop-common-project/hadoop-common/src/test/java/org/apache/hadoop/metrics2/lib/TestMutableMetrics.java:
##
@@ -52,6 +52,8 @@ public class TestMutableMetrics {
   private static final Logger LOG =
   LoggerFactory.getLogger(TestMutableMetrics.class);
   private static final double EPSILON = 1e-42;
+  private static final int SLEEP_TIME = 6000;

Review Comment:
   SLEEP_TIME_MS = 6 * 1000; // 6 seconds



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: common-issues-unsubscr...@hadoop.apache.org

For queries about this service, please contact Infrastructure at:
us...@infra.apache.org


-
To unsubscribe, e-mail: common-issues-unsubscr...@hadoop.apache.org
For additional commands, e-mail: common-issues-h...@hadoop.apache.org



[GitHub] [hadoop] goiri commented on a diff in pull request #5556: HDFS-16982 Use the right Quantiles Array for Inverse Quantiles snapshot

2023-04-14 Thread via GitHub


goiri commented on code in PR #5556:
URL: https://github.com/apache/hadoop/pull/5556#discussion_r1167234948


##
hadoop-common-project/hadoop-common/src/main/java/org/apache/hadoop/metrics2/lib/MutableQuantiles.java:
##
@@ -130,11 +129,11 @@ public MutableQuantiles() {}
   public synchronized void snapshot(MetricsRecordBuilder builder, boolean all) 
{
 if (all || changed()) {
   builder.addGauge(numInfo, previousCount);
-  for (int i = 0; i < quantiles.length; i++) {
+  for (int i = 0; i < getQuantiles().length; i++) {

Review Comment:
   You probably need to extract `getQuantiles()`, otherwise you may end up with 
two versions.



##
hadoop-common-project/hadoop-common/src/test/java/org/apache/hadoop/metrics2/lib/TestMutableMetrics.java:
##
@@ -431,6 +431,46 @@ public void testMutableQuantilesError() throws Exception {
 }
   }
 
+  /**
+   * Ensure that quantile estimates from {@link MutableInverseQuantiles} are 
within
+   * specified error bounds.
+   */
+  @Test(timeout = 3)
+  public void testMutableInverseQuantilesError() throws Exception {
+MetricsRecordBuilder mb = mockMetricsRecordBuilder();
+MetricsRegistry registry = new MetricsRegistry("test");
+// Use a 5s rollover period
+MutableQuantiles inverseQuantiles = registry.newInverseQuantiles("foo", 
"stat", "Ops",
+"Latency", 5);
+// Push some values in and wait for it to publish
+long start = System.nanoTime() / 100;

Review Comment:
   Use units in the vars.



##
hadoop-common-project/hadoop-common/src/test/java/org/apache/hadoop/metrics2/lib/TestMutableMetrics.java:
##
@@ -431,6 +431,46 @@ public void testMutableQuantilesError() throws Exception {
 }
   }
 
+  /**
+   * Ensure that quantile estimates from {@link MutableInverseQuantiles} are 
within
+   * specified error bounds.
+   */
+  @Test(timeout = 3)
+  public void testMutableInverseQuantilesError() throws Exception {
+MetricsRecordBuilder mb = mockMetricsRecordBuilder();
+MetricsRegistry registry = new MetricsRegistry("test");
+// Use a 5s rollover period
+MutableQuantiles inverseQuantiles = registry.newInverseQuantiles("foo", 
"stat", "Ops",
+"Latency", 5);
+// Push some values in and wait for it to publish
+long start = System.nanoTime() / 100;
+for (long i = 1; i <= 1000; i++) {

Review Comment:
   Declare constants.



##
hadoop-common-project/hadoop-common/src/test/java/org/apache/hadoop/metrics2/lib/TestMutableMetrics.java:
##
@@ -431,6 +431,46 @@ public void testMutableQuantilesError() throws Exception {
 }
   }
 
+  /**
+   * Ensure that quantile estimates from {@link MutableInverseQuantiles} are 
within
+   * specified error bounds.
+   */
+  @Test(timeout = 3)
+  public void testMutableInverseQuantilesError() throws Exception {
+MetricsRecordBuilder mb = mockMetricsRecordBuilder();
+MetricsRegistry registry = new MetricsRegistry("test");
+// Use a 5s rollover period
+MutableQuantiles inverseQuantiles = registry.newInverseQuantiles("foo", 
"stat", "Ops",
+"Latency", 5);
+// Push some values in and wait for it to publish
+long start = System.nanoTime() / 100;
+for (long i = 1; i <= 1000; i++) {
+  inverseQuantiles.add(i);
+  inverseQuantiles.add(1001 - i);
+}
+long end = System.nanoTime() / 100;
+
+Thread.sleep(6000 - (end - start));

Review Comment:
   Constant



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: common-issues-unsubscr...@hadoop.apache.org

For queries about this service, please contact Infrastructure at:
us...@infra.apache.org


-
To unsubscribe, e-mail: common-issues-unsubscr...@hadoop.apache.org
For additional commands, e-mail: common-issues-h...@hadoop.apache.org