author | mchernov |
Fri, 17 Jun 2016 18:45:09 +0300 | |
changeset 39294 | 4be906c4ad95 |
parent 38726 | 2c99beca1dd8 |
child 39414 | 4adf52148100 |
permissions | -rw-r--r-- |
35885 | 1 |
/* |
2 |
* Copyright (c) 2016, Oracle and/or its affiliates. All rights reserved. |
|
3 |
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. |
|
4 |
* |
|
5 |
* This code is free software; you can redistribute it and/or modify it |
|
6 |
* under the terms of the GNU General Public License version 2 only, as |
|
7 |
* published by the Free Software Foundation. |
|
8 |
* |
|
9 |
* This code is distributed in the hope that it will be useful, but WITHOUT |
|
10 |
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or |
|
11 |
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License |
|
12 |
* version 2 for more details (a copy is included in the LICENSE file that |
|
13 |
* accompanied this code). |
|
14 |
* |
|
15 |
* You should have received a copy of the GNU General Public License version |
|
16 |
* 2 along with this work; if not, write to the Free Software Foundation, |
|
17 |
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. |
|
18 |
* |
|
19 |
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA |
|
20 |
* or visit www.oracle.com if you need additional information or have any |
|
21 |
* questions. |
|
22 |
*/ |
|
23 |
||
24 |
/* |
|
25 |
* @test TestPLABResize |
|
36390
a2d991d1d628
8141141: Young and Old gen PLAB stats are similar in output with -XX:+PrintPLAB
tschatzl
parents:
36205
diff
changeset
|
26 |
* @bug 8141278 8141141 |
35885 | 27 |
* @summary Test for PLAB resizing |
39294
4be906c4ad95
8158412: [TESTBUG] TestIHOPErgo and TestStressG1Humongous should not be executed when JFR is enabled
mchernov
parents:
38726
diff
changeset
|
28 |
* @requires vm.gc == "G1" | vm.gc == "null" |
4be906c4ad95
8158412: [TESTBUG] TestIHOPErgo and TestStressG1Humongous should not be executed when JFR is enabled
mchernov
parents:
38726
diff
changeset
|
29 |
* @requires !vm.flightRecorder |
36616 | 30 |
* @library /testlibrary /test/lib / |
38152
80e5da81fb2c
8154258: [TESTBUG] Various serviceability tests fail compilation
dsamersoff
parents:
37181
diff
changeset
|
31 |
* @modules java.base/jdk.internal.misc |
35885 | 32 |
* @modules java.management |
33 |
* @build ClassFileInstaller |
|
34 |
* sun.hotspot.WhiteBox |
|
35 |
* gc.g1.plab.lib.LogParser |
|
36 |
* gc.g1.plab.lib.MemoryConsumer |
|
37 |
* gc.g1.plab.lib.PLABUtils |
|
38 |
* gc.g1.plab.lib.AppPLABResize |
|
39 |
* @run main ClassFileInstaller sun.hotspot.WhiteBox |
|
40 |
* sun.hotspot.WhiteBox$WhiteBoxPermission |
|
41 |
* @run main gc.g1.plab.TestPLABResize |
|
42 |
*/ |
|
43 |
package gc.g1.plab; |
|
44 |
||
45 |
import java.util.Arrays; |
|
46 |
import java.util.List; |
|
47 |
import java.util.stream.Collectors; |
|
48 |
import java.io.PrintStream; |
|
49 |
||
50 |
import gc.g1.plab.lib.LogParser; |
|
51 |
import gc.g1.plab.lib.PLABUtils; |
|
52 |
import gc.g1.plab.lib.AppPLABResize; |
|
37181
0d5e8ae18924
8149662: Refactor hotspot/test/gc/g1/plab/lib/LogParser.java
mchernov
parents:
37163
diff
changeset
|
53 |
import gc.g1.plab.lib.PlabReport; |
35885 | 54 |
|
55 |
import jdk.test.lib.OutputAnalyzer; |
|
56 |
import jdk.test.lib.ProcessTools; |
|
57 |
||
58 |
/** |
|
59 |
* Test for PLAB resizing. |
|
60 |
*/ |
|
61 |
public class TestPLABResize { |
|
62 |
||
63 |
private static final int OBJECT_SIZE_SMALL = 10; |
|
64 |
private static final int OBJECT_SIZE_MEDIUM = 70; |
|
65 |
private static final int OBJECT_SIZE_HIGH = 150; |
|
66 |
private static final int GC_NUM_SMALL = 1; |
|
67 |
private static final int GC_NUM_MEDIUM = 3; |
|
68 |
private static final int GC_NUM_HIGH = 7; |
|
69 |
private static final int WASTE_PCT_SMALL = 10; |
|
70 |
private static final int WASTE_PCT_MEDIUM = 20; |
|
71 |
private static final int WASTE_PCT_HIGH = 30; |
|
72 |
||
73 |
private static final int ITERATIONS_SMALL = 3; |
|
74 |
private static final int ITERATIONS_MEDIUM = 5; |
|
75 |
private static final int ITERATIONS_HIGH = 8; |
|
76 |
||
37181
0d5e8ae18924
8149662: Refactor hotspot/test/gc/g1/plab/lib/LogParser.java
mchernov
parents:
37163
diff
changeset
|
77 |
private static final String PLAB_SIZE_FIELD_NAME = "actual"; |
0d5e8ae18924
8149662: Refactor hotspot/test/gc/g1/plab/lib/LogParser.java
mchernov
parents:
37163
diff
changeset
|
78 |
|
35885 | 79 |
private final static TestCase[] TEST_CASES = { |
80 |
new TestCase(WASTE_PCT_SMALL, OBJECT_SIZE_SMALL, GC_NUM_SMALL, ITERATIONS_MEDIUM), |
|
81 |
new TestCase(WASTE_PCT_SMALL, OBJECT_SIZE_MEDIUM, GC_NUM_HIGH, ITERATIONS_SMALL), |
|
82 |
new TestCase(WASTE_PCT_SMALL, OBJECT_SIZE_HIGH, GC_NUM_MEDIUM, ITERATIONS_HIGH), |
|
83 |
new TestCase(WASTE_PCT_MEDIUM, OBJECT_SIZE_SMALL, GC_NUM_HIGH, ITERATIONS_MEDIUM), |
|
84 |
new TestCase(WASTE_PCT_MEDIUM, OBJECT_SIZE_MEDIUM, GC_NUM_SMALL, ITERATIONS_SMALL), |
|
85 |
new TestCase(WASTE_PCT_MEDIUM, OBJECT_SIZE_HIGH, GC_NUM_MEDIUM, ITERATIONS_HIGH), |
|
86 |
new TestCase(WASTE_PCT_HIGH, OBJECT_SIZE_SMALL, GC_NUM_HIGH, ITERATIONS_MEDIUM), |
|
87 |
new TestCase(WASTE_PCT_HIGH, OBJECT_SIZE_MEDIUM, GC_NUM_SMALL, ITERATIONS_SMALL), |
|
88 |
new TestCase(WASTE_PCT_HIGH, OBJECT_SIZE_HIGH, GC_NUM_MEDIUM, ITERATIONS_HIGH) |
|
89 |
}; |
|
90 |
||
91 |
public static void main(String[] args) throws Throwable { |
|
92 |
for (TestCase testCase : TEST_CASES) { |
|
93 |
testCase.print(System.out); |
|
94 |
List<String> options = PLABUtils.prepareOptions(testCase.toOptions()); |
|
95 |
options.add(AppPLABResize.class.getName()); |
|
96 |
OutputAnalyzer out = ProcessTools.executeTestJvm(options.toArray(new String[options.size()])); |
|
38726
2c99beca1dd8
8157452: [TESTBUG] PLAB tests don't handle unexpected GC
mchernov
parents:
38152
diff
changeset
|
97 |
PLABUtils.commonCheck(out); |
35885 | 98 |
checkResults(out.getOutput(), testCase); |
99 |
} |
|
100 |
} |
|
101 |
||
102 |
/** |
|
103 |
* Checks testing results. |
|
104 |
* Expected results - desired PLAB size is decreased and increased during promotion to Survivor. |
|
105 |
* |
|
106 |
* @param output - VM output |
|
107 |
* @param testCase |
|
108 |
*/ |
|
109 |
private static void checkResults(String output, TestCase testCase) { |
|
110 |
final LogParser log = new LogParser(output); |
|
37181
0d5e8ae18924
8149662: Refactor hotspot/test/gc/g1/plab/lib/LogParser.java
mchernov
parents:
37163
diff
changeset
|
111 |
final PlabReport report = log.getEntries(); |
35885 | 112 |
|
37181
0d5e8ae18924
8149662: Refactor hotspot/test/gc/g1/plab/lib/LogParser.java
mchernov
parents:
37163
diff
changeset
|
113 |
final List<Long> plabSizes = report.entryStream() |
0d5e8ae18924
8149662: Refactor hotspot/test/gc/g1/plab/lib/LogParser.java
mchernov
parents:
37163
diff
changeset
|
114 |
.map(item -> item.getValue() |
0d5e8ae18924
8149662: Refactor hotspot/test/gc/g1/plab/lib/LogParser.java
mchernov
parents:
37163
diff
changeset
|
115 |
.get(LogParser.ReportType.SURVIVOR_STATS) |
0d5e8ae18924
8149662: Refactor hotspot/test/gc/g1/plab/lib/LogParser.java
mchernov
parents:
37163
diff
changeset
|
116 |
.get(PLAB_SIZE_FIELD_NAME) |
0d5e8ae18924
8149662: Refactor hotspot/test/gc/g1/plab/lib/LogParser.java
mchernov
parents:
37163
diff
changeset
|
117 |
) |
0d5e8ae18924
8149662: Refactor hotspot/test/gc/g1/plab/lib/LogParser.java
mchernov
parents:
37163
diff
changeset
|
118 |
.collect(Collectors.toList()); |
35885 | 119 |
|
120 |
// Check that desired plab size was changed during iterations. |
|
37061
f4f1c40edfd9
8150183: gc/g1/plab/TestPLABResize.java - previous PLAB size should be less than current
mchernov
parents:
36616
diff
changeset
|
121 |
// The test case does 3 rounds of allocations. The second round of N allocations and GC's |
f4f1c40edfd9
8150183: gc/g1/plab/TestPLABResize.java - previous PLAB size should be less than current
mchernov
parents:
36616
diff
changeset
|
122 |
// has a decreasing size of allocations so that iterations N to 2*N -1 will be of decreasing size. |
f4f1c40edfd9
8150183: gc/g1/plab/TestPLABResize.java - previous PLAB size should be less than current
mchernov
parents:
36616
diff
changeset
|
123 |
// The third round with iterations 2*N to 3*N -1 has increasing sizes of allocation. |
38726
2c99beca1dd8
8157452: [TESTBUG] PLAB tests don't handle unexpected GC
mchernov
parents:
38152
diff
changeset
|
124 |
if ( plabSizes.size() != testCase.iterations * 3 ) { |
2c99beca1dd8
8157452: [TESTBUG] PLAB tests don't handle unexpected GC
mchernov
parents:
38152
diff
changeset
|
125 |
System.out.println(output); |
2c99beca1dd8
8157452: [TESTBUG] PLAB tests don't handle unexpected GC
mchernov
parents:
38152
diff
changeset
|
126 |
throw new RuntimeException ("Expects for " + testCase.iterations * 3 + " PLAB entries in log, found " + plabSizes.size()); |
2c99beca1dd8
8157452: [TESTBUG] PLAB tests don't handle unexpected GC
mchernov
parents:
38152
diff
changeset
|
127 |
} |
2c99beca1dd8
8157452: [TESTBUG] PLAB tests don't handle unexpected GC
mchernov
parents:
38152
diff
changeset
|
128 |
|
37061
f4f1c40edfd9
8150183: gc/g1/plab/TestPLABResize.java - previous PLAB size should be less than current
mchernov
parents:
36616
diff
changeset
|
129 |
long startDesiredPLABSize = plabSizes.get(testCase.getIterations()); |
f4f1c40edfd9
8150183: gc/g1/plab/TestPLABResize.java - previous PLAB size should be less than current
mchernov
parents:
36616
diff
changeset
|
130 |
long endDesiredPLABSize = plabSizes.get(testCase.getIterations() * 2 - 1); |
35885 | 131 |
|
37061
f4f1c40edfd9
8150183: gc/g1/plab/TestPLABResize.java - previous PLAB size should be less than current
mchernov
parents:
36616
diff
changeset
|
132 |
if (startDesiredPLABSize < endDesiredPLABSize) { |
f4f1c40edfd9
8150183: gc/g1/plab/TestPLABResize.java - previous PLAB size should be less than current
mchernov
parents:
36616
diff
changeset
|
133 |
System.out.println(output); |
f4f1c40edfd9
8150183: gc/g1/plab/TestPLABResize.java - previous PLAB size should be less than current
mchernov
parents:
36616
diff
changeset
|
134 |
throw new RuntimeException("Test failed! Expect that initial PLAB size should be greater than checked. Initial size: " + startDesiredPLABSize + " Checked size:" + endDesiredPLABSize); |
35885 | 135 |
} |
136 |
||
37061
f4f1c40edfd9
8150183: gc/g1/plab/TestPLABResize.java - previous PLAB size should be less than current
mchernov
parents:
36616
diff
changeset
|
137 |
startDesiredPLABSize = plabSizes.get(testCase.getIterations() * 2); |
f4f1c40edfd9
8150183: gc/g1/plab/TestPLABResize.java - previous PLAB size should be less than current
mchernov
parents:
36616
diff
changeset
|
138 |
endDesiredPLABSize = plabSizes.get(testCase.getIterations() * 3 - 1); |
f4f1c40edfd9
8150183: gc/g1/plab/TestPLABResize.java - previous PLAB size should be less than current
mchernov
parents:
36616
diff
changeset
|
139 |
|
f4f1c40edfd9
8150183: gc/g1/plab/TestPLABResize.java - previous PLAB size should be less than current
mchernov
parents:
36616
diff
changeset
|
140 |
if (startDesiredPLABSize > endDesiredPLABSize) { |
f4f1c40edfd9
8150183: gc/g1/plab/TestPLABResize.java - previous PLAB size should be less than current
mchernov
parents:
36616
diff
changeset
|
141 |
System.out.println(output); |
f4f1c40edfd9
8150183: gc/g1/plab/TestPLABResize.java - previous PLAB size should be less than current
mchernov
parents:
36616
diff
changeset
|
142 |
throw new RuntimeException("Test failed! Expect that initial PLAB size should be less than checked. Initial size: " + startDesiredPLABSize + " Checked size:" + endDesiredPLABSize); |
35885 | 143 |
} |
144 |
||
145 |
System.out.println("Test passed!"); |
|
146 |
} |
|
147 |
||
148 |
/** |
|
149 |
* Description of one test case. |
|
150 |
*/ |
|
151 |
private static class TestCase { |
|
152 |
||
153 |
private final int wastePct; |
|
154 |
private final int chunkSize; |
|
155 |
private final int parGCThreads; |
|
156 |
private final int iterations; |
|
157 |
||
158 |
/** |
|
159 |
* @param wastePct |
|
160 |
* ParallelGCBufferWastePct |
|
161 |
* @param chunkSize |
|
162 |
* requested object size for memory consumption |
|
163 |
* @param parGCThreads |
|
164 |
* -XX:ParallelGCThreads |
|
165 |
* @param iterations |
|
166 |
* |
|
167 |
*/ |
|
168 |
public TestCase(int wastePct, |
|
169 |
int chunkSize, |
|
170 |
int parGCThreads, |
|
171 |
int iterations |
|
172 |
) { |
|
173 |
if (wastePct == 0 || chunkSize == 0 || parGCThreads == 0 || iterations == 0) { |
|
174 |
throw new IllegalArgumentException("Parameters should not be 0"); |
|
175 |
} |
|
176 |
this.wastePct = wastePct; |
|
177 |
||
178 |
this.chunkSize = chunkSize; |
|
179 |
this.parGCThreads = parGCThreads; |
|
180 |
this.iterations = iterations; |
|
181 |
} |
|
182 |
||
183 |
/** |
|
184 |
* Convert current TestCase to List of options. |
|
185 |
* |
|
186 |
* @return |
|
187 |
* List of options |
|
188 |
*/ |
|
189 |
public List<String> toOptions() { |
|
190 |
return Arrays.asList("-XX:ParallelGCThreads=" + parGCThreads, |
|
191 |
"-XX:ParallelGCBufferWastePct=" + wastePct, |
|
192 |
"-XX:+ResizePLAB", |
|
193 |
"-Dchunk.size=" + chunkSize, |
|
194 |
"-Diterations=" + iterations, |
|
195 |
"-XX:NewSize=16m", |
|
196 |
"-XX:MaxNewSize=16m" |
|
197 |
); |
|
198 |
} |
|
199 |
||
200 |
/** |
|
201 |
* Print details about test case. |
|
202 |
*/ |
|
203 |
public void print(PrintStream out) { |
|
204 |
out.println("Test case details:"); |
|
205 |
out.println(" Parallel GC buffer waste pct : " + wastePct); |
|
206 |
out.println(" Chunk size : " + chunkSize); |
|
207 |
out.println(" Parallel GC threads : " + parGCThreads); |
|
208 |
out.println(" Iterations: " + iterations); |
|
209 |
} |
|
210 |
||
211 |
/** |
|
212 |
* @return iterations |
|
213 |
*/ |
|
214 |
public int getIterations() { |
|
215 |
return iterations; |
|
216 |
} |
|
217 |
} |
|
218 |
} |