author | hannesw |
Tue, 10 Jan 2017 15:27:14 +0100 | |
changeset 43116 | 20c7572ce2a5 |
parent 41705 | 332239c052cc |
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 |
/* |
41705
332239c052cc
8165687: Fix license and copyright headers in jd9 under hotspot/test
stsmirno
parents:
40631
diff
changeset
|
2 |
* Copyright (c) 2015, 2016, Oracle and/or its affiliates. All rights reserved. |
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 |
|
054d452e4e06
8081317: [NEWTEST] documented GC ratio tuning and new size options should be covered by regression tests
mchernov
parents:
diff
changeset
|
24 |
/* |
054d452e4e06
8081317: [NEWTEST] documented GC ratio tuning and new size options should be covered by regression tests
mchernov
parents:
diff
changeset
|
25 |
* @test TestNewRatioFlag |
054d452e4e06
8081317: [NEWTEST] documented GC ratio tuning and new size options should be covered by regression tests
mchernov
parents:
diff
changeset
|
26 |
* @key gc |
054d452e4e06
8081317: [NEWTEST] documented GC ratio tuning and new size options should be covered by regression tests
mchernov
parents:
diff
changeset
|
27 |
* @bug 8025166 |
054d452e4e06
8081317: [NEWTEST] documented GC ratio tuning and new size options should be covered by regression tests
mchernov
parents:
diff
changeset
|
28 |
* @summary Verify that heap devided among generations according to NewRatio |
40631
ed82623d7831
8157957: ClassNotFoundException: jdk.test.lib.JDKToolFinder
ctornqvi
parents:
36851
diff
changeset
|
29 |
* @library /test/lib |
36851 | 30 |
* @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
|
31 |
* java.management |
40631
ed82623d7831
8157957: ClassNotFoundException: jdk.test.lib.JDKToolFinder
ctornqvi
parents:
36851
diff
changeset
|
32 |
* @build sun.hotspot.WhiteBox |
32625
054d452e4e06
8081317: [NEWTEST] documented GC ratio tuning and new size options should be covered by regression tests
mchernov
parents:
diff
changeset
|
33 |
* @run main ClassFileInstaller sun.hotspot.WhiteBox |
054d452e4e06
8081317: [NEWTEST] documented GC ratio tuning and new size options should be covered by regression tests
mchernov
parents:
diff
changeset
|
34 |
* @run driver TestNewRatioFlag |
054d452e4e06
8081317: [NEWTEST] documented GC ratio tuning and new size options should be covered by regression tests
mchernov
parents:
diff
changeset
|
35 |
*/ |
054d452e4e06
8081317: [NEWTEST] documented GC ratio tuning and new size options should be covered by regression tests
mchernov
parents:
diff
changeset
|
36 |
|
054d452e4e06
8081317: [NEWTEST] documented GC ratio tuning and new size options should be covered by regression tests
mchernov
parents:
diff
changeset
|
37 |
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
|
38 |
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
|
39 |
import java.util.LinkedList; |
40631
ed82623d7831
8157957: ClassNotFoundException: jdk.test.lib.JDKToolFinder
ctornqvi
parents:
36851
diff
changeset
|
40 |
import jdk.test.lib.process.ProcessTools; |
ed82623d7831
8157957: ClassNotFoundException: jdk.test.lib.JDKToolFinder
ctornqvi
parents:
36851
diff
changeset
|
41 |
import jdk.test.lib.process.OutputAnalyzer; |
32625
054d452e4e06
8081317: [NEWTEST] documented GC ratio tuning and new size options should be covered by regression tests
mchernov
parents:
diff
changeset
|
42 |
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
|
43 |
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
|
44 |
|
054d452e4e06
8081317: [NEWTEST] documented GC ratio tuning and new size options should be covered by regression tests
mchernov
parents:
diff
changeset
|
45 |
public class TestNewRatioFlag { |
054d452e4e06
8081317: [NEWTEST] documented GC ratio tuning and new size options should be covered by regression tests
mchernov
parents:
diff
changeset
|
46 |
|
054d452e4e06
8081317: [NEWTEST] documented GC ratio tuning and new size options should be covered by regression tests
mchernov
parents:
diff
changeset
|
47 |
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
|
48 |
public static final long HEAP_SIZE = 100 * M; |
054d452e4e06
8081317: [NEWTEST] documented GC ratio tuning and new size options should be covered by regression tests
mchernov
parents:
diff
changeset
|
49 |
|
054d452e4e06
8081317: [NEWTEST] documented GC ratio tuning and new size options should be covered by regression tests
mchernov
parents:
diff
changeset
|
50 |
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
|
51 |
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
|
52 |
Arrays.asList(Utils.getFilteredTestJavaOpts("(-XX:[^ ]*NewSize=[^ ]+)|(-Xm[ns][^ ]+)")) |
054d452e4e06
8081317: [NEWTEST] documented GC ratio tuning and new size options should be covered by regression tests
mchernov
parents:
diff
changeset
|
53 |
); |
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 |
testNewRatio(4, options); |
054d452e4e06
8081317: [NEWTEST] documented GC ratio tuning and new size options should be covered by regression tests
mchernov
parents:
diff
changeset
|
56 |
testNewRatio(6, options); |
054d452e4e06
8081317: [NEWTEST] documented GC ratio tuning and new size options should be covered by regression tests
mchernov
parents:
diff
changeset
|
57 |
testNewRatio(10, options); |
054d452e4e06
8081317: [NEWTEST] documented GC ratio tuning and new size options should be covered by regression tests
mchernov
parents:
diff
changeset
|
58 |
testNewRatio(15, options); |
054d452e4e06
8081317: [NEWTEST] documented GC ratio tuning and new size options should be covered by regression tests
mchernov
parents:
diff
changeset
|
59 |
testNewRatio(20, options); |
054d452e4e06
8081317: [NEWTEST] documented GC ratio tuning and new size options should be covered by regression tests
mchernov
parents:
diff
changeset
|
60 |
} |
054d452e4e06
8081317: [NEWTEST] documented GC ratio tuning and new size options should be covered by regression tests
mchernov
parents:
diff
changeset
|
61 |
|
054d452e4e06
8081317: [NEWTEST] documented GC ratio tuning and new size options should be covered by regression tests
mchernov
parents:
diff
changeset
|
62 |
/** |
054d452e4e06
8081317: [NEWTEST] documented GC ratio tuning and new size options should be covered by regression tests
mchernov
parents:
diff
changeset
|
63 |
* Verify that actual size of young gen conforms specified NewRatio |
054d452e4e06
8081317: [NEWTEST] documented GC ratio tuning and new size options should be covered by regression tests
mchernov
parents:
diff
changeset
|
64 |
* |
054d452e4e06
8081317: [NEWTEST] documented GC ratio tuning and new size options should be covered by regression tests
mchernov
parents:
diff
changeset
|
65 |
* @param ratio value of NewRatio option |
054d452e4e06
8081317: [NEWTEST] documented GC ratio tuning and new size options should be covered by regression tests
mchernov
parents:
diff
changeset
|
66 |
* @param options additional options for VM |
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 |
public static void testNewRatio(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
|
69 |
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
|
70 |
Collections.addAll(vmOptions, |
054d452e4e06
8081317: [NEWTEST] documented GC ratio tuning and new size options should be covered by regression tests
mchernov
parents:
diff
changeset
|
71 |
"-Xbootclasspath/a:.", |
054d452e4e06
8081317: [NEWTEST] documented GC ratio tuning and new size options should be covered by regression tests
mchernov
parents:
diff
changeset
|
72 |
"-XX:+UnlockDiagnosticVMOptions", |
054d452e4e06
8081317: [NEWTEST] documented GC ratio tuning and new size options should be covered by regression tests
mchernov
parents:
diff
changeset
|
73 |
"-XX:+WhiteBoxAPI", |
054d452e4e06
8081317: [NEWTEST] documented GC ratio tuning and new size options should be covered by regression tests
mchernov
parents:
diff
changeset
|
74 |
"-XX:GCLockerEdenExpansionPercent=0", |
054d452e4e06
8081317: [NEWTEST] documented GC ratio tuning and new size options should be covered by regression tests
mchernov
parents:
diff
changeset
|
75 |
"-Xmx" + HEAP_SIZE, |
054d452e4e06
8081317: [NEWTEST] documented GC ratio tuning and new size options should be covered by regression tests
mchernov
parents:
diff
changeset
|
76 |
"-Xms" + HEAP_SIZE, |
054d452e4e06
8081317: [NEWTEST] documented GC ratio tuning and new size options should be covered by regression tests
mchernov
parents:
diff
changeset
|
77 |
"-XX:NewRatio=" + ratio, |
054d452e4e06
8081317: [NEWTEST] documented GC ratio tuning and new size options should be covered by regression tests
mchernov
parents:
diff
changeset
|
78 |
"-XX:-UseLargePages", |
054d452e4e06
8081317: [NEWTEST] documented GC ratio tuning and new size options should be covered by regression tests
mchernov
parents:
diff
changeset
|
79 |
NewRatioVerifier.class.getName(), |
054d452e4e06
8081317: [NEWTEST] documented GC ratio tuning and new size options should be covered by regression tests
mchernov
parents:
diff
changeset
|
80 |
Integer.toString(ratio) |
054d452e4e06
8081317: [NEWTEST] documented GC ratio tuning and new size options should be covered by regression tests
mchernov
parents:
diff
changeset
|
81 |
); |
054d452e4e06
8081317: [NEWTEST] documented GC ratio tuning and new size options should be covered by regression tests
mchernov
parents:
diff
changeset
|
82 |
|
054d452e4e06
8081317: [NEWTEST] documented GC ratio tuning and new size options should be covered by regression tests
mchernov
parents:
diff
changeset
|
83 |
ProcessBuilder procBuilder = ProcessTools.createJavaProcessBuilder(vmOptions.toArray(new String[vmOptions.size()])); |
054d452e4e06
8081317: [NEWTEST] documented GC ratio tuning and new size options should be covered by regression tests
mchernov
parents:
diff
changeset
|
84 |
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
|
85 |
analyzer.shouldHaveExitValue(0); |
054d452e4e06
8081317: [NEWTEST] documented GC ratio tuning and new size options should be covered by regression tests
mchernov
parents:
diff
changeset
|
86 |
System.out.println(analyzer.getOutput()); |
054d452e4e06
8081317: [NEWTEST] documented GC ratio tuning and new size options should be covered by regression tests
mchernov
parents:
diff
changeset
|
87 |
} |
054d452e4e06
8081317: [NEWTEST] documented GC ratio tuning and new size options should be covered by regression tests
mchernov
parents:
diff
changeset
|
88 |
|
054d452e4e06
8081317: [NEWTEST] documented GC ratio tuning and new size options should be covered by regression tests
mchernov
parents:
diff
changeset
|
89 |
public static class NewRatioVerifier { |
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 |
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
|
92 |
|
054d452e4e06
8081317: [NEWTEST] documented GC ratio tuning and new size options should be covered by regression tests
mchernov
parents:
diff
changeset
|
93 |
public static void main(String args[]) { |
054d452e4e06
8081317: [NEWTEST] documented GC ratio tuning and new size options should be covered by regression tests
mchernov
parents:
diff
changeset
|
94 |
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
|
95 |
throw new IllegalArgumentException("Expected 1 arg: <expectedRatio>"); |
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 |
int expectedRatio = 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
|
98 |
switch (GCTypes.YoungGCType.getYoungGCType()) { |
054d452e4e06
8081317: [NEWTEST] documented GC ratio tuning and new size options should be covered by regression tests
mchernov
parents:
diff
changeset
|
99 |
case DefNew: |
054d452e4e06
8081317: [NEWTEST] documented GC ratio tuning and new size options should be covered by regression tests
mchernov
parents:
diff
changeset
|
100 |
case ParNew: |
054d452e4e06
8081317: [NEWTEST] documented GC ratio tuning and new size options should be covered by regression tests
mchernov
parents:
diff
changeset
|
101 |
verifyDefNewNewRatio(expectedRatio); |
054d452e4e06
8081317: [NEWTEST] documented GC ratio tuning and new size options should be covered by regression tests
mchernov
parents:
diff
changeset
|
102 |
break; |
054d452e4e06
8081317: [NEWTEST] documented GC ratio tuning and new size options should be covered by regression tests
mchernov
parents:
diff
changeset
|
103 |
case PSNew: |
054d452e4e06
8081317: [NEWTEST] documented GC ratio tuning and new size options should be covered by regression tests
mchernov
parents:
diff
changeset
|
104 |
verifyPSNewRatio(expectedRatio); |
054d452e4e06
8081317: [NEWTEST] documented GC ratio tuning and new size options should be covered by regression tests
mchernov
parents:
diff
changeset
|
105 |
break; |
054d452e4e06
8081317: [NEWTEST] documented GC ratio tuning and new size options should be covered by regression tests
mchernov
parents:
diff
changeset
|
106 |
case G1: |
054d452e4e06
8081317: [NEWTEST] documented GC ratio tuning and new size options should be covered by regression tests
mchernov
parents:
diff
changeset
|
107 |
verifyG1NewRatio(expectedRatio); |
054d452e4e06
8081317: [NEWTEST] documented GC ratio tuning and new size options should be covered by regression tests
mchernov
parents:
diff
changeset
|
108 |
break; |
054d452e4e06
8081317: [NEWTEST] documented GC ratio tuning and new size options should be covered by regression tests
mchernov
parents:
diff
changeset
|
109 |
default: |
054d452e4e06
8081317: [NEWTEST] documented GC ratio tuning and new size options should be covered by regression tests
mchernov
parents:
diff
changeset
|
110 |
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
|
111 |
} |
054d452e4e06
8081317: [NEWTEST] documented GC ratio tuning and new size options should be covered by regression tests
mchernov
parents:
diff
changeset
|
112 |
} |
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 |
/** |
054d452e4e06
8081317: [NEWTEST] documented GC ratio tuning and new size options should be covered by regression tests
mchernov
parents:
diff
changeset
|
115 |
* Verify NewSize for DefNew and ParNew collectors. |
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 |
* Compare expected NewSize calculated according to sizing policies used by DefNew |
054d452e4e06
8081317: [NEWTEST] documented GC ratio tuning and new size options should be covered by regression tests
mchernov
parents:
diff
changeset
|
118 |
* with NewSize value reported by MemoryPoolMXBeans. |
054d452e4e06
8081317: [NEWTEST] documented GC ratio tuning and new size options should be covered by regression tests
mchernov
parents:
diff
changeset
|
119 |
*/ |
054d452e4e06
8081317: [NEWTEST] documented GC ratio tuning and new size options should be covered by regression tests
mchernov
parents:
diff
changeset
|
120 |
public static void verifyDefNewNewRatio(int expectedRatio) { |
054d452e4e06
8081317: [NEWTEST] documented GC ratio tuning and new size options should be covered by regression tests
mchernov
parents:
diff
changeset
|
121 |
long initEden = HeapRegionUsageTool.getEdenUsage().getInit(); |
054d452e4e06
8081317: [NEWTEST] documented GC ratio tuning and new size options should be covered by regression tests
mchernov
parents:
diff
changeset
|
122 |
long initSurv = HeapRegionUsageTool.getSurvivorUsage().getInit(); |
054d452e4e06
8081317: [NEWTEST] documented GC ratio tuning and new size options should be covered by regression tests
mchernov
parents:
diff
changeset
|
123 |
long initOld = HeapRegionUsageTool.getOldUsage().getInit(); |
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 |
long newSize = initEden + 2 * initSurv; |
054d452e4e06
8081317: [NEWTEST] documented GC ratio tuning and new size options should be covered by regression tests
mchernov
parents:
diff
changeset
|
126 |
|
054d452e4e06
8081317: [NEWTEST] documented GC ratio tuning and new size options should be covered by regression tests
mchernov
parents:
diff
changeset
|
127 |
long expectedNewSize = HeapRegionUsageTool.alignDown(initOld / expectedRatio, |
054d452e4e06
8081317: [NEWTEST] documented GC ratio tuning and new size options should be covered by regression tests
mchernov
parents:
diff
changeset
|
128 |
wb.getHeapSpaceAlignment()); |
054d452e4e06
8081317: [NEWTEST] documented GC ratio tuning and new size options should be covered by regression tests
mchernov
parents:
diff
changeset
|
129 |
|
054d452e4e06
8081317: [NEWTEST] documented GC ratio tuning and new size options should be covered by regression tests
mchernov
parents:
diff
changeset
|
130 |
if (expectedNewSize != newSize) { |
054d452e4e06
8081317: [NEWTEST] documented GC ratio tuning and new size options should be covered by regression tests
mchernov
parents:
diff
changeset
|
131 |
throw new RuntimeException("Expected young gen size is: " + expectedNewSize |
054d452e4e06
8081317: [NEWTEST] documented GC ratio tuning and new size options should be covered by regression tests
mchernov
parents:
diff
changeset
|
132 |
+ ", but observed new size is: " + newSize); |
054d452e4e06
8081317: [NEWTEST] documented GC ratio tuning and new size options should be covered by regression tests
mchernov
parents:
diff
changeset
|
133 |
} |
054d452e4e06
8081317: [NEWTEST] documented GC ratio tuning and new size options should be covered by regression tests
mchernov
parents:
diff
changeset
|
134 |
} |
054d452e4e06
8081317: [NEWTEST] documented GC ratio tuning and new size options should be covered by regression tests
mchernov
parents:
diff
changeset
|
135 |
|
054d452e4e06
8081317: [NEWTEST] documented GC ratio tuning and new size options should be covered by regression tests
mchernov
parents:
diff
changeset
|
136 |
/** |
054d452e4e06
8081317: [NEWTEST] documented GC ratio tuning and new size options should be covered by regression tests
mchernov
parents:
diff
changeset
|
137 |
* Verify NewSize for PS collector. |
054d452e4e06
8081317: [NEWTEST] documented GC ratio tuning and new size options should be covered by regression tests
mchernov
parents:
diff
changeset
|
138 |
* Expected NewSize calculated according to alignment policies used by PS |
054d452e4e06
8081317: [NEWTEST] documented GC ratio tuning and new size options should be covered by regression tests
mchernov
parents:
diff
changeset
|
139 |
* and then compared with actual NewSize obtained from MemoryPoolMXBeans. |
054d452e4e06
8081317: [NEWTEST] documented GC ratio tuning and new size options should be covered by regression tests
mchernov
parents:
diff
changeset
|
140 |
*/ |
054d452e4e06
8081317: [NEWTEST] documented GC ratio tuning and new size options should be covered by regression tests
mchernov
parents:
diff
changeset
|
141 |
public static void verifyPSNewRatio(int expectedRatio) { |
054d452e4e06
8081317: [NEWTEST] documented GC ratio tuning and new size options should be covered by regression tests
mchernov
parents:
diff
changeset
|
142 |
long initEden = HeapRegionUsageTool.getEdenUsage().getInit(); |
054d452e4e06
8081317: [NEWTEST] documented GC ratio tuning and new size options should be covered by regression tests
mchernov
parents:
diff
changeset
|
143 |
long initSurv = HeapRegionUsageTool.getSurvivorUsage().getInit(); |
054d452e4e06
8081317: [NEWTEST] documented GC ratio tuning and new size options should be covered by regression tests
mchernov
parents:
diff
changeset
|
144 |
long initOld = HeapRegionUsageTool.getOldUsage().getInit(); |
054d452e4e06
8081317: [NEWTEST] documented GC ratio tuning and new size options should be covered by regression tests
mchernov
parents:
diff
changeset
|
145 |
|
054d452e4e06
8081317: [NEWTEST] documented GC ratio tuning and new size options should be covered by regression tests
mchernov
parents:
diff
changeset
|
146 |
long newSize = initEden + 2 * initSurv; |
054d452e4e06
8081317: [NEWTEST] documented GC ratio tuning and new size options should be covered by regression tests
mchernov
parents:
diff
changeset
|
147 |
|
054d452e4e06
8081317: [NEWTEST] documented GC ratio tuning and new size options should be covered by regression tests
mchernov
parents:
diff
changeset
|
148 |
long alignedDownNewSize = HeapRegionUsageTool.alignDown(initOld / expectedRatio, |
054d452e4e06
8081317: [NEWTEST] documented GC ratio tuning and new size options should be covered by regression tests
mchernov
parents:
diff
changeset
|
149 |
wb.getHeapSpaceAlignment()); |
054d452e4e06
8081317: [NEWTEST] documented GC ratio tuning and new size options should be covered by regression tests
mchernov
parents:
diff
changeset
|
150 |
long expectedNewSize = HeapRegionUsageTool.alignUp(alignedDownNewSize, |
054d452e4e06
8081317: [NEWTEST] documented GC ratio tuning and new size options should be covered by regression tests
mchernov
parents:
diff
changeset
|
151 |
wb.psVirtualSpaceAlignment()); |
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 |
if (expectedNewSize != newSize) { |
054d452e4e06
8081317: [NEWTEST] documented GC ratio tuning and new size options should be covered by regression tests
mchernov
parents:
diff
changeset
|
154 |
throw new RuntimeException("Expected young gen size is: " + expectedNewSize |
054d452e4e06
8081317: [NEWTEST] documented GC ratio tuning and new size options should be covered by regression tests
mchernov
parents:
diff
changeset
|
155 |
+ ", but observed new size is: " + newSize); |
054d452e4e06
8081317: [NEWTEST] documented GC ratio tuning and new size options should be covered by regression tests
mchernov
parents:
diff
changeset
|
156 |
} |
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 |
|
054d452e4e06
8081317: [NEWTEST] documented GC ratio tuning and new size options should be covered by regression tests
mchernov
parents:
diff
changeset
|
159 |
/** |
054d452e4e06
8081317: [NEWTEST] documented GC ratio tuning and new size options should be covered by regression tests
mchernov
parents:
diff
changeset
|
160 |
* Verify NewSize for G1 GC. |
054d452e4e06
8081317: [NEWTEST] documented GC ratio tuning and new size options should be covered by regression tests
mchernov
parents:
diff
changeset
|
161 |
* Amount of young regions calculated according to sizing policies used by G1 |
054d452e4e06
8081317: [NEWTEST] documented GC ratio tuning and new size options should be covered by regression tests
mchernov
parents:
diff
changeset
|
162 |
* and then compared with actual number of young regions derived from |
054d452e4e06
8081317: [NEWTEST] documented GC ratio tuning and new size options should be covered by regression tests
mchernov
parents:
diff
changeset
|
163 |
* values reported by MemoryPoolMXBeans and region size. |
054d452e4e06
8081317: [NEWTEST] documented GC ratio tuning and new size options should be covered by regression tests
mchernov
parents:
diff
changeset
|
164 |
*/ |
054d452e4e06
8081317: [NEWTEST] documented GC ratio tuning and new size options should be covered by regression tests
mchernov
parents:
diff
changeset
|
165 |
public static void verifyG1NewRatio(int expectedRatio) { |
054d452e4e06
8081317: [NEWTEST] documented GC ratio tuning and new size options should be covered by regression tests
mchernov
parents:
diff
changeset
|
166 |
long initEden = HeapRegionUsageTool.getEdenUsage().getInit(); |
054d452e4e06
8081317: [NEWTEST] documented GC ratio tuning and new size options should be covered by regression tests
mchernov
parents:
diff
changeset
|
167 |
long initSurv = HeapRegionUsageTool.getSurvivorUsage().getInit(); |
054d452e4e06
8081317: [NEWTEST] documented GC ratio tuning and new size options should be covered by regression tests
mchernov
parents:
diff
changeset
|
168 |
long maxOld = HeapRegionUsageTool.getOldUsage().getMax(); |
054d452e4e06
8081317: [NEWTEST] documented GC ratio tuning and new size options should be covered by regression tests
mchernov
parents:
diff
changeset
|
169 |
|
054d452e4e06
8081317: [NEWTEST] documented GC ratio tuning and new size options should be covered by regression tests
mchernov
parents:
diff
changeset
|
170 |
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
|
171 |
int youngListLength = (int) ((initEden + initSurv) / regionSize); |
054d452e4e06
8081317: [NEWTEST] documented GC ratio tuning and new size options should be covered by regression tests
mchernov
parents:
diff
changeset
|
172 |
int maxRegions = (int) (maxOld / regionSize); |
054d452e4e06
8081317: [NEWTEST] documented GC ratio tuning and new size options should be covered by regression tests
mchernov
parents:
diff
changeset
|
173 |
int expectedYoungListLength = (int) (maxRegions / (double) (expectedRatio + 1)); |
054d452e4e06
8081317: [NEWTEST] documented GC ratio tuning and new size options should be covered by regression tests
mchernov
parents:
diff
changeset
|
174 |
|
054d452e4e06
8081317: [NEWTEST] documented GC ratio tuning and new size options should be covered by regression tests
mchernov
parents:
diff
changeset
|
175 |
if (youngListLength != expectedYoungListLength) { |
054d452e4e06
8081317: [NEWTEST] documented GC ratio tuning and new size options should be covered by regression tests
mchernov
parents:
diff
changeset
|
176 |
throw new RuntimeException("Expected G1 young list length is: " + expectedYoungListLength |
054d452e4e06
8081317: [NEWTEST] documented GC ratio tuning and new size options should be covered by regression tests
mchernov
parents:
diff
changeset
|
177 |
+ ", but observed young list length is: " + youngListLength); |
054d452e4e06
8081317: [NEWTEST] documented GC ratio tuning and new size options should be covered by regression tests
mchernov
parents:
diff
changeset
|
178 |
} |
054d452e4e06
8081317: [NEWTEST] documented GC ratio tuning and new size options should be covered by regression tests
mchernov
parents:
diff
changeset
|
179 |
} |
054d452e4e06
8081317: [NEWTEST] documented GC ratio tuning and new size options should be covered by regression tests
mchernov
parents:
diff
changeset
|
180 |
} |
054d452e4e06
8081317: [NEWTEST] documented GC ratio tuning and new size options should be covered by regression tests
mchernov
parents:
diff
changeset
|
181 |
} |