author | lana |
Thu, 12 May 2016 15:15:02 +0000 | |
changeset 37915 | be4ff50b6cb6 |
parent 36851 | 03e2f4d0a421 |
child 40631 | ed82623d7831 |
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 |
/* |
054d452e4e06
8081317: [NEWTEST] documented GC ratio tuning and new size options should be covered by regression tests
mchernov
parents:
diff
changeset
|
2 |
* Copyright (c) 2015, Oracle and/or its affiliates. All rights reserved. |
054d452e4e06
8081317: [NEWTEST] documented GC ratio tuning and new size options should be covered by regression tests
mchernov
parents:
diff
changeset
|
3 |
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. |
054d452e4e06
8081317: [NEWTEST] documented GC ratio tuning and new size options should be covered by regression tests
mchernov
parents:
diff
changeset
|
4 |
* |
054d452e4e06
8081317: [NEWTEST] documented GC ratio tuning and new size options should be covered by regression tests
mchernov
parents:
diff
changeset
|
5 |
* This code is free software; you can redistribute it and/or modify it |
054d452e4e06
8081317: [NEWTEST] documented GC ratio tuning and new size options should be covered by regression tests
mchernov
parents:
diff
changeset
|
6 |
* under the terms of the GNU General Public License version 2 only, as |
054d452e4e06
8081317: [NEWTEST] documented GC ratio tuning and new size options should be covered by regression tests
mchernov
parents:
diff
changeset
|
7 |
* published by the Free Software Foundation. |
054d452e4e06
8081317: [NEWTEST] documented GC ratio tuning and new size options should be covered by regression tests
mchernov
parents:
diff
changeset
|
8 |
* |
054d452e4e06
8081317: [NEWTEST] documented GC ratio tuning and new size options should be covered by regression tests
mchernov
parents:
diff
changeset
|
9 |
* This code is distributed in the hope that it will be useful, but WITHOUT |
054d452e4e06
8081317: [NEWTEST] documented GC ratio tuning and new size options should be covered by regression tests
mchernov
parents:
diff
changeset
|
10 |
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or |
054d452e4e06
8081317: [NEWTEST] documented GC ratio tuning and new size options should be covered by regression tests
mchernov
parents:
diff
changeset
|
11 |
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License |
054d452e4e06
8081317: [NEWTEST] documented GC ratio tuning and new size options should be covered by regression tests
mchernov
parents:
diff
changeset
|
12 |
* version 2 for more details (a copy is included in the LICENSE file that |
054d452e4e06
8081317: [NEWTEST] documented GC ratio tuning and new size options should be covered by regression tests
mchernov
parents:
diff
changeset
|
13 |
* accompanied this code). |
054d452e4e06
8081317: [NEWTEST] documented GC ratio tuning and new size options should be covered by regression tests
mchernov
parents:
diff
changeset
|
14 |
* |
054d452e4e06
8081317: [NEWTEST] documented GC ratio tuning and new size options should be covered by regression tests
mchernov
parents:
diff
changeset
|
15 |
* You should have received a copy of the GNU General Public License version |
054d452e4e06
8081317: [NEWTEST] documented GC ratio tuning and new size options should be covered by regression tests
mchernov
parents:
diff
changeset
|
16 |
* 2 along with this work; if not, write to the Free Software Foundation, |
054d452e4e06
8081317: [NEWTEST] documented GC ratio tuning and new size options should be covered by regression tests
mchernov
parents:
diff
changeset
|
17 |
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. |
054d452e4e06
8081317: [NEWTEST] documented GC ratio tuning and new size options should be covered by regression tests
mchernov
parents:
diff
changeset
|
18 |
* |
054d452e4e06
8081317: [NEWTEST] documented GC ratio tuning and new size options should be covered by regression tests
mchernov
parents:
diff
changeset
|
19 |
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA |
054d452e4e06
8081317: [NEWTEST] documented GC ratio tuning and new size options should be covered by regression tests
mchernov
parents:
diff
changeset
|
20 |
* or visit www.oracle.com if you need additional information or have any |
054d452e4e06
8081317: [NEWTEST] documented GC ratio tuning and new size options should be covered by regression tests
mchernov
parents:
diff
changeset
|
21 |
* questions. |
054d452e4e06
8081317: [NEWTEST] documented GC ratio tuning and new size options should be covered by regression tests
mchernov
parents:
diff
changeset
|
22 |
*/ |
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 TestMinAndInitialSurvivorRatioFlags |
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 |
* @summary Verify that MinSurvivorRatio and InitialSurvivorRatio flags work |
33730
30e064828045
8140189: [TESTBUG] Get rid of "@library /../../test/lib" in jtreg tests
cjplummer
parents:
32625
diff
changeset
|
28 |
* @library /testlibrary /test/lib |
36851 | 29 |
* @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
|
30 |
* java.management |
054d452e4e06
8081317: [NEWTEST] documented GC ratio tuning and new size options should be covered by regression tests
mchernov
parents:
diff
changeset
|
31 |
* @build TestMinAndInitialSurvivorRatioFlags |
054d452e4e06
8081317: [NEWTEST] documented GC ratio tuning and new size options should be covered by regression tests
mchernov
parents:
diff
changeset
|
32 |
* @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
|
33 |
* @run driver TestMinAndInitialSurvivorRatioFlags |
054d452e4e06
8081317: [NEWTEST] documented GC ratio tuning and new size options should be covered by regression tests
mchernov
parents:
diff
changeset
|
34 |
*/ |
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 |
import jdk.test.lib.AllocationHelper; |
054d452e4e06
8081317: [NEWTEST] documented GC ratio tuning and new size options should be covered by regression tests
mchernov
parents:
diff
changeset
|
37 |
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
|
38 |
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
|
39 |
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
|
40 |
import java.util.LinkedList; |
054d452e4e06
8081317: [NEWTEST] documented GC ratio tuning and new size options should be covered by regression tests
mchernov
parents:
diff
changeset
|
41 |
import jdk.test.lib.HeapRegionUsageTool; |
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.OutputAnalyzer; |
054d452e4e06
8081317: [NEWTEST] documented GC ratio tuning and new size options should be covered by regression tests
mchernov
parents:
diff
changeset
|
43 |
import jdk.test.lib.ProcessTools; |
054d452e4e06
8081317: [NEWTEST] documented GC ratio tuning and new size options should be covered by regression tests
mchernov
parents:
diff
changeset
|
44 |
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
|
45 |
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
|
46 |
|
054d452e4e06
8081317: [NEWTEST] documented GC ratio tuning and new size options should be covered by regression tests
mchernov
parents:
diff
changeset
|
47 |
/* Test verifies that VM can start with any GC when MinSurvivorRatio and |
054d452e4e06
8081317: [NEWTEST] documented GC ratio tuning and new size options should be covered by regression tests
mchernov
parents:
diff
changeset
|
48 |
* InitialSurvivorRatio flags passed and for Parallel GC it verifies that |
054d452e4e06
8081317: [NEWTEST] documented GC ratio tuning and new size options should be covered by regression tests
mchernov
parents:
diff
changeset
|
49 |
* after start up survivor ratio equal to InitialSurvivorRatio value and |
054d452e4e06
8081317: [NEWTEST] documented GC ratio tuning and new size options should be covered by regression tests
mchernov
parents:
diff
changeset
|
50 |
* that actual survivor ratio will never be less than MinSurvivorRatio. |
054d452e4e06
8081317: [NEWTEST] documented GC ratio tuning and new size options should be covered by regression tests
mchernov
parents:
diff
changeset
|
51 |
*/ |
054d452e4e06
8081317: [NEWTEST] documented GC ratio tuning and new size options should be covered by regression tests
mchernov
parents:
diff
changeset
|
52 |
public class TestMinAndInitialSurvivorRatioFlags { |
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 |
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
|
55 |
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
|
56 |
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
|
57 |
|
054d452e4e06
8081317: [NEWTEST] documented GC ratio tuning and new size options should be covered by regression tests
mchernov
parents:
diff
changeset
|
58 |
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
|
59 |
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
|
60 |
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
|
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 |
testSurvivorRatio(5, -1, -1, options, true); |
054d452e4e06
8081317: [NEWTEST] documented GC ratio tuning and new size options should be covered by regression tests
mchernov
parents:
diff
changeset
|
64 |
testSurvivorRatio(10, -1, -1, options, true); |
054d452e4e06
8081317: [NEWTEST] documented GC ratio tuning and new size options should be covered by regression tests
mchernov
parents:
diff
changeset
|
65 |
testSurvivorRatio(-1, 5, 3, options, true); |
054d452e4e06
8081317: [NEWTEST] documented GC ratio tuning and new size options should be covered by regression tests
mchernov
parents:
diff
changeset
|
66 |
testSurvivorRatio(-1, 15, 3, options, true); |
054d452e4e06
8081317: [NEWTEST] documented GC ratio tuning and new size options should be covered by regression tests
mchernov
parents:
diff
changeset
|
67 |
testSurvivorRatio(-1, 15, 3, options, false); |
054d452e4e06
8081317: [NEWTEST] documented GC ratio tuning and new size options should be covered by regression tests
mchernov
parents:
diff
changeset
|
68 |
testSurvivorRatio(-1, 10, 10, options, true); |
054d452e4e06
8081317: [NEWTEST] documented GC ratio tuning and new size options should be covered by regression tests
mchernov
parents:
diff
changeset
|
69 |
testSurvivorRatio(-1, 3, 15, options, true); |
054d452e4e06
8081317: [NEWTEST] documented GC ratio tuning and new size options should be covered by regression tests
mchernov
parents:
diff
changeset
|
70 |
testSurvivorRatio(-1, 3, 15, options, false); |
054d452e4e06
8081317: [NEWTEST] documented GC ratio tuning and new size options should be covered by regression tests
mchernov
parents:
diff
changeset
|
71 |
} |
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 |
/** |
054d452e4e06
8081317: [NEWTEST] documented GC ratio tuning and new size options should be covered by regression tests
mchernov
parents:
diff
changeset
|
74 |
* Test that MinSurvivorRatio and InitialSurvivorRatio flags work. |
054d452e4e06
8081317: [NEWTEST] documented GC ratio tuning and new size options should be covered by regression tests
mchernov
parents:
diff
changeset
|
75 |
* |
054d452e4e06
8081317: [NEWTEST] documented GC ratio tuning and new size options should be covered by regression tests
mchernov
parents:
diff
changeset
|
76 |
* @param survivorRatio value for -XX:SurvivorRatio option, omitted if negative |
054d452e4e06
8081317: [NEWTEST] documented GC ratio tuning and new size options should be covered by regression tests
mchernov
parents:
diff
changeset
|
77 |
* @param initRatio value for -XX:InitialSurvivorRatio option, omitted if negative |
054d452e4e06
8081317: [NEWTEST] documented GC ratio tuning and new size options should be covered by regression tests
mchernov
parents:
diff
changeset
|
78 |
* @param minRatio value for -XX:MinSurvivorRatio option, omitted if negative |
054d452e4e06
8081317: [NEWTEST] documented GC ratio tuning and new size options should be covered by regression tests
mchernov
parents:
diff
changeset
|
79 |
* @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
|
80 |
* @param useAdaptiveSizePolicy turn on or off UseAdaptiveSizePolicy option |
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 |
public static void testSurvivorRatio(int survivorRatio, |
054d452e4e06
8081317: [NEWTEST] documented GC ratio tuning and new size options should be covered by regression tests
mchernov
parents:
diff
changeset
|
83 |
int initRatio, |
054d452e4e06
8081317: [NEWTEST] documented GC ratio tuning and new size options should be covered by regression tests
mchernov
parents:
diff
changeset
|
84 |
int minRatio, |
054d452e4e06
8081317: [NEWTEST] documented GC ratio tuning and new size options should be covered by regression tests
mchernov
parents:
diff
changeset
|
85 |
LinkedList<String> options, |
054d452e4e06
8081317: [NEWTEST] documented GC ratio tuning and new size options should be covered by regression tests
mchernov
parents:
diff
changeset
|
86 |
boolean useAdaptiveSizePolicy) throws Exception { |
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 |
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
|
89 |
Collections.addAll(vmOptions, |
054d452e4e06
8081317: [NEWTEST] documented GC ratio tuning and new size options should be covered by regression tests
mchernov
parents:
diff
changeset
|
90 |
"-Xbootclasspath/a:.", |
054d452e4e06
8081317: [NEWTEST] documented GC ratio tuning and new size options should be covered by regression tests
mchernov
parents:
diff
changeset
|
91 |
"-XX:+UnlockDiagnosticVMOptions", |
054d452e4e06
8081317: [NEWTEST] documented GC ratio tuning and new size options should be covered by regression tests
mchernov
parents:
diff
changeset
|
92 |
"-XX:+WhiteBoxAPI", |
054d452e4e06
8081317: [NEWTEST] documented GC ratio tuning and new size options should be covered by regression tests
mchernov
parents:
diff
changeset
|
93 |
"-XX:MaxNewSize=" + NEW_SIZE, "-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
|
94 |
"-Xmx" + HEAP_SIZE, "-Xms" + HEAP_SIZE, |
054d452e4e06
8081317: [NEWTEST] documented GC ratio tuning and new size options should be covered by regression tests
mchernov
parents:
diff
changeset
|
95 |
(survivorRatio >= 0 ? "-XX:SurvivorRatio=" + survivorRatio : ""), |
054d452e4e06
8081317: [NEWTEST] documented GC ratio tuning and new size options should be covered by regression tests
mchernov
parents:
diff
changeset
|
96 |
(initRatio >= 0 ? "-XX:InitialSurvivorRatio=" + initRatio : ""), |
054d452e4e06
8081317: [NEWTEST] documented GC ratio tuning and new size options should be covered by regression tests
mchernov
parents:
diff
changeset
|
97 |
(minRatio >= 0 ? "-XX:MinSurvivorRatio=" + minRatio : ""), |
054d452e4e06
8081317: [NEWTEST] documented GC ratio tuning and new size options should be covered by regression tests
mchernov
parents:
diff
changeset
|
98 |
(useAdaptiveSizePolicy ? "-XX:+UseAdaptiveSizePolicy" : "-XX:-UseAdaptiveSizePolicy"), |
054d452e4e06
8081317: [NEWTEST] documented GC ratio tuning and new size options should be covered by regression tests
mchernov
parents:
diff
changeset
|
99 |
SurvivorRatioVerifier.class.getName(), |
054d452e4e06
8081317: [NEWTEST] documented GC ratio tuning and new size options should be covered by regression tests
mchernov
parents:
diff
changeset
|
100 |
Integer.toString(survivorRatio), |
054d452e4e06
8081317: [NEWTEST] documented GC ratio tuning and new size options should be covered by regression tests
mchernov
parents:
diff
changeset
|
101 |
Integer.toString(initRatio), |
054d452e4e06
8081317: [NEWTEST] documented GC ratio tuning and new size options should be covered by regression tests
mchernov
parents:
diff
changeset
|
102 |
Integer.toString(minRatio), |
054d452e4e06
8081317: [NEWTEST] documented GC ratio tuning and new size options should be covered by regression tests
mchernov
parents:
diff
changeset
|
103 |
Boolean.toString(useAdaptiveSizePolicy) |
054d452e4e06
8081317: [NEWTEST] documented GC ratio tuning and new size options should be covered by regression tests
mchernov
parents:
diff
changeset
|
104 |
); |
054d452e4e06
8081317: [NEWTEST] documented GC ratio tuning and new size options should be covered by regression tests
mchernov
parents:
diff
changeset
|
105 |
vmOptions.removeIf((String p) -> p.isEmpty()); |
054d452e4e06
8081317: [NEWTEST] documented GC ratio tuning and new size options should be covered by regression tests
mchernov
parents:
diff
changeset
|
106 |
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
|
107 |
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
|
108 |
analyzer.shouldHaveExitValue(0); |
054d452e4e06
8081317: [NEWTEST] documented GC ratio tuning and new size options should be covered by regression tests
mchernov
parents:
diff
changeset
|
109 |
} |
054d452e4e06
8081317: [NEWTEST] documented GC ratio tuning and new size options should be covered by regression tests
mchernov
parents:
diff
changeset
|
110 |
|
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 |
* 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
|
113 |
* Will be executed in tested VM. Checks initial size of eden and survivor paces with alignment. |
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 |
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
|
116 |
|
054d452e4e06
8081317: [NEWTEST] documented GC ratio tuning and new size options should be covered by regression tests
mchernov
parents:
diff
changeset
|
117 |
public 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
|
118 |
|
054d452e4e06
8081317: [NEWTEST] documented GC ratio tuning and new size options should be covered by regression tests
mchernov
parents:
diff
changeset
|
119 |
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
|
120 |
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
|
121 |
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
|
122 |
|
054d452e4e06
8081317: [NEWTEST] documented GC ratio tuning and new size options should be covered by regression tests
mchernov
parents:
diff
changeset
|
123 |
public static byte garbage[][] = new byte[ARRAY_LENGTH][]; |
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 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
|
126 |
if (args.length != 4) { |
054d452e4e06
8081317: [NEWTEST] documented GC ratio tuning and new size options should be covered by regression tests
mchernov
parents:
diff
changeset
|
127 |
throw new IllegalArgumentException("Expected 4 args: <survivorRatio> <initRatio> <minRatio> <useAdaptiveSizePolicy>"); |
054d452e4e06
8081317: [NEWTEST] documented GC ratio tuning and new size options should be covered by regression tests
mchernov
parents:
diff
changeset
|
128 |
} |
054d452e4e06
8081317: [NEWTEST] documented GC ratio tuning and new size options should be covered by regression tests
mchernov
parents:
diff
changeset
|
129 |
final int survivorRatio = 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
|
130 |
final int initRatio = Integer.valueOf(args[1]); |
054d452e4e06
8081317: [NEWTEST] documented GC ratio tuning and new size options should be covered by regression tests
mchernov
parents:
diff
changeset
|
131 |
final int minRatio = Integer.valueOf(args[2]); |
054d452e4e06
8081317: [NEWTEST] documented GC ratio tuning and new size options should be covered by regression tests
mchernov
parents:
diff
changeset
|
132 |
final boolean useAdaptiveSizePolicy = Boolean.valueOf(args[3]); |
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 |
// we stop testing only here to ensure that JVM will accept |
054d452e4e06
8081317: [NEWTEST] documented GC ratio tuning and new size options should be covered by regression tests
mchernov
parents:
diff
changeset
|
135 |
// both MinSurvivorRatio and InitialSurvivorRatio regardles to GC |
054d452e4e06
8081317: [NEWTEST] documented GC ratio tuning and new size options should be covered by regression tests
mchernov
parents:
diff
changeset
|
136 |
if (GCTypes.YoungGCType.getYoungGCType() != GCTypes.YoungGCType.PSNew) { |
054d452e4e06
8081317: [NEWTEST] documented GC ratio tuning and new size options should be covered by regression tests
mchernov
parents:
diff
changeset
|
137 |
System.out.println("Test is only applicable to Parallel GC"); |
054d452e4e06
8081317: [NEWTEST] documented GC ratio tuning and new size options should be covered by regression tests
mchernov
parents:
diff
changeset
|
138 |
return; |
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 |
|
054d452e4e06
8081317: [NEWTEST] documented GC ratio tuning and new size options should be covered by regression tests
mchernov
parents:
diff
changeset
|
141 |
// verify initial survivor ratio |
054d452e4e06
8081317: [NEWTEST] documented GC ratio tuning and new size options should be covered by regression tests
mchernov
parents:
diff
changeset
|
142 |
verifySurvivorRatio(survivorRatio, initRatio, minRatio, useAdaptiveSizePolicy, true); |
054d452e4e06
8081317: [NEWTEST] documented GC ratio tuning and new size options should be covered by regression tests
mchernov
parents:
diff
changeset
|
143 |
|
054d452e4e06
8081317: [NEWTEST] documented GC ratio tuning and new size options should be covered by regression tests
mchernov
parents:
diff
changeset
|
144 |
// force GC |
054d452e4e06
8081317: [NEWTEST] documented GC ratio tuning and new size options should be covered by regression tests
mchernov
parents:
diff
changeset
|
145 |
AllocationHelper allocator = new AllocationHelper(MAX_ITERATIONS, ARRAY_LENGTH, CHUNK_SIZE, |
054d452e4e06
8081317: [NEWTEST] documented GC ratio tuning and new size options should be covered by regression tests
mchernov
parents:
diff
changeset
|
146 |
() -> (verifySurvivorRatio(survivorRatio, initRatio, minRatio, useAdaptiveSizePolicy, false))); |
054d452e4e06
8081317: [NEWTEST] documented GC ratio tuning and new size options should be covered by regression tests
mchernov
parents:
diff
changeset
|
147 |
allocator.allocateMemoryAndVerify(); |
054d452e4e06
8081317: [NEWTEST] documented GC ratio tuning and new size options should be covered by regression tests
mchernov
parents:
diff
changeset
|
148 |
} |
054d452e4e06
8081317: [NEWTEST] documented GC ratio tuning and new size options should be covered by regression tests
mchernov
parents:
diff
changeset
|
149 |
|
054d452e4e06
8081317: [NEWTEST] documented GC ratio tuning and new size options should be covered by regression tests
mchernov
parents:
diff
changeset
|
150 |
/** |
054d452e4e06
8081317: [NEWTEST] documented GC ratio tuning and new size options should be covered by regression tests
mchernov
parents:
diff
changeset
|
151 |
* Verify actual survivor ratio. |
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 |
* @param survivorRatio value of SurvivorRatio option, omitted if negative |
054d452e4e06
8081317: [NEWTEST] documented GC ratio tuning and new size options should be covered by regression tests
mchernov
parents:
diff
changeset
|
154 |
* @param initRatio value of InitialSurvivorRatio option, omitted if negative |
054d452e4e06
8081317: [NEWTEST] documented GC ratio tuning and new size options should be covered by regression tests
mchernov
parents:
diff
changeset
|
155 |
* @param minRatio value of MinSurvivorRatio option, omitted if negative |
054d452e4e06
8081317: [NEWTEST] documented GC ratio tuning and new size options should be covered by regression tests
mchernov
parents:
diff
changeset
|
156 |
* @param useAdaptiveSizePolicy value of UseAdaptiveSizePolicy option |
054d452e4e06
8081317: [NEWTEST] documented GC ratio tuning and new size options should be covered by regression tests
mchernov
parents:
diff
changeset
|
157 |
* @param verifyInitialRatio true if we are going to verify initial ratio |
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 |
public static Void verifySurvivorRatio(int survivorRatio, |
054d452e4e06
8081317: [NEWTEST] documented GC ratio tuning and new size options should be covered by regression tests
mchernov
parents:
diff
changeset
|
160 |
int initRatio, |
054d452e4e06
8081317: [NEWTEST] documented GC ratio tuning and new size options should be covered by regression tests
mchernov
parents:
diff
changeset
|
161 |
int minRatio, |
054d452e4e06
8081317: [NEWTEST] documented GC ratio tuning and new size options should be covered by regression tests
mchernov
parents:
diff
changeset
|
162 |
boolean useAdaptiveSizePolicy, |
054d452e4e06
8081317: [NEWTEST] documented GC ratio tuning and new size options should be covered by regression tests
mchernov
parents:
diff
changeset
|
163 |
boolean verifyInitialRatio) { |
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 |
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
|
166 |
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
|
167 |
|
054d452e4e06
8081317: [NEWTEST] documented GC ratio tuning and new size options should be covered by regression tests
mchernov
parents:
diff
changeset
|
168 |
long alignedNewSize = 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
|
169 |
long generationAlignment = wb.psHeapGenerationAlignment(); |
054d452e4e06
8081317: [NEWTEST] documented GC ratio tuning and new size options should be covered by regression tests
mchernov
parents:
diff
changeset
|
170 |
|
054d452e4e06
8081317: [NEWTEST] documented GC ratio tuning and new size options should be covered by regression tests
mchernov
parents:
diff
changeset
|
171 |
if (survivorRatio >= 0) { |
054d452e4e06
8081317: [NEWTEST] documented GC ratio tuning and new size options should be covered by regression tests
mchernov
parents:
diff
changeset
|
172 |
// -XX:SurvivorRatio was passed to JVM, actual ratio should be SurvivorRatio + 2 |
054d452e4e06
8081317: [NEWTEST] documented GC ratio tuning and new size options should be covered by regression tests
mchernov
parents:
diff
changeset
|
173 |
long expectedSize = HeapRegionUsageTool.alignDown(alignedNewSize / (survivorRatio + 2), |
054d452e4e06
8081317: [NEWTEST] documented GC ratio tuning and new size options should be covered by regression tests
mchernov
parents:
diff
changeset
|
174 |
generationAlignment); |
054d452e4e06
8081317: [NEWTEST] documented GC ratio tuning and new size options should be covered by regression tests
mchernov
parents:
diff
changeset
|
175 |
|
054d452e4e06
8081317: [NEWTEST] documented GC ratio tuning and new size options should be covered by regression tests
mchernov
parents:
diff
changeset
|
176 |
if (survivorUsage.getCommitted() != expectedSize) { |
054d452e4e06
8081317: [NEWTEST] documented GC ratio tuning and new size options should be covered by regression tests
mchernov
parents:
diff
changeset
|
177 |
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
|
178 |
+ ", 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
|
179 |
} |
054d452e4e06
8081317: [NEWTEST] documented GC ratio tuning and new size options should be covered by regression tests
mchernov
parents:
diff
changeset
|
180 |
} else if (verifyInitialRatio || !useAdaptiveSizePolicy) { |
054d452e4e06
8081317: [NEWTEST] documented GC ratio tuning and new size options should be covered by regression tests
mchernov
parents:
diff
changeset
|
181 |
// In case of initial ratio verification or disabled adaptive size policy |
054d452e4e06
8081317: [NEWTEST] documented GC ratio tuning and new size options should be covered by regression tests
mchernov
parents:
diff
changeset
|
182 |
// ratio should be equal to InitialSurvivorRatio value |
054d452e4e06
8081317: [NEWTEST] documented GC ratio tuning and new size options should be covered by regression tests
mchernov
parents:
diff
changeset
|
183 |
long expectedSize = HeapRegionUsageTool.alignDown(alignedNewSize / initRatio, |
054d452e4e06
8081317: [NEWTEST] documented GC ratio tuning and new size options should be covered by regression tests
mchernov
parents:
diff
changeset
|
184 |
generationAlignment); |
054d452e4e06
8081317: [NEWTEST] documented GC ratio tuning and new size options should be covered by regression tests
mchernov
parents:
diff
changeset
|
185 |
if (survivorUsage.getCommitted() != expectedSize) { |
054d452e4e06
8081317: [NEWTEST] documented GC ratio tuning and new size options should be covered by regression tests
mchernov
parents:
diff
changeset
|
186 |
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
|
187 |
+ ", 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
|
188 |
} |
054d452e4e06
8081317: [NEWTEST] documented GC ratio tuning and new size options should be covered by regression tests
mchernov
parents:
diff
changeset
|
189 |
} else { |
054d452e4e06
8081317: [NEWTEST] documented GC ratio tuning and new size options should be covered by regression tests
mchernov
parents:
diff
changeset
|
190 |
// In any other case actual survivor ratio should not be lower than MinSurvivorRatio |
054d452e4e06
8081317: [NEWTEST] documented GC ratio tuning and new size options should be covered by regression tests
mchernov
parents:
diff
changeset
|
191 |
// or is should be equal to InitialSurvivorRatio |
054d452e4e06
8081317: [NEWTEST] documented GC ratio tuning and new size options should be covered by regression tests
mchernov
parents:
diff
changeset
|
192 |
long expectedMinSize = HeapRegionUsageTool.alignDown(alignedNewSize / minRatio, |
054d452e4e06
8081317: [NEWTEST] documented GC ratio tuning and new size options should be covered by regression tests
mchernov
parents:
diff
changeset
|
193 |
generationAlignment); |
054d452e4e06
8081317: [NEWTEST] documented GC ratio tuning and new size options should be covered by regression tests
mchernov
parents:
diff
changeset
|
194 |
long expectedInitSize = HeapRegionUsageTool.alignDown(alignedNewSize / initRatio, |
054d452e4e06
8081317: [NEWTEST] documented GC ratio tuning and new size options should be covered by regression tests
mchernov
parents:
diff
changeset
|
195 |
generationAlignment); |
054d452e4e06
8081317: [NEWTEST] documented GC ratio tuning and new size options should be covered by regression tests
mchernov
parents:
diff
changeset
|
196 |
if (survivorUsage.getCommitted() != expectedInitSize |
054d452e4e06
8081317: [NEWTEST] documented GC ratio tuning and new size options should be covered by regression tests
mchernov
parents:
diff
changeset
|
197 |
&& survivorUsage.getCommitted() < expectedMinSize) { |
054d452e4e06
8081317: [NEWTEST] documented GC ratio tuning and new size options should be covered by regression tests
mchernov
parents:
diff
changeset
|
198 |
throw new RuntimeException("Expected survivor size should be " + expectedMinSize |
054d452e4e06
8081317: [NEWTEST] documented GC ratio tuning and new size options should be covered by regression tests
mchernov
parents:
diff
changeset
|
199 |
+ " or should be greater then " + expectedMinSize |
054d452e4e06
8081317: [NEWTEST] documented GC ratio tuning and new size options should be covered by regression tests
mchernov
parents:
diff
changeset
|
200 |
+ ", but observer survivor 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
|
201 |
} |
054d452e4e06
8081317: [NEWTEST] documented GC ratio tuning and new size options should be covered by regression tests
mchernov
parents:
diff
changeset
|
202 |
} |
054d452e4e06
8081317: [NEWTEST] documented GC ratio tuning and new size options should be covered by regression tests
mchernov
parents:
diff
changeset
|
203 |
return null; |
054d452e4e06
8081317: [NEWTEST] documented GC ratio tuning and new size options should be covered by regression tests
mchernov
parents:
diff
changeset
|
204 |
} |
054d452e4e06
8081317: [NEWTEST] documented GC ratio tuning and new size options should be covered by regression tests
mchernov
parents:
diff
changeset
|
205 |
} |
054d452e4e06
8081317: [NEWTEST] documented GC ratio tuning and new size options should be covered by regression tests
mchernov
parents:
diff
changeset
|
206 |
} |