Skip to content

Commit 09e5321

Browse files
committed
8225313: serviceability/jvmti/HeapMonitor/MyPackage/HeapMonitorStatObjectCorrectnessTest.java failed with Unexpected high difference percentage
Reviewed-by: dholmes, kevinw
1 parent 258f188 commit 09e5321

File tree

4 files changed

+23
-29
lines changed

4 files changed

+23
-29
lines changed

test/hotspot/jtreg/ProblemList.txt

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -108,10 +108,6 @@ serviceability/sa/sadebugd/DebugdConnectTest.java 8239062 macosx-x64
108108
serviceability/sa/TestRevPtrsForInvokeDynamic.java 8241235 generic-all
109109
resourcehogs/serviceability/sa/TestHeapDumpForLargeArray.java 8262386 generic-all
110110

111-
serviceability/jvmti/HeapMonitor/MyPackage/HeapMonitorStatIntervalTest.java 8214032 generic-all
112-
serviceability/jvmti/HeapMonitor/MyPackage/HeapMonitorInterpreterObjectTest.java 8225313 linux-i586,linux-x64,windows-x64
113-
serviceability/jvmti/HeapMonitor/MyPackage/HeapMonitorStatArrayCorrectnessTest.java 8224150 generic-all
114-
serviceability/jvmti/HeapMonitor/MyPackage/HeapMonitorStatObjectCorrectnessTest.java 8225313 linux-i586,linux-x64,windows-x64
115111
serviceability/jvmti/ModuleAwareAgents/ThreadStart/MAAThreadStart.java 8225354 windows-all
116112
serviceability/dcmd/gc/RunFinalizationTest.java 8227120 linux-all,windows-x64
117113

test/hotspot/jtreg/serviceability/jvmti/HeapMonitor/MyPackage/HeapMonitorStatArrayCorrectnessTest.java

Lines changed: 10 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright (c) 2018, 2019, Oracle and/or its affiliates. All rights reserved.
2+
* Copyright (c) 2018, 2021, Oracle and/or its affiliates. All rights reserved.
33
* Copyright (c) 2018, 2019, Google and/or its affiliates. All rights reserved.
44
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
55
*
@@ -36,10 +36,16 @@
3636
public class HeapMonitorStatArrayCorrectnessTest {
3737

3838
private static final int maxCount = 10;
39-
// Do 100000 iterations and expect maxIteration / multiplier samples.
40-
private static final int maxIteration = 100000;
39+
// Do 200000 iterations and expect maxIteration / multiplier samples.
40+
private static final int maxIteration = 200_000;
4141
private static int array[];
4242

43+
// 15% error ensures a sanity test without becoming flaky.
44+
// Flakiness is due to the fact that this test is dependent on the sampling interval, which is a
45+
// statistical geometric variable around the sampling interval. This means that the test could be
46+
// unlucky and not achieve the mean average fast enough for the test case.
47+
private static final int acceptedErrorPercentage = 15;
48+
4349
private static void allocate(int size) {
4450
for (int j = 0; j < maxIteration; j++) {
4551
array = new int[size];
@@ -85,11 +91,7 @@ public static void main(String[] args) {
8591
expected *= 4;
8692
expected /= samplingMultiplier;
8793

88-
// 10% error ensures a sanity test without becoming flaky.
89-
// Flakiness is due to the fact that this test is dependent on the sampling interval, which is a
90-
// statistical geometric variable around the sampling interval. This means that the test could be
91-
// unlucky and not achieve the mean average fast enough for the test case.
92-
if (HeapMonitor.statsHaveExpectedNumberSamples((int) expected, 10)) {
94+
if (HeapMonitor.statsHaveExpectedNumberSamples((int) expected, acceptedErrorPercentage)) {
9395
break;
9496
}
9597
}

test/hotspot/jtreg/serviceability/jvmti/HeapMonitor/MyPackage/HeapMonitorStatIntervalTest.java

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@ private static boolean testIntervalOnce(int interval, boolean throwIfFailure) {
4242
HeapMonitor.enableSamplingEvents();
4343

4444
int allocationTotal = 10 * 1024 * 1024;
45-
int allocationIterations = 10;
45+
int allocationIterations = 20;
4646

4747
double actualCount = 0;
4848
for (int i = 0; i < allocationIterations; i++) {
@@ -58,13 +58,13 @@ private static boolean testIntervalOnce(int interval, boolean throwIfFailure) {
5858
double error = Math.abs(actualCount - expectedCount);
5959
double errorPercentage = error / expectedCount * 100;
6060

61-
boolean success = (errorPercentage < 10.0);
61+
boolean success = (errorPercentage < 15.0);
6262
System.out.println("Interval: " + interval + ", throw if failure: " + throwIfFailure
6363
+ " - Expected count: " + expectedCount + ", allocationIterations: " + allocationIterations
6464
+ ", actualCount: " + actualCount + " -> " + success);
6565

6666
if (!success && throwIfFailure) {
67-
throw new RuntimeException("Interval average over 10% for interval " + interval + " -> "
67+
throw new RuntimeException("Interval average over 15% for interval " + interval + " -> "
6868
+ actualCount + ", " + expectedCount);
6969
}
7070

@@ -74,7 +74,7 @@ private static boolean testIntervalOnce(int interval, boolean throwIfFailure) {
7474

7575
private static void testInterval(int interval) {
7676
// Test the interval twice, it can happen that the test is "unlucky" and the interval just goes above
77-
// the 10% mark. So try again to squash flakiness.
77+
// the 15% mark. So try again to squash flakiness.
7878
// Flakiness is due to the fact that this test is dependent on the sampling interval, which is a
7979
// statistical geometric variable around the sampling interval. This means that the test could be
8080
// unlucky and not achieve the mean average fast enough for the test case.

test/hotspot/jtreg/serviceability/jvmti/HeapMonitor/MyPackage/HeapMonitorStatObjectCorrectnessTest.java

Lines changed: 9 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -36,11 +36,15 @@
3636
/** This test is checking the object allocation path works with heap sampling. */
3737
public class HeapMonitorStatObjectCorrectnessTest {
3838

39-
// Do 200000 iterations and expect maxIteration / multiplier samples.
40-
private static final int maxIteration = 200000;
39+
// Do 400000 iterations and expect maxIteration / multiplier samples.
40+
private static final int maxIteration = 400_000;
4141
private static BigObject obj;
4242

43-
private native static boolean statsHaveExpectedNumberSamples(int expected, int percentError);
43+
// 15% error ensures a sanity test without becoming flaky.
44+
// Flakiness is due to the fact that this test is dependent on the sampling interval, which is a
45+
// statistical geometric variable around the sampling interval. This means that the test could be
46+
// unlucky and not achieve the mean average fast enough for the test case.
47+
private static final int acceptedErrorPercentage = 15;
4448

4549
private static void allocate() {
4650
emptyStorage();
@@ -83,11 +87,7 @@ private static void testBigAllocationInterval() {
8387
double expected = maxIteration;
8488
expected /= samplingMultiplier;
8589

86-
// 10% error ensures a sanity test without becoming flaky.
87-
// Flakiness is due to the fact that this test is dependent on the sampling interval, which is a
88-
// statistical geometric variable around the sampling interval. This means that the test could be
89-
// unlucky and not achieve the mean average fast enough for the test case.
90-
if (!HeapMonitor.statsHaveExpectedNumberSamples((int) expected, 10)) {
90+
if (!HeapMonitor.statsHaveExpectedNumberSamples((int) expected, acceptedErrorPercentage)) {
9191
throw new RuntimeException("Statistics should show about " + expected + " samples.");
9292
}
9393
}
@@ -108,11 +108,7 @@ private static void testEveryAllocationSampled() {
108108

109109
double expected = maxIteration;
110110

111-
// 10% error ensures a sanity test without becoming flaky.
112-
// Flakiness is due to the fact that this test is dependent on the sampling interval, which is a
113-
// statistical geometric variable around the sampling interval. This means that the test could be
114-
// unlucky and not achieve the mean average fast enough for the test case.
115-
if (!HeapMonitor.statsHaveExpectedNumberSamples((int) expected, 10)) {
111+
if (!HeapMonitor.statsHaveExpectedNumberSamples((int) expected, acceptedErrorPercentage)) {
116112
throw new RuntimeException("Statistics should show about " + expected + " samples.");
117113
}
118114
}

0 commit comments

Comments
 (0)