author | lkorinth |
Wed, 13 Nov 2019 11:37:29 +0100 | |
changeset 59053 | ba6c248cae19 |
parent 55610 | 47fdb5b0fa41 |
permissions | -rw-r--r-- |
32625
054d452e4e06
8081317: [NEWTEST] documented GC ratio tuning and new size options should be covered by regression tests
mchernov
parents:
diff
changeset
|
1 |
/* |
53523
4c5184c56dc2
8214799: Add package declaration to each JTREG test case in the gc folder
lkorinth
parents:
52925
diff
changeset
|
2 |
* Copyright (c) 2015, 2019, Oracle and/or its affiliates. All rights reserved. |
41705
332239c052cc
8165687: Fix license and copyright headers in jd9 under hotspot/test
stsmirno
parents:
40631
diff
changeset
|
3 |
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. |
332239c052cc
8165687: Fix license and copyright headers in jd9 under hotspot/test
stsmirno
parents:
40631
diff
changeset
|
4 |
* |
332239c052cc
8165687: Fix license and copyright headers in jd9 under hotspot/test
stsmirno
parents:
40631
diff
changeset
|
5 |
* This code is free software; you can redistribute it and/or modify it |
332239c052cc
8165687: Fix license and copyright headers in jd9 under hotspot/test
stsmirno
parents:
40631
diff
changeset
|
6 |
* under the terms of the GNU General Public License version 2 only, as |
332239c052cc
8165687: Fix license and copyright headers in jd9 under hotspot/test
stsmirno
parents:
40631
diff
changeset
|
7 |
* published by the Free Software Foundation. |
332239c052cc
8165687: Fix license and copyright headers in jd9 under hotspot/test
stsmirno
parents:
40631
diff
changeset
|
8 |
* |
332239c052cc
8165687: Fix license and copyright headers in jd9 under hotspot/test
stsmirno
parents:
40631
diff
changeset
|
9 |
* This code is distributed in the hope that it will be useful, but WITHOUT |
332239c052cc
8165687: Fix license and copyright headers in jd9 under hotspot/test
stsmirno
parents:
40631
diff
changeset
|
10 |
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or |
332239c052cc
8165687: Fix license and copyright headers in jd9 under hotspot/test
stsmirno
parents:
40631
diff
changeset
|
11 |
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License |
332239c052cc
8165687: Fix license and copyright headers in jd9 under hotspot/test
stsmirno
parents:
40631
diff
changeset
|
12 |
* version 2 for more details (a copy is included in the LICENSE file that |
332239c052cc
8165687: Fix license and copyright headers in jd9 under hotspot/test
stsmirno
parents:
40631
diff
changeset
|
13 |
* accompanied this code). |
332239c052cc
8165687: Fix license and copyright headers in jd9 under hotspot/test
stsmirno
parents:
40631
diff
changeset
|
14 |
* |
332239c052cc
8165687: Fix license and copyright headers in jd9 under hotspot/test
stsmirno
parents:
40631
diff
changeset
|
15 |
* You should have received a copy of the GNU General Public License version |
332239c052cc
8165687: Fix license and copyright headers in jd9 under hotspot/test
stsmirno
parents:
40631
diff
changeset
|
16 |
* 2 along with this work; if not, write to the Free Software Foundation, |
332239c052cc
8165687: Fix license and copyright headers in jd9 under hotspot/test
stsmirno
parents:
40631
diff
changeset
|
17 |
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. |
332239c052cc
8165687: Fix license and copyright headers in jd9 under hotspot/test
stsmirno
parents:
40631
diff
changeset
|
18 |
* |
332239c052cc
8165687: Fix license and copyright headers in jd9 under hotspot/test
stsmirno
parents:
40631
diff
changeset
|
19 |
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA |
332239c052cc
8165687: Fix license and copyright headers in jd9 under hotspot/test
stsmirno
parents:
40631
diff
changeset
|
20 |
* or visit www.oracle.com if you need additional information or have any |
332239c052cc
8165687: Fix license and copyright headers in jd9 under hotspot/test
stsmirno
parents:
40631
diff
changeset
|
21 |
* questions. |
332239c052cc
8165687: Fix license and copyright headers in jd9 under hotspot/test
stsmirno
parents:
40631
diff
changeset
|
22 |
*/ |
32625
054d452e4e06
8081317: [NEWTEST] documented GC ratio tuning and new size options should be covered by regression tests
mchernov
parents:
diff
changeset
|
23 |
|
53523
4c5184c56dc2
8214799: Add package declaration to each JTREG test case in the gc folder
lkorinth
parents:
52925
diff
changeset
|
24 |
package gc.arguments; |
4c5184c56dc2
8214799: Add package declaration to each JTREG test case in the gc folder
lkorinth
parents:
52925
diff
changeset
|
25 |
|
32625
054d452e4e06
8081317: [NEWTEST] documented GC ratio tuning and new size options should be covered by regression tests
mchernov
parents:
diff
changeset
|
26 |
/* |
054d452e4e06
8081317: [NEWTEST] documented GC ratio tuning and new size options should be covered by regression tests
mchernov
parents:
diff
changeset
|
27 |
* @test TestSurvivorRatioFlag |
054d452e4e06
8081317: [NEWTEST] documented GC ratio tuning and new size options should be covered by regression tests
mchernov
parents:
diff
changeset
|
28 |
* @key gc |
054d452e4e06
8081317: [NEWTEST] documented GC ratio tuning and new size options should be covered by regression tests
mchernov
parents:
diff
changeset
|
29 |
* @summary Verify that actual survivor ratio is equal to specified SurvivorRatio value |
52925
9c18c9d839d3
8214259: Implementation: JEP 189: Shenandoah: A Low-Pause-Time Garbage Collector (Experimental)
rkennke
parents:
50525
diff
changeset
|
30 |
* @requires vm.gc != "Z" & vm.gc != "Shenandoah" |
40631
ed82623d7831
8157957: ClassNotFoundException: jdk.test.lib.JDKToolFinder
ctornqvi
parents:
40244
diff
changeset
|
31 |
* @library /test/lib |
53523
4c5184c56dc2
8214799: Add package declaration to each JTREG test case in the gc folder
lkorinth
parents:
52925
diff
changeset
|
32 |
* @library / |
36851 | 33 |
* @modules java.base/jdk.internal.misc |
32625
054d452e4e06
8081317: [NEWTEST] documented GC ratio tuning and new size options should be covered by regression tests
mchernov
parents:
diff
changeset
|
34 |
* java.management |
40631
ed82623d7831
8157957: ClassNotFoundException: jdk.test.lib.JDKToolFinder
ctornqvi
parents:
40244
diff
changeset
|
35 |
* @build sun.hotspot.WhiteBox |
48791
6e079ff6c83c
8186635: ClassFileInstaller should be run as a driver
iignatyev
parents:
47216
diff
changeset
|
36 |
* @run driver ClassFileInstaller sun.hotspot.WhiteBox |
53523
4c5184c56dc2
8214799: Add package declaration to each JTREG test case in the gc folder
lkorinth
parents:
52925
diff
changeset
|
37 |
* @run driver gc.arguments.TestSurvivorRatioFlag |
32625
054d452e4e06
8081317: [NEWTEST] documented GC ratio tuning and new size options should be covered by regression tests
mchernov
parents:
diff
changeset
|
38 |
*/ |
054d452e4e06
8081317: [NEWTEST] documented GC ratio tuning and new size options should be covered by regression tests
mchernov
parents:
diff
changeset
|
39 |
|
054d452e4e06
8081317: [NEWTEST] documented GC ratio tuning and new size options should be covered by regression tests
mchernov
parents:
diff
changeset
|
40 |
import java.lang.management.MemoryUsage; |
054d452e4e06
8081317: [NEWTEST] documented GC ratio tuning and new size options should be covered by regression tests
mchernov
parents:
diff
changeset
|
41 |
import java.util.Arrays; |
054d452e4e06
8081317: [NEWTEST] documented GC ratio tuning and new size options should be covered by regression tests
mchernov
parents:
diff
changeset
|
42 |
import java.util.Collections; |
054d452e4e06
8081317: [NEWTEST] documented GC ratio tuning and new size options should be covered by regression tests
mchernov
parents:
diff
changeset
|
43 |
import java.util.LinkedList; |
40631
ed82623d7831
8157957: ClassNotFoundException: jdk.test.lib.JDKToolFinder
ctornqvi
parents:
40244
diff
changeset
|
44 |
import jdk.test.lib.process.OutputAnalyzer; |
ed82623d7831
8157957: ClassNotFoundException: jdk.test.lib.JDKToolFinder
ctornqvi
parents:
40244
diff
changeset
|
45 |
import jdk.test.lib.process.ProcessTools; |
32625
054d452e4e06
8081317: [NEWTEST] documented GC ratio tuning and new size options should be covered by regression tests
mchernov
parents:
diff
changeset
|
46 |
import jdk.test.lib.Utils; |
054d452e4e06
8081317: [NEWTEST] documented GC ratio tuning and new size options should be covered by regression tests
mchernov
parents:
diff
changeset
|
47 |
import sun.hotspot.WhiteBox; |
054d452e4e06
8081317: [NEWTEST] documented GC ratio tuning and new size options should be covered by regression tests
mchernov
parents:
diff
changeset
|
48 |
|
054d452e4e06
8081317: [NEWTEST] documented GC ratio tuning and new size options should be covered by regression tests
mchernov
parents:
diff
changeset
|
49 |
public class TestSurvivorRatioFlag { |
054d452e4e06
8081317: [NEWTEST] documented GC ratio tuning and new size options should be covered by regression tests
mchernov
parents:
diff
changeset
|
50 |
|
054d452e4e06
8081317: [NEWTEST] documented GC ratio tuning and new size options should be covered by regression tests
mchernov
parents:
diff
changeset
|
51 |
public static final long M = 1024 * 1024; |
054d452e4e06
8081317: [NEWTEST] documented GC ratio tuning and new size options should be covered by regression tests
mchernov
parents:
diff
changeset
|
52 |
public static final long HEAP_SIZE = 200 * M; |
054d452e4e06
8081317: [NEWTEST] documented GC ratio tuning and new size options should be covered by regression tests
mchernov
parents:
diff
changeset
|
53 |
public static final long NEW_SIZE = 100 * M; |
054d452e4e06
8081317: [NEWTEST] documented GC ratio tuning and new size options should be covered by regression tests
mchernov
parents:
diff
changeset
|
54 |
|
054d452e4e06
8081317: [NEWTEST] documented GC ratio tuning and new size options should be covered by regression tests
mchernov
parents:
diff
changeset
|
55 |
public static void main(String args[]) throws Exception { |
054d452e4e06
8081317: [NEWTEST] documented GC ratio tuning and new size options should be covered by regression tests
mchernov
parents:
diff
changeset
|
56 |
LinkedList<String> options = new LinkedList<>( |
054d452e4e06
8081317: [NEWTEST] documented GC ratio tuning and new size options should be covered by regression tests
mchernov
parents:
diff
changeset
|
57 |
Arrays.asList(Utils.getFilteredTestJavaOpts("-XX:[^ ]*SurvivorRatio=[^ ]+")) |
054d452e4e06
8081317: [NEWTEST] documented GC ratio tuning and new size options should be covered by regression tests
mchernov
parents:
diff
changeset
|
58 |
); |
054d452e4e06
8081317: [NEWTEST] documented GC ratio tuning and new size options should be covered by regression tests
mchernov
parents:
diff
changeset
|
59 |
|
054d452e4e06
8081317: [NEWTEST] documented GC ratio tuning and new size options should be covered by regression tests
mchernov
parents:
diff
changeset
|
60 |
testSurvivorRatio(3, options); |
054d452e4e06
8081317: [NEWTEST] documented GC ratio tuning and new size options should be covered by regression tests
mchernov
parents:
diff
changeset
|
61 |
testSurvivorRatio(6, options); |
054d452e4e06
8081317: [NEWTEST] documented GC ratio tuning and new size options should be covered by regression tests
mchernov
parents:
diff
changeset
|
62 |
testSurvivorRatio(10, options); |
054d452e4e06
8081317: [NEWTEST] documented GC ratio tuning and new size options should be covered by regression tests
mchernov
parents:
diff
changeset
|
63 |
testSurvivorRatio(15, options); |
054d452e4e06
8081317: [NEWTEST] documented GC ratio tuning and new size options should be covered by regression tests
mchernov
parents:
diff
changeset
|
64 |
testSurvivorRatio(20, options); |
054d452e4e06
8081317: [NEWTEST] documented GC ratio tuning and new size options should be covered by regression tests
mchernov
parents:
diff
changeset
|
65 |
} |
054d452e4e06
8081317: [NEWTEST] documented GC ratio tuning and new size options should be covered by regression tests
mchernov
parents:
diff
changeset
|
66 |
|
054d452e4e06
8081317: [NEWTEST] documented GC ratio tuning and new size options should be covered by regression tests
mchernov
parents:
diff
changeset
|
67 |
/** |
054d452e4e06
8081317: [NEWTEST] documented GC ratio tuning and new size options should be covered by regression tests
mchernov
parents:
diff
changeset
|
68 |
* Verify that actual survivor ratio equal to specified. |
054d452e4e06
8081317: [NEWTEST] documented GC ratio tuning and new size options should be covered by regression tests
mchernov
parents:
diff
changeset
|
69 |
* |
054d452e4e06
8081317: [NEWTEST] documented GC ratio tuning and new size options should be covered by regression tests
mchernov
parents:
diff
changeset
|
70 |
* @param ratio survivor ratio that be verified |
054d452e4e06
8081317: [NEWTEST] documented GC ratio tuning and new size options should be covered by regression tests
mchernov
parents:
diff
changeset
|
71 |
* @param options additional options to JVM |
054d452e4e06
8081317: [NEWTEST] documented GC ratio tuning and new size options should be covered by regression tests
mchernov
parents:
diff
changeset
|
72 |
*/ |
054d452e4e06
8081317: [NEWTEST] documented GC ratio tuning and new size options should be covered by regression tests
mchernov
parents:
diff
changeset
|
73 |
public static void testSurvivorRatio(int ratio, LinkedList<String> options) throws Exception { |
054d452e4e06
8081317: [NEWTEST] documented GC ratio tuning and new size options should be covered by regression tests
mchernov
parents:
diff
changeset
|
74 |
|
054d452e4e06
8081317: [NEWTEST] documented GC ratio tuning and new size options should be covered by regression tests
mchernov
parents:
diff
changeset
|
75 |
LinkedList<String> vmOptions = new LinkedList<>(options); |
054d452e4e06
8081317: [NEWTEST] documented GC ratio tuning and new size options should be covered by regression tests
mchernov
parents:
diff
changeset
|
76 |
|
054d452e4e06
8081317: [NEWTEST] documented GC ratio tuning and new size options should be covered by regression tests
mchernov
parents:
diff
changeset
|
77 |
Collections.addAll(vmOptions, |
054d452e4e06
8081317: [NEWTEST] documented GC ratio tuning and new size options should be covered by regression tests
mchernov
parents:
diff
changeset
|
78 |
"-Xbootclasspath/a:.", |
40244
b3055c216762
8136930: Simplify use of module-system options by custom launchers
hseigel
parents:
38152
diff
changeset
|
79 |
"--add-exports=java.base/jdk.internal.misc=ALL-UNNAMED", |
32625
054d452e4e06
8081317: [NEWTEST] documented GC ratio tuning and new size options should be covered by regression tests
mchernov
parents:
diff
changeset
|
80 |
"-XX:+UnlockDiagnosticVMOptions", |
054d452e4e06
8081317: [NEWTEST] documented GC ratio tuning and new size options should be covered by regression tests
mchernov
parents:
diff
changeset
|
81 |
"-XX:+WhiteBoxAPI", |
054d452e4e06
8081317: [NEWTEST] documented GC ratio tuning and new size options should be covered by regression tests
mchernov
parents:
diff
changeset
|
82 |
"-XX:GCLockerEdenExpansionPercent=0", |
054d452e4e06
8081317: [NEWTEST] documented GC ratio tuning and new size options should be covered by regression tests
mchernov
parents:
diff
changeset
|
83 |
"-XX:MaxNewSize=" + NEW_SIZE, |
054d452e4e06
8081317: [NEWTEST] documented GC ratio tuning and new size options should be covered by regression tests
mchernov
parents:
diff
changeset
|
84 |
"-XX:NewSize=" + NEW_SIZE, |
054d452e4e06
8081317: [NEWTEST] documented GC ratio tuning and new size options should be covered by regression tests
mchernov
parents:
diff
changeset
|
85 |
"-Xmx" + HEAP_SIZE, |
054d452e4e06
8081317: [NEWTEST] documented GC ratio tuning and new size options should be covered by regression tests
mchernov
parents:
diff
changeset
|
86 |
"-Xms" + HEAP_SIZE, |
054d452e4e06
8081317: [NEWTEST] documented GC ratio tuning and new size options should be covered by regression tests
mchernov
parents:
diff
changeset
|
87 |
"-XX:SurvivorRatio=" + ratio, |
054d452e4e06
8081317: [NEWTEST] documented GC ratio tuning and new size options should be covered by regression tests
mchernov
parents:
diff
changeset
|
88 |
SurvivorRatioVerifier.class.getName(), |
054d452e4e06
8081317: [NEWTEST] documented GC ratio tuning and new size options should be covered by regression tests
mchernov
parents:
diff
changeset
|
89 |
Integer.toString(ratio) |
054d452e4e06
8081317: [NEWTEST] documented GC ratio tuning and new size options should be covered by regression tests
mchernov
parents:
diff
changeset
|
90 |
); |
054d452e4e06
8081317: [NEWTEST] documented GC ratio tuning and new size options should be covered by regression tests
mchernov
parents:
diff
changeset
|
91 |
|
55610
47fdb5b0fa41
8217170: gc/arguments/TestUseCompressedOopsErgo.java timed out
kbarrett
parents:
53523
diff
changeset
|
92 |
ProcessBuilder procBuilder = GCArguments.createJavaProcessBuilder(vmOptions.toArray(new String[vmOptions.size()])); |
32625
054d452e4e06
8081317: [NEWTEST] documented GC ratio tuning and new size options should be covered by regression tests
mchernov
parents:
diff
changeset
|
93 |
OutputAnalyzer analyzer = new OutputAnalyzer(procBuilder.start()); |
054d452e4e06
8081317: [NEWTEST] documented GC ratio tuning and new size options should be covered by regression tests
mchernov
parents:
diff
changeset
|
94 |
analyzer.shouldHaveExitValue(0); |
054d452e4e06
8081317: [NEWTEST] documented GC ratio tuning and new size options should be covered by regression tests
mchernov
parents:
diff
changeset
|
95 |
} |
054d452e4e06
8081317: [NEWTEST] documented GC ratio tuning and new size options should be covered by regression tests
mchernov
parents:
diff
changeset
|
96 |
|
054d452e4e06
8081317: [NEWTEST] documented GC ratio tuning and new size options should be covered by regression tests
mchernov
parents:
diff
changeset
|
97 |
/** |
054d452e4e06
8081317: [NEWTEST] documented GC ratio tuning and new size options should be covered by regression tests
mchernov
parents:
diff
changeset
|
98 |
* Class that verifies survivor ratio. |
054d452e4e06
8081317: [NEWTEST] documented GC ratio tuning and new size options should be covered by regression tests
mchernov
parents:
diff
changeset
|
99 |
*/ |
054d452e4e06
8081317: [NEWTEST] documented GC ratio tuning and new size options should be covered by regression tests
mchernov
parents:
diff
changeset
|
100 |
public static class SurvivorRatioVerifier { |
054d452e4e06
8081317: [NEWTEST] documented GC ratio tuning and new size options should be covered by regression tests
mchernov
parents:
diff
changeset
|
101 |
|
054d452e4e06
8081317: [NEWTEST] documented GC ratio tuning and new size options should be covered by regression tests
mchernov
parents:
diff
changeset
|
102 |
static WhiteBox wb = WhiteBox.getWhiteBox(); |
054d452e4e06
8081317: [NEWTEST] documented GC ratio tuning and new size options should be covered by regression tests
mchernov
parents:
diff
changeset
|
103 |
|
054d452e4e06
8081317: [NEWTEST] documented GC ratio tuning and new size options should be covered by regression tests
mchernov
parents:
diff
changeset
|
104 |
public static final int MAX_ITERATIONS = 10; |
054d452e4e06
8081317: [NEWTEST] documented GC ratio tuning and new size options should be covered by regression tests
mchernov
parents:
diff
changeset
|
105 |
public static final int ARRAY_LENGTH = 10000; |
054d452e4e06
8081317: [NEWTEST] documented GC ratio tuning and new size options should be covered by regression tests
mchernov
parents:
diff
changeset
|
106 |
public static final int CHUNK_SIZE = 10000; |
054d452e4e06
8081317: [NEWTEST] documented GC ratio tuning and new size options should be covered by regression tests
mchernov
parents:
diff
changeset
|
107 |
|
054d452e4e06
8081317: [NEWTEST] documented GC ratio tuning and new size options should be covered by regression tests
mchernov
parents:
diff
changeset
|
108 |
public static void main(String args[]) throws Exception { |
054d452e4e06
8081317: [NEWTEST] documented GC ratio tuning and new size options should be covered by regression tests
mchernov
parents:
diff
changeset
|
109 |
if (args.length != 1) { |
054d452e4e06
8081317: [NEWTEST] documented GC ratio tuning and new size options should be covered by regression tests
mchernov
parents:
diff
changeset
|
110 |
throw new IllegalArgumentException("Expected 1 arg: <ratio>"); |
054d452e4e06
8081317: [NEWTEST] documented GC ratio tuning and new size options should be covered by regression tests
mchernov
parents:
diff
changeset
|
111 |
} |
054d452e4e06
8081317: [NEWTEST] documented GC ratio tuning and new size options should be covered by regression tests
mchernov
parents:
diff
changeset
|
112 |
final int ratio = Integer.valueOf(args[0]); |
054d452e4e06
8081317: [NEWTEST] documented GC ratio tuning and new size options should be covered by regression tests
mchernov
parents:
diff
changeset
|
113 |
|
054d452e4e06
8081317: [NEWTEST] documented GC ratio tuning and new size options should be covered by regression tests
mchernov
parents:
diff
changeset
|
114 |
AllocationHelper allocator = new AllocationHelper(MAX_ITERATIONS, ARRAY_LENGTH, CHUNK_SIZE, () -> (verifySurvivorRatio(ratio))); |
054d452e4e06
8081317: [NEWTEST] documented GC ratio tuning and new size options should be covered by regression tests
mchernov
parents:
diff
changeset
|
115 |
allocator.allocateMemoryAndVerify(); |
054d452e4e06
8081317: [NEWTEST] documented GC ratio tuning and new size options should be covered by regression tests
mchernov
parents:
diff
changeset
|
116 |
} |
054d452e4e06
8081317: [NEWTEST] documented GC ratio tuning and new size options should be covered by regression tests
mchernov
parents:
diff
changeset
|
117 |
|
054d452e4e06
8081317: [NEWTEST] documented GC ratio tuning and new size options should be covered by regression tests
mchernov
parents:
diff
changeset
|
118 |
/** |
054d452e4e06
8081317: [NEWTEST] documented GC ratio tuning and new size options should be covered by regression tests
mchernov
parents:
diff
changeset
|
119 |
* Verify that actual survivor ratio is equal to expected. |
054d452e4e06
8081317: [NEWTEST] documented GC ratio tuning and new size options should be covered by regression tests
mchernov
parents:
diff
changeset
|
120 |
* Depending on selected young GC we verify that: |
054d452e4e06
8081317: [NEWTEST] documented GC ratio tuning and new size options should be covered by regression tests
mchernov
parents:
diff
changeset
|
121 |
* - for DefNew and ParNew: eden_size / survivor_size is close to expectedRatio; |
054d452e4e06
8081317: [NEWTEST] documented GC ratio tuning and new size options should be covered by regression tests
mchernov
parents:
diff
changeset
|
122 |
* - for PSNew: survivor_size equal to young_gen_size / expectedRatio; |
054d452e4e06
8081317: [NEWTEST] documented GC ratio tuning and new size options should be covered by regression tests
mchernov
parents:
diff
changeset
|
123 |
* - for G1: survivor_regions <= young_list_length / expectedRatio. |
054d452e4e06
8081317: [NEWTEST] documented GC ratio tuning and new size options should be covered by regression tests
mchernov
parents:
diff
changeset
|
124 |
*/ |
054d452e4e06
8081317: [NEWTEST] documented GC ratio tuning and new size options should be covered by regression tests
mchernov
parents:
diff
changeset
|
125 |
public static Void verifySurvivorRatio(int expectedRatio) { |
054d452e4e06
8081317: [NEWTEST] documented GC ratio tuning and new size options should be covered by regression tests
mchernov
parents:
diff
changeset
|
126 |
GCTypes.YoungGCType type = GCTypes.YoungGCType.getYoungGCType(); |
054d452e4e06
8081317: [NEWTEST] documented GC ratio tuning and new size options should be covered by regression tests
mchernov
parents:
diff
changeset
|
127 |
switch (type) { |
054d452e4e06
8081317: [NEWTEST] documented GC ratio tuning and new size options should be covered by regression tests
mchernov
parents:
diff
changeset
|
128 |
case DefNew: |
054d452e4e06
8081317: [NEWTEST] documented GC ratio tuning and new size options should be covered by regression tests
mchernov
parents:
diff
changeset
|
129 |
verifyDefNewSurvivorRatio(expectedRatio); |
054d452e4e06
8081317: [NEWTEST] documented GC ratio tuning and new size options should be covered by regression tests
mchernov
parents:
diff
changeset
|
130 |
break; |
054d452e4e06
8081317: [NEWTEST] documented GC ratio tuning and new size options should be covered by regression tests
mchernov
parents:
diff
changeset
|
131 |
case PSNew: |
054d452e4e06
8081317: [NEWTEST] documented GC ratio tuning and new size options should be covered by regression tests
mchernov
parents:
diff
changeset
|
132 |
verifyPSSurvivorRatio(expectedRatio); |
054d452e4e06
8081317: [NEWTEST] documented GC ratio tuning and new size options should be covered by regression tests
mchernov
parents:
diff
changeset
|
133 |
break; |
054d452e4e06
8081317: [NEWTEST] documented GC ratio tuning and new size options should be covered by regression tests
mchernov
parents:
diff
changeset
|
134 |
case G1: |
054d452e4e06
8081317: [NEWTEST] documented GC ratio tuning and new size options should be covered by regression tests
mchernov
parents:
diff
changeset
|
135 |
verifyG1SurvivorRatio(expectedRatio); |
054d452e4e06
8081317: [NEWTEST] documented GC ratio tuning and new size options should be covered by regression tests
mchernov
parents:
diff
changeset
|
136 |
break; |
054d452e4e06
8081317: [NEWTEST] documented GC ratio tuning and new size options should be covered by regression tests
mchernov
parents:
diff
changeset
|
137 |
default: |
054d452e4e06
8081317: [NEWTEST] documented GC ratio tuning and new size options should be covered by regression tests
mchernov
parents:
diff
changeset
|
138 |
throw new RuntimeException("Unexpected young GC type"); |
054d452e4e06
8081317: [NEWTEST] documented GC ratio tuning and new size options should be covered by regression tests
mchernov
parents:
diff
changeset
|
139 |
} |
054d452e4e06
8081317: [NEWTEST] documented GC ratio tuning and new size options should be covered by regression tests
mchernov
parents:
diff
changeset
|
140 |
return null; |
054d452e4e06
8081317: [NEWTEST] documented GC ratio tuning and new size options should be covered by regression tests
mchernov
parents:
diff
changeset
|
141 |
} |
054d452e4e06
8081317: [NEWTEST] documented GC ratio tuning and new size options should be covered by regression tests
mchernov
parents:
diff
changeset
|
142 |
|
054d452e4e06
8081317: [NEWTEST] documented GC ratio tuning and new size options should be covered by regression tests
mchernov
parents:
diff
changeset
|
143 |
private static void verifyDefNewSurvivorRatio(int expectedRatio) { |
054d452e4e06
8081317: [NEWTEST] documented GC ratio tuning and new size options should be covered by regression tests
mchernov
parents:
diff
changeset
|
144 |
MemoryUsage edenUsage = HeapRegionUsageTool.getEdenUsage(); |
054d452e4e06
8081317: [NEWTEST] documented GC ratio tuning and new size options should be covered by regression tests
mchernov
parents:
diff
changeset
|
145 |
MemoryUsage survivorUsage = HeapRegionUsageTool.getSurvivorUsage(); |
054d452e4e06
8081317: [NEWTEST] documented GC ratio tuning and new size options should be covered by regression tests
mchernov
parents:
diff
changeset
|
146 |
|
054d452e4e06
8081317: [NEWTEST] documented GC ratio tuning and new size options should be covered by regression tests
mchernov
parents:
diff
changeset
|
147 |
int actualRatio = (int) (edenUsage.getCommitted() / survivorUsage.getCommitted()); |
054d452e4e06
8081317: [NEWTEST] documented GC ratio tuning and new size options should be covered by regression tests
mchernov
parents:
diff
changeset
|
148 |
if (Math.abs(actualRatio - expectedRatio) > 1) { |
054d452e4e06
8081317: [NEWTEST] documented GC ratio tuning and new size options should be covered by regression tests
mchernov
parents:
diff
changeset
|
149 |
throw new RuntimeException("Expected survivor ratio is: " + expectedRatio |
054d452e4e06
8081317: [NEWTEST] documented GC ratio tuning and new size options should be covered by regression tests
mchernov
parents:
diff
changeset
|
150 |
+ ", but observed ratio is: " + actualRatio); |
054d452e4e06
8081317: [NEWTEST] documented GC ratio tuning and new size options should be covered by regression tests
mchernov
parents:
diff
changeset
|
151 |
} |
054d452e4e06
8081317: [NEWTEST] documented GC ratio tuning and new size options should be covered by regression tests
mchernov
parents:
diff
changeset
|
152 |
} |
054d452e4e06
8081317: [NEWTEST] documented GC ratio tuning and new size options should be covered by regression tests
mchernov
parents:
diff
changeset
|
153 |
|
054d452e4e06
8081317: [NEWTEST] documented GC ratio tuning and new size options should be covered by regression tests
mchernov
parents:
diff
changeset
|
154 |
private static void verifyPSSurvivorRatio(int expectedRatio) { |
054d452e4e06
8081317: [NEWTEST] documented GC ratio tuning and new size options should be covered by regression tests
mchernov
parents:
diff
changeset
|
155 |
MemoryUsage edenUsage = HeapRegionUsageTool.getEdenUsage(); |
054d452e4e06
8081317: [NEWTEST] documented GC ratio tuning and new size options should be covered by regression tests
mchernov
parents:
diff
changeset
|
156 |
MemoryUsage survivorUsage = HeapRegionUsageTool.getSurvivorUsage(); |
054d452e4e06
8081317: [NEWTEST] documented GC ratio tuning and new size options should be covered by regression tests
mchernov
parents:
diff
changeset
|
157 |
|
054d452e4e06
8081317: [NEWTEST] documented GC ratio tuning and new size options should be covered by regression tests
mchernov
parents:
diff
changeset
|
158 |
long youngGenSize = edenUsage.getMax() + 2 * survivorUsage.getMax(); |
054d452e4e06
8081317: [NEWTEST] documented GC ratio tuning and new size options should be covered by regression tests
mchernov
parents:
diff
changeset
|
159 |
// for Paralle GC Min/InitialSurvivorRatio = SurvivorRatio + 2 |
054d452e4e06
8081317: [NEWTEST] documented GC ratio tuning and new size options should be covered by regression tests
mchernov
parents:
diff
changeset
|
160 |
long expectedSize = HeapRegionUsageTool.alignDown(youngGenSize / (expectedRatio + 2), |
054d452e4e06
8081317: [NEWTEST] documented GC ratio tuning and new size options should be covered by regression tests
mchernov
parents:
diff
changeset
|
161 |
wb.psHeapGenerationAlignment()); |
054d452e4e06
8081317: [NEWTEST] documented GC ratio tuning and new size options should be covered by regression tests
mchernov
parents:
diff
changeset
|
162 |
|
054d452e4e06
8081317: [NEWTEST] documented GC ratio tuning and new size options should be covered by regression tests
mchernov
parents:
diff
changeset
|
163 |
if (expectedSize != survivorUsage.getCommitted()) { |
054d452e4e06
8081317: [NEWTEST] documented GC ratio tuning and new size options should be covered by regression tests
mchernov
parents:
diff
changeset
|
164 |
throw new RuntimeException("Expected survivor size is: " + expectedSize |
054d452e4e06
8081317: [NEWTEST] documented GC ratio tuning and new size options should be covered by regression tests
mchernov
parents:
diff
changeset
|
165 |
+ ", but observed size is: " + survivorUsage.getCommitted()); |
054d452e4e06
8081317: [NEWTEST] documented GC ratio tuning and new size options should be covered by regression tests
mchernov
parents:
diff
changeset
|
166 |
} |
054d452e4e06
8081317: [NEWTEST] documented GC ratio tuning and new size options should be covered by regression tests
mchernov
parents:
diff
changeset
|
167 |
} |
054d452e4e06
8081317: [NEWTEST] documented GC ratio tuning and new size options should be covered by regression tests
mchernov
parents:
diff
changeset
|
168 |
|
054d452e4e06
8081317: [NEWTEST] documented GC ratio tuning and new size options should be covered by regression tests
mchernov
parents:
diff
changeset
|
169 |
private static void verifyG1SurvivorRatio(int expectedRatio) { |
054d452e4e06
8081317: [NEWTEST] documented GC ratio tuning and new size options should be covered by regression tests
mchernov
parents:
diff
changeset
|
170 |
MemoryUsage survivorUsage = HeapRegionUsageTool.getSurvivorUsage(); |
054d452e4e06
8081317: [NEWTEST] documented GC ratio tuning and new size options should be covered by regression tests
mchernov
parents:
diff
changeset
|
171 |
|
054d452e4e06
8081317: [NEWTEST] documented GC ratio tuning and new size options should be covered by regression tests
mchernov
parents:
diff
changeset
|
172 |
int regionSize = wb.g1RegionSize(); |
054d452e4e06
8081317: [NEWTEST] documented GC ratio tuning and new size options should be covered by regression tests
mchernov
parents:
diff
changeset
|
173 |
int youngListLength = (int) Math.max(NEW_SIZE / regionSize, 1); |
054d452e4e06
8081317: [NEWTEST] documented GC ratio tuning and new size options should be covered by regression tests
mchernov
parents:
diff
changeset
|
174 |
int expectedSurvivorRegions = (int) Math.ceil(youngListLength / (double) expectedRatio); |
054d452e4e06
8081317: [NEWTEST] documented GC ratio tuning and new size options should be covered by regression tests
mchernov
parents:
diff
changeset
|
175 |
int observedSurvivorRegions = (int) (survivorUsage.getCommitted() / regionSize); |
054d452e4e06
8081317: [NEWTEST] documented GC ratio tuning and new size options should be covered by regression tests
mchernov
parents:
diff
changeset
|
176 |
|
054d452e4e06
8081317: [NEWTEST] documented GC ratio tuning and new size options should be covered by regression tests
mchernov
parents:
diff
changeset
|
177 |
if (expectedSurvivorRegions < observedSurvivorRegions) { |
054d452e4e06
8081317: [NEWTEST] documented GC ratio tuning and new size options should be covered by regression tests
mchernov
parents:
diff
changeset
|
178 |
throw new RuntimeException("Expected amount of G1 survivor regions is " |
054d452e4e06
8081317: [NEWTEST] documented GC ratio tuning and new size options should be covered by regression tests
mchernov
parents:
diff
changeset
|
179 |
+ expectedSurvivorRegions + ", but observed " |
054d452e4e06
8081317: [NEWTEST] documented GC ratio tuning and new size options should be covered by regression tests
mchernov
parents:
diff
changeset
|
180 |
+ observedSurvivorRegions); |
054d452e4e06
8081317: [NEWTEST] documented GC ratio tuning and new size options should be covered by regression tests
mchernov
parents:
diff
changeset
|
181 |
} |
054d452e4e06
8081317: [NEWTEST] documented GC ratio tuning and new size options should be covered by regression tests
mchernov
parents:
diff
changeset
|
182 |
} |
054d452e4e06
8081317: [NEWTEST] documented GC ratio tuning and new size options should be covered by regression tests
mchernov
parents:
diff
changeset
|
183 |
} |
054d452e4e06
8081317: [NEWTEST] documented GC ratio tuning and new size options should be covered by regression tests
mchernov
parents:
diff
changeset
|
184 |
} |