author | tschatzl |
Tue, 19 Jul 2016 10:31:41 +0200 | |
changeset 39979 | b17e445924da |
parent 35929 | 2783e5e132e3 |
child 40631 | ed82623d7831 |
permissions | -rw-r--r-- |
20305
af013cf4a5e6
8014078: G1: improve remembered set summary information by providing per region type information
tschatzl
parents:
diff
changeset
|
1 |
/* |
30247
9925b07bba5b
8042901: Allow com.sun.management to be in a different module to java.lang.management
sjiang
parents:
25362
diff
changeset
|
2 |
* Copyright (c) 2013, 2015, Oracle and/or its affiliates. All rights reserved. |
20305
af013cf4a5e6
8014078: G1: improve remembered set summary information by providing per region type information
tschatzl
parents:
diff
changeset
|
3 |
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. |
af013cf4a5e6
8014078: G1: improve remembered set summary information by providing per region type information
tschatzl
parents:
diff
changeset
|
4 |
* |
af013cf4a5e6
8014078: G1: improve remembered set summary information by providing per region type information
tschatzl
parents:
diff
changeset
|
5 |
* This code is free software; you can redistribute it and/or modify it |
af013cf4a5e6
8014078: G1: improve remembered set summary information by providing per region type information
tschatzl
parents:
diff
changeset
|
6 |
* under the terms of the GNU General Public License version 2 only, as |
af013cf4a5e6
8014078: G1: improve remembered set summary information by providing per region type information
tschatzl
parents:
diff
changeset
|
7 |
* published by the Free Software Foundation. |
af013cf4a5e6
8014078: G1: improve remembered set summary information by providing per region type information
tschatzl
parents:
diff
changeset
|
8 |
* |
af013cf4a5e6
8014078: G1: improve remembered set summary information by providing per region type information
tschatzl
parents:
diff
changeset
|
9 |
* This code is distributed in the hope that it will be useful, but WITHOUT |
af013cf4a5e6
8014078: G1: improve remembered set summary information by providing per region type information
tschatzl
parents:
diff
changeset
|
10 |
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or |
af013cf4a5e6
8014078: G1: improve remembered set summary information by providing per region type information
tschatzl
parents:
diff
changeset
|
11 |
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License |
af013cf4a5e6
8014078: G1: improve remembered set summary information by providing per region type information
tschatzl
parents:
diff
changeset
|
12 |
* version 2 for more details (a copy is included in the LICENSE file that |
af013cf4a5e6
8014078: G1: improve remembered set summary information by providing per region type information
tschatzl
parents:
diff
changeset
|
13 |
* accompanied this code). |
af013cf4a5e6
8014078: G1: improve remembered set summary information by providing per region type information
tschatzl
parents:
diff
changeset
|
14 |
* |
af013cf4a5e6
8014078: G1: improve remembered set summary information by providing per region type information
tschatzl
parents:
diff
changeset
|
15 |
* You should have received a copy of the GNU General Public License version |
af013cf4a5e6
8014078: G1: improve remembered set summary information by providing per region type information
tschatzl
parents:
diff
changeset
|
16 |
* 2 along with this work; if not, write to the Free Software Foundation, |
af013cf4a5e6
8014078: G1: improve remembered set summary information by providing per region type information
tschatzl
parents:
diff
changeset
|
17 |
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. |
af013cf4a5e6
8014078: G1: improve remembered set summary information by providing per region type information
tschatzl
parents:
diff
changeset
|
18 |
* |
af013cf4a5e6
8014078: G1: improve remembered set summary information by providing per region type information
tschatzl
parents:
diff
changeset
|
19 |
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA |
af013cf4a5e6
8014078: G1: improve remembered set summary information by providing per region type information
tschatzl
parents:
diff
changeset
|
20 |
* or visit www.oracle.com if you need additional information or have any |
af013cf4a5e6
8014078: G1: improve remembered set summary information by providing per region type information
tschatzl
parents:
diff
changeset
|
21 |
* questions. |
af013cf4a5e6
8014078: G1: improve remembered set summary information by providing per region type information
tschatzl
parents:
diff
changeset
|
22 |
*/ |
af013cf4a5e6
8014078: G1: improve remembered set summary information by providing per region type information
tschatzl
parents:
diff
changeset
|
23 |
|
af013cf4a5e6
8014078: G1: improve remembered set summary information by providing per region type information
tschatzl
parents:
diff
changeset
|
24 |
/* |
35061 | 25 |
* Common helpers for TestRemsetLogging* tests |
20305
af013cf4a5e6
8014078: G1: improve remembered set summary information by providing per region type information
tschatzl
parents:
diff
changeset
|
26 |
*/ |
af013cf4a5e6
8014078: G1: improve remembered set summary information by providing per region type information
tschatzl
parents:
diff
changeset
|
27 |
|
af013cf4a5e6
8014078: G1: improve remembered set summary information by providing per region type information
tschatzl
parents:
diff
changeset
|
28 |
import com.sun.management.HotSpotDiagnosticMXBean; |
af013cf4a5e6
8014078: G1: improve remembered set summary information by providing per region type information
tschatzl
parents:
diff
changeset
|
29 |
import com.sun.management.VMOption; |
35189
a69874af6697
8145534: TestRemsetLogging.java takes a long time
tschatzl
parents:
35061
diff
changeset
|
30 |
import sun.hotspot.WhiteBox; |
20305
af013cf4a5e6
8014078: G1: improve remembered set summary information by providing per region type information
tschatzl
parents:
diff
changeset
|
31 |
|
30604
b8d532cb6420
8067013: Rename the com.oracle.java.testlibary package
ykantser
parents:
30247
diff
changeset
|
32 |
import jdk.test.lib.*; |
30247
9925b07bba5b
8042901: Allow com.sun.management to be in a different module to java.lang.management
sjiang
parents:
25362
diff
changeset
|
33 |
import java.lang.management.ManagementFactory; |
20305
af013cf4a5e6
8014078: G1: improve remembered set summary information by providing per region type information
tschatzl
parents:
diff
changeset
|
34 |
import java.util.ArrayList; |
af013cf4a5e6
8014078: G1: improve remembered set summary information by providing per region type information
tschatzl
parents:
diff
changeset
|
35 |
import java.util.Arrays; |
af013cf4a5e6
8014078: G1: improve remembered set summary information by providing per region type information
tschatzl
parents:
diff
changeset
|
36 |
|
af013cf4a5e6
8014078: G1: improve remembered set summary information by providing per region type information
tschatzl
parents:
diff
changeset
|
37 |
class VerifySummaryOutput { |
af013cf4a5e6
8014078: G1: improve remembered set summary information by providing per region type information
tschatzl
parents:
diff
changeset
|
38 |
public static void main(String[] args) { |
af013cf4a5e6
8014078: G1: improve remembered set summary information by providing per region type information
tschatzl
parents:
diff
changeset
|
39 |
int numGCs = Integer.parseInt(args[0]); |
af013cf4a5e6
8014078: G1: improve remembered set summary information by providing per region type information
tschatzl
parents:
diff
changeset
|
40 |
|
35189
a69874af6697
8145534: TestRemsetLogging.java takes a long time
tschatzl
parents:
35061
diff
changeset
|
41 |
// Perform the requested amount of GCs. |
a69874af6697
8145534: TestRemsetLogging.java takes a long time
tschatzl
parents:
35061
diff
changeset
|
42 |
WhiteBox wb = WhiteBox.getWhiteBox(); |
a69874af6697
8145534: TestRemsetLogging.java takes a long time
tschatzl
parents:
35061
diff
changeset
|
43 |
for (int i = 0; i < numGCs - 1; i++) { |
a69874af6697
8145534: TestRemsetLogging.java takes a long time
tschatzl
parents:
35061
diff
changeset
|
44 |
wb.youngGC(); |
a69874af6697
8145534: TestRemsetLogging.java takes a long time
tschatzl
parents:
35061
diff
changeset
|
45 |
} |
20305
af013cf4a5e6
8014078: G1: improve remembered set summary information by providing per region type information
tschatzl
parents:
diff
changeset
|
46 |
if (numGCs > 0) { |
35189
a69874af6697
8145534: TestRemsetLogging.java takes a long time
tschatzl
parents:
35061
diff
changeset
|
47 |
wb.fullGC(); |
20305
af013cf4a5e6
8014078: G1: improve remembered set summary information by providing per region type information
tschatzl
parents:
diff
changeset
|
48 |
} |
af013cf4a5e6
8014078: G1: improve remembered set summary information by providing per region type information
tschatzl
parents:
diff
changeset
|
49 |
} |
af013cf4a5e6
8014078: G1: improve remembered set summary information by providing per region type information
tschatzl
parents:
diff
changeset
|
50 |
} |
af013cf4a5e6
8014078: G1: improve remembered set summary information by providing per region type information
tschatzl
parents:
diff
changeset
|
51 |
|
35061 | 52 |
public class TestRemsetLoggingTools { |
20305
af013cf4a5e6
8014078: G1: improve remembered set summary information by providing per region type information
tschatzl
parents:
diff
changeset
|
53 |
|
af013cf4a5e6
8014078: G1: improve remembered set summary information by providing per region type information
tschatzl
parents:
diff
changeset
|
54 |
public static String runTest(String[] additionalArgs, int numGCs) throws Exception { |
af013cf4a5e6
8014078: G1: improve remembered set summary information by providing per region type information
tschatzl
parents:
diff
changeset
|
55 |
ArrayList<String> finalargs = new ArrayList<String>(); |
af013cf4a5e6
8014078: G1: improve remembered set summary information by providing per region type information
tschatzl
parents:
diff
changeset
|
56 |
String[] defaultArgs = new String[] { |
35189
a69874af6697
8145534: TestRemsetLogging.java takes a long time
tschatzl
parents:
35061
diff
changeset
|
57 |
"-Xbootclasspath/a:.", |
a69874af6697
8145534: TestRemsetLogging.java takes a long time
tschatzl
parents:
35061
diff
changeset
|
58 |
"-XX:+UnlockDiagnosticVMOptions", "-XX:+WhiteBoxAPI", |
a69874af6697
8145534: TestRemsetLogging.java takes a long time
tschatzl
parents:
35061
diff
changeset
|
59 |
"-cp", System.getProperty("java.class.path"), |
20305
af013cf4a5e6
8014078: G1: improve remembered set summary information by providing per region type information
tschatzl
parents:
diff
changeset
|
60 |
"-XX:+UseG1GC", |
af013cf4a5e6
8014078: G1: improve remembered set summary information by providing per region type information
tschatzl
parents:
diff
changeset
|
61 |
"-Xmn4m", |
35189
a69874af6697
8145534: TestRemsetLogging.java takes a long time
tschatzl
parents:
35061
diff
changeset
|
62 |
"-Xint", // -Xint makes the test run faster |
31629
892d04ec5304
8129977: TestSummarizeRSetStats.java fails: Incorrect amount of per-period RSet summaries at the end
tschatzl
parents:
30604
diff
changeset
|
63 |
"-Xms20m", |
20305
af013cf4a5e6
8014078: G1: improve remembered set summary information by providing per region type information
tschatzl
parents:
diff
changeset
|
64 |
"-Xmx20m", |
35189
a69874af6697
8145534: TestRemsetLogging.java takes a long time
tschatzl
parents:
35061
diff
changeset
|
65 |
"-XX:ParallelGCThreads=1", |
20305
af013cf4a5e6
8014078: G1: improve remembered set summary information by providing per region type information
tschatzl
parents:
diff
changeset
|
66 |
"-XX:InitiatingHeapOccupancyPercent=100", // we don't want the additional GCs due to initial marking |
af013cf4a5e6
8014078: G1: improve remembered set summary information by providing per region type information
tschatzl
parents:
diff
changeset
|
67 |
"-XX:+UnlockDiagnosticVMOptions", |
af013cf4a5e6
8014078: G1: improve remembered set summary information by providing per region type information
tschatzl
parents:
diff
changeset
|
68 |
"-XX:G1HeapRegionSize=1M", |
af013cf4a5e6
8014078: G1: improve remembered set summary information by providing per region type information
tschatzl
parents:
diff
changeset
|
69 |
}; |
af013cf4a5e6
8014078: G1: improve remembered set summary information by providing per region type information
tschatzl
parents:
diff
changeset
|
70 |
|
af013cf4a5e6
8014078: G1: improve remembered set summary information by providing per region type information
tschatzl
parents:
diff
changeset
|
71 |
finalargs.addAll(Arrays.asList(defaultArgs)); |
af013cf4a5e6
8014078: G1: improve remembered set summary information by providing per region type information
tschatzl
parents:
diff
changeset
|
72 |
|
af013cf4a5e6
8014078: G1: improve remembered set summary information by providing per region type information
tschatzl
parents:
diff
changeset
|
73 |
if (additionalArgs != null) { |
af013cf4a5e6
8014078: G1: improve remembered set summary information by providing per region type information
tschatzl
parents:
diff
changeset
|
74 |
finalargs.addAll(Arrays.asList(additionalArgs)); |
af013cf4a5e6
8014078: G1: improve remembered set summary information by providing per region type information
tschatzl
parents:
diff
changeset
|
75 |
} |
af013cf4a5e6
8014078: G1: improve remembered set summary information by providing per region type information
tschatzl
parents:
diff
changeset
|
76 |
|
af013cf4a5e6
8014078: G1: improve remembered set summary information by providing per region type information
tschatzl
parents:
diff
changeset
|
77 |
finalargs.add(VerifySummaryOutput.class.getName()); |
af013cf4a5e6
8014078: G1: improve remembered set summary information by providing per region type information
tschatzl
parents:
diff
changeset
|
78 |
finalargs.add(String.valueOf(numGCs)); |
af013cf4a5e6
8014078: G1: improve remembered set summary information by providing per region type information
tschatzl
parents:
diff
changeset
|
79 |
|
af013cf4a5e6
8014078: G1: improve remembered set summary information by providing per region type information
tschatzl
parents:
diff
changeset
|
80 |
ProcessBuilder pb = ProcessTools.createJavaProcessBuilder( |
af013cf4a5e6
8014078: G1: improve remembered set summary information by providing per region type information
tschatzl
parents:
diff
changeset
|
81 |
finalargs.toArray(new String[0])); |
af013cf4a5e6
8014078: G1: improve remembered set summary information by providing per region type information
tschatzl
parents:
diff
changeset
|
82 |
OutputAnalyzer output = new OutputAnalyzer(pb.start()); |
af013cf4a5e6
8014078: G1: improve remembered set summary information by providing per region type information
tschatzl
parents:
diff
changeset
|
83 |
|
af013cf4a5e6
8014078: G1: improve remembered set summary information by providing per region type information
tschatzl
parents:
diff
changeset
|
84 |
output.shouldHaveExitValue(0); |
af013cf4a5e6
8014078: G1: improve remembered set summary information by providing per region type information
tschatzl
parents:
diff
changeset
|
85 |
|
af013cf4a5e6
8014078: G1: improve remembered set summary information by providing per region type information
tschatzl
parents:
diff
changeset
|
86 |
String result = output.getStdout(); |
af013cf4a5e6
8014078: G1: improve remembered set summary information by providing per region type information
tschatzl
parents:
diff
changeset
|
87 |
return result; |
af013cf4a5e6
8014078: G1: improve remembered set summary information by providing per region type information
tschatzl
parents:
diff
changeset
|
88 |
} |
af013cf4a5e6
8014078: G1: improve remembered set summary information by providing per region type information
tschatzl
parents:
diff
changeset
|
89 |
|
af013cf4a5e6
8014078: G1: improve remembered set summary information by providing per region type information
tschatzl
parents:
diff
changeset
|
90 |
private static void checkCounts(int expected, int actual, String which) throws Exception { |
af013cf4a5e6
8014078: G1: improve remembered set summary information by providing per region type information
tschatzl
parents:
diff
changeset
|
91 |
if (expected != actual) { |
af013cf4a5e6
8014078: G1: improve remembered set summary information by providing per region type information
tschatzl
parents:
diff
changeset
|
92 |
throw new Exception("RSet summaries mention " + which + " regions an incorrect number of times. Expected " + expected + ", got " + actual); |
af013cf4a5e6
8014078: G1: improve remembered set summary information by providing per region type information
tschatzl
parents:
diff
changeset
|
93 |
} |
af013cf4a5e6
8014078: G1: improve remembered set summary information by providing per region type information
tschatzl
parents:
diff
changeset
|
94 |
} |
af013cf4a5e6
8014078: G1: improve remembered set summary information by providing per region type information
tschatzl
parents:
diff
changeset
|
95 |
|
af013cf4a5e6
8014078: G1: improve remembered set summary information by providing per region type information
tschatzl
parents:
diff
changeset
|
96 |
public static void expectPerRegionRSetSummaries(String result, int expectedCumulative, int expectedPeriodic) throws Exception { |
af013cf4a5e6
8014078: G1: improve remembered set summary information by providing per region type information
tschatzl
parents:
diff
changeset
|
97 |
expectRSetSummaries(result, expectedCumulative, expectedPeriodic); |
af013cf4a5e6
8014078: G1: improve remembered set summary information by providing per region type information
tschatzl
parents:
diff
changeset
|
98 |
int actualYoung = result.split("Young regions").length - 1; |
35929 | 99 |
int actualHumongous = result.split("Humongous regions").length - 1; |
20305
af013cf4a5e6
8014078: G1: improve remembered set summary information by providing per region type information
tschatzl
parents:
diff
changeset
|
100 |
int actualFree = result.split("Free regions").length - 1; |
af013cf4a5e6
8014078: G1: improve remembered set summary information by providing per region type information
tschatzl
parents:
diff
changeset
|
101 |
int actualOther = result.split("Old regions").length - 1; |
af013cf4a5e6
8014078: G1: improve remembered set summary information by providing per region type information
tschatzl
parents:
diff
changeset
|
102 |
|
af013cf4a5e6
8014078: G1: improve remembered set summary information by providing per region type information
tschatzl
parents:
diff
changeset
|
103 |
// the strings we check for above are printed four times per summary |
af013cf4a5e6
8014078: G1: improve remembered set summary information by providing per region type information
tschatzl
parents:
diff
changeset
|
104 |
int expectedPerRegionTypeInfo = (expectedCumulative + expectedPeriodic) * 4; |
af013cf4a5e6
8014078: G1: improve remembered set summary information by providing per region type information
tschatzl
parents:
diff
changeset
|
105 |
|
af013cf4a5e6
8014078: G1: improve remembered set summary information by providing per region type information
tschatzl
parents:
diff
changeset
|
106 |
checkCounts(expectedPerRegionTypeInfo, actualYoung, "Young"); |
35929 | 107 |
checkCounts(expectedPerRegionTypeInfo, actualHumongous, "Humongous"); |
20305
af013cf4a5e6
8014078: G1: improve remembered set summary information by providing per region type information
tschatzl
parents:
diff
changeset
|
108 |
checkCounts(expectedPerRegionTypeInfo, actualFree, "Free"); |
af013cf4a5e6
8014078: G1: improve remembered set summary information by providing per region type information
tschatzl
parents:
diff
changeset
|
109 |
checkCounts(expectedPerRegionTypeInfo, actualOther, "Old"); |
af013cf4a5e6
8014078: G1: improve remembered set summary information by providing per region type information
tschatzl
parents:
diff
changeset
|
110 |
} |
af013cf4a5e6
8014078: G1: improve remembered set summary information by providing per region type information
tschatzl
parents:
diff
changeset
|
111 |
|
af013cf4a5e6
8014078: G1: improve remembered set summary information by providing per region type information
tschatzl
parents:
diff
changeset
|
112 |
public static void expectRSetSummaries(String result, int expectedCumulative, int expectedPeriodic) throws Exception { |
af013cf4a5e6
8014078: G1: improve remembered set summary information by providing per region type information
tschatzl
parents:
diff
changeset
|
113 |
int actualTotal = result.split("concurrent refinement").length - 1; |
af013cf4a5e6
8014078: G1: improve remembered set summary information by providing per region type information
tschatzl
parents:
diff
changeset
|
114 |
int actualCumulative = result.split("Cumulative RS summary").length - 1; |
af013cf4a5e6
8014078: G1: improve remembered set summary information by providing per region type information
tschatzl
parents:
diff
changeset
|
115 |
|
af013cf4a5e6
8014078: G1: improve remembered set summary information by providing per region type information
tschatzl
parents:
diff
changeset
|
116 |
if (expectedCumulative != actualCumulative) { |
af013cf4a5e6
8014078: G1: improve remembered set summary information by providing per region type information
tschatzl
parents:
diff
changeset
|
117 |
throw new Exception("Incorrect amount of RSet summaries at the end. Expected " + expectedCumulative + ", got " + actualCumulative); |
af013cf4a5e6
8014078: G1: improve remembered set summary information by providing per region type information
tschatzl
parents:
diff
changeset
|
118 |
} |
af013cf4a5e6
8014078: G1: improve remembered set summary information by providing per region type information
tschatzl
parents:
diff
changeset
|
119 |
|
af013cf4a5e6
8014078: G1: improve remembered set summary information by providing per region type information
tschatzl
parents:
diff
changeset
|
120 |
if (expectedPeriodic != (actualTotal - actualCumulative)) { |
af013cf4a5e6
8014078: G1: improve remembered set summary information by providing per region type information
tschatzl
parents:
diff
changeset
|
121 |
throw new Exception("Incorrect amount of per-period RSet summaries at the end. Expected " + expectedPeriodic + ", got " + (actualTotal - actualCumulative)); |
af013cf4a5e6
8014078: G1: improve remembered set summary information by providing per region type information
tschatzl
parents:
diff
changeset
|
122 |
} |
af013cf4a5e6
8014078: G1: improve remembered set summary information by providing per region type information
tschatzl
parents:
diff
changeset
|
123 |
} |
af013cf4a5e6
8014078: G1: improve remembered set summary information by providing per region type information
tschatzl
parents:
diff
changeset
|
124 |
} |