8225313: serviceability/jvmti/HeapMonitor/MyPackage/HeapMonitorStatObjectCorrectnessTest.java failed with Unexpected high difference percentage

Reviewed-by: dholmes, kevinw
This commit is contained in:
Leonid Mesnik 2021-07-22 18:19:16 +00:00
parent 258f188bff
commit 09e5321763
4 changed files with 23 additions and 29 deletions

View file

@ -108,10 +108,6 @@ serviceability/sa/sadebugd/DebugdConnectTest.java 8239062 macosx-x64
serviceability/sa/TestRevPtrsForInvokeDynamic.java 8241235 generic-all serviceability/sa/TestRevPtrsForInvokeDynamic.java 8241235 generic-all
resourcehogs/serviceability/sa/TestHeapDumpForLargeArray.java 8262386 generic-all resourcehogs/serviceability/sa/TestHeapDumpForLargeArray.java 8262386 generic-all
serviceability/jvmti/HeapMonitor/MyPackage/HeapMonitorStatIntervalTest.java 8214032 generic-all
serviceability/jvmti/HeapMonitor/MyPackage/HeapMonitorInterpreterObjectTest.java 8225313 linux-i586,linux-x64,windows-x64
serviceability/jvmti/HeapMonitor/MyPackage/HeapMonitorStatArrayCorrectnessTest.java 8224150 generic-all
serviceability/jvmti/HeapMonitor/MyPackage/HeapMonitorStatObjectCorrectnessTest.java 8225313 linux-i586,linux-x64,windows-x64
serviceability/jvmti/ModuleAwareAgents/ThreadStart/MAAThreadStart.java 8225354 windows-all serviceability/jvmti/ModuleAwareAgents/ThreadStart/MAAThreadStart.java 8225354 windows-all
serviceability/dcmd/gc/RunFinalizationTest.java 8227120 linux-all,windows-x64 serviceability/dcmd/gc/RunFinalizationTest.java 8227120 linux-all,windows-x64

View file

@ -1,5 +1,5 @@
/* /*
* Copyright (c) 2018, 2019, Oracle and/or its affiliates. All rights reserved. * Copyright (c) 2018, 2021, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2018, 2019, Google and/or its affiliates. All rights reserved. * Copyright (c) 2018, 2019, Google and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
* *
@ -36,10 +36,16 @@ package MyPackage;
public class HeapMonitorStatArrayCorrectnessTest { public class HeapMonitorStatArrayCorrectnessTest {
private static final int maxCount = 10; private static final int maxCount = 10;
// Do 100000 iterations and expect maxIteration / multiplier samples. // Do 200000 iterations and expect maxIteration / multiplier samples.
private static final int maxIteration = 100000; private static final int maxIteration = 200_000;
private static int array[]; private static int array[];
// 15% error ensures a sanity test without becoming flaky.
// Flakiness is due to the fact that this test is dependent on the sampling interval, which is a
// statistical geometric variable around the sampling interval. This means that the test could be
// unlucky and not achieve the mean average fast enough for the test case.
private static final int acceptedErrorPercentage = 15;
private static void allocate(int size) { private static void allocate(int size) {
for (int j = 0; j < maxIteration; j++) { for (int j = 0; j < maxIteration; j++) {
array = new int[size]; array = new int[size];
@ -85,11 +91,7 @@ public class HeapMonitorStatArrayCorrectnessTest {
expected *= 4; expected *= 4;
expected /= samplingMultiplier; expected /= samplingMultiplier;
// 10% error ensures a sanity test without becoming flaky. if (HeapMonitor.statsHaveExpectedNumberSamples((int) expected, acceptedErrorPercentage)) {
// Flakiness is due to the fact that this test is dependent on the sampling interval, which is a
// statistical geometric variable around the sampling interval. This means that the test could be
// unlucky and not achieve the mean average fast enough for the test case.
if (HeapMonitor.statsHaveExpectedNumberSamples((int) expected, 10)) {
break; break;
} }
} }

View file

@ -42,7 +42,7 @@ public class HeapMonitorStatIntervalTest {
HeapMonitor.enableSamplingEvents(); HeapMonitor.enableSamplingEvents();
int allocationTotal = 10 * 1024 * 1024; int allocationTotal = 10 * 1024 * 1024;
int allocationIterations = 10; int allocationIterations = 20;
double actualCount = 0; double actualCount = 0;
for (int i = 0; i < allocationIterations; i++) { for (int i = 0; i < allocationIterations; i++) {
@ -58,13 +58,13 @@ public class HeapMonitorStatIntervalTest {
double error = Math.abs(actualCount - expectedCount); double error = Math.abs(actualCount - expectedCount);
double errorPercentage = error / expectedCount * 100; double errorPercentage = error / expectedCount * 100;
boolean success = (errorPercentage < 10.0); boolean success = (errorPercentage < 15.0);
System.out.println("Interval: " + interval + ", throw if failure: " + throwIfFailure System.out.println("Interval: " + interval + ", throw if failure: " + throwIfFailure
+ " - Expected count: " + expectedCount + ", allocationIterations: " + allocationIterations + " - Expected count: " + expectedCount + ", allocationIterations: " + allocationIterations
+ ", actualCount: " + actualCount + " -> " + success); + ", actualCount: " + actualCount + " -> " + success);
if (!success && throwIfFailure) { if (!success && throwIfFailure) {
throw new RuntimeException("Interval average over 10% for interval " + interval + " -> " throw new RuntimeException("Interval average over 15% for interval " + interval + " -> "
+ actualCount + ", " + expectedCount); + actualCount + ", " + expectedCount);
} }
@ -74,7 +74,7 @@ public class HeapMonitorStatIntervalTest {
private static void testInterval(int interval) { private static void testInterval(int interval) {
// Test the interval twice, it can happen that the test is "unlucky" and the interval just goes above // Test the interval twice, it can happen that the test is "unlucky" and the interval just goes above
// the 10% mark. So try again to squash flakiness. // the 15% mark. So try again to squash flakiness.
// Flakiness is due to the fact that this test is dependent on the sampling interval, which is a // Flakiness is due to the fact that this test is dependent on the sampling interval, which is a
// statistical geometric variable around the sampling interval. This means that the test could be // statistical geometric variable around the sampling interval. This means that the test could be
// unlucky and not achieve the mean average fast enough for the test case. // unlucky and not achieve the mean average fast enough for the test case.

View file

@ -36,11 +36,15 @@ package MyPackage;
/** This test is checking the object allocation path works with heap sampling. */ /** This test is checking the object allocation path works with heap sampling. */
public class HeapMonitorStatObjectCorrectnessTest { public class HeapMonitorStatObjectCorrectnessTest {
// Do 200000 iterations and expect maxIteration / multiplier samples. // Do 400000 iterations and expect maxIteration / multiplier samples.
private static final int maxIteration = 200000; private static final int maxIteration = 400_000;
private static BigObject obj; private static BigObject obj;
private native static boolean statsHaveExpectedNumberSamples(int expected, int percentError); // 15% error ensures a sanity test without becoming flaky.
// Flakiness is due to the fact that this test is dependent on the sampling interval, which is a
// statistical geometric variable around the sampling interval. This means that the test could be
// unlucky and not achieve the mean average fast enough for the test case.
private static final int acceptedErrorPercentage = 15;
private static void allocate() { private static void allocate() {
emptyStorage(); emptyStorage();
@ -83,11 +87,7 @@ public class HeapMonitorStatObjectCorrectnessTest {
double expected = maxIteration; double expected = maxIteration;
expected /= samplingMultiplier; expected /= samplingMultiplier;
// 10% error ensures a sanity test without becoming flaky. if (!HeapMonitor.statsHaveExpectedNumberSamples((int) expected, acceptedErrorPercentage)) {
// Flakiness is due to the fact that this test is dependent on the sampling interval, which is a
// statistical geometric variable around the sampling interval. This means that the test could be
// unlucky and not achieve the mean average fast enough for the test case.
if (!HeapMonitor.statsHaveExpectedNumberSamples((int) expected, 10)) {
throw new RuntimeException("Statistics should show about " + expected + " samples."); throw new RuntimeException("Statistics should show about " + expected + " samples.");
} }
} }
@ -108,11 +108,7 @@ public class HeapMonitorStatObjectCorrectnessTest {
double expected = maxIteration; double expected = maxIteration;
// 10% error ensures a sanity test without becoming flaky. if (!HeapMonitor.statsHaveExpectedNumberSamples((int) expected, acceptedErrorPercentage)) {
// Flakiness is due to the fact that this test is dependent on the sampling interval, which is a
// statistical geometric variable around the sampling interval. This means that the test could be
// unlucky and not achieve the mean average fast enough for the test case.
if (!HeapMonitor.statsHaveExpectedNumberSamples((int) expected, 10)) {
throw new RuntimeException("Statistics should show about " + expected + " samples."); throw new RuntimeException("Statistics should show about " + expected + " samples.");
} }
} }