author | jlahoda |
Mon, 13 Feb 2017 09:37:26 +0100 | |
changeset 43772 | 4e5350b7be75 |
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:
41092
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:
41092
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:
41092
diff
changeset
|
4 |
* |
332239c052cc
8165687: Fix license and copyright headers in jd9 under hotspot/test
stsmirno
parents:
41092
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:
41092
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:
41092
diff
changeset
|
7 |
* published by the Free Software Foundation. |
332239c052cc
8165687: Fix license and copyright headers in jd9 under hotspot/test
stsmirno
parents:
41092
diff
changeset
|
8 |
* |
332239c052cc
8165687: Fix license and copyright headers in jd9 under hotspot/test
stsmirno
parents:
41092
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:
41092
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:
41092
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:
41092
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:
41092
diff
changeset
|
13 |
* accompanied this code). |
332239c052cc
8165687: Fix license and copyright headers in jd9 under hotspot/test
stsmirno
parents:
41092
diff
changeset
|
14 |
* |
332239c052cc
8165687: Fix license and copyright headers in jd9 under hotspot/test
stsmirno
parents:
41092
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:
41092
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:
41092
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:
41092
diff
changeset
|
18 |
* |
332239c052cc
8165687: Fix license and copyright headers in jd9 under hotspot/test
stsmirno
parents:
41092
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:
41092
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:
41092
diff
changeset
|
21 |
* questions. |
332239c052cc
8165687: Fix license and copyright headers in jd9 under hotspot/test
stsmirno
parents:
41092
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 TestTargetSurvivorRatioFlag |
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 option TargetSurvivorRatio affects survivor space occupancy after minor GC. |
39226
8151452e26b2
8146530: [testbug] some tests fail because the compiler is using Java heap memory
sjohanss
parents:
38152
diff
changeset
|
28 |
* @requires (vm.opt.ExplicitGCInvokesConcurrent == null) | (vm.opt.ExplicitGCInvokesConcurrent == false) |
8151452e26b2
8146530: [testbug] some tests fail because the compiler is using Java heap memory
sjohanss
parents:
38152
diff
changeset
|
29 |
* @requires (vm.opt.UseJVMCICompiler == null) | (vm.opt.UseJVMCICompiler == false) |
40631
ed82623d7831
8157957: ClassNotFoundException: jdk.test.lib.JDKToolFinder
ctornqvi
parents:
40244
diff
changeset
|
30 |
* @library /test/lib |
36851 | 31 |
* @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
|
32 |
* java.management |
40631
ed82623d7831
8157957: ClassNotFoundException: jdk.test.lib.JDKToolFinder
ctornqvi
parents:
40244
diff
changeset
|
33 |
* @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
|
34 |
* @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
|
35 |
* @run driver TestTargetSurvivorRatioFlag |
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 |
|
054d452e4e06
8081317: [NEWTEST] documented GC ratio tuning and new size options should be covered by regression tests
mchernov
parents:
diff
changeset
|
38 |
import java.lang.management.GarbageCollectorMXBean; |
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.Arrays; |
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.Collections; |
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.LinkedList; |
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.List; |
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.regex.Matcher; |
054d452e4e06
8081317: [NEWTEST] documented GC ratio tuning and new size options should be covered by regression tests
mchernov
parents:
diff
changeset
|
44 |
import java.util.regex.Pattern; |
38152
80e5da81fb2c
8154258: [TESTBUG] Various serviceability tests fail compilation
dsamersoff
parents:
36851
diff
changeset
|
45 |
import jdk.internal.misc.Unsafe; |
40631
ed82623d7831
8157957: ClassNotFoundException: jdk.test.lib.JDKToolFinder
ctornqvi
parents:
40244
diff
changeset
|
46 |
import jdk.test.lib.process.OutputAnalyzer; |
ed82623d7831
8157957: ClassNotFoundException: jdk.test.lib.JDKToolFinder
ctornqvi
parents:
40244
diff
changeset
|
47 |
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
|
48 |
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
|
49 |
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
|
50 |
|
054d452e4e06
8081317: [NEWTEST] documented GC ratio tuning and new size options should be covered by regression tests
mchernov
parents:
diff
changeset
|
51 |
/* In order to test that TargetSurvivorRatio affects survivor space occupancy |
054d452e4e06
8081317: [NEWTEST] documented GC ratio tuning and new size options should be covered by regression tests
mchernov
parents:
diff
changeset
|
52 |
* we setup fixed MaxTenuringThreshold and then verifying that if size of allocated |
054d452e4e06
8081317: [NEWTEST] documented GC ratio tuning and new size options should be covered by regression tests
mchernov
parents:
diff
changeset
|
53 |
* objects is lower than (survivor_size * TargetSurvivorRatio / 100) then objects |
054d452e4e06
8081317: [NEWTEST] documented GC ratio tuning and new size options should be covered by regression tests
mchernov
parents:
diff
changeset
|
54 |
* will stay in survivor space until MaxTenuringThreshold minor GC cycles. |
054d452e4e06
8081317: [NEWTEST] documented GC ratio tuning and new size options should be covered by regression tests
mchernov
parents:
diff
changeset
|
55 |
* If more than (survivor_size * TargetSurvivorRatio / 100) objects were allocated, |
054d452e4e06
8081317: [NEWTEST] documented GC ratio tuning and new size options should be covered by regression tests
mchernov
parents:
diff
changeset
|
56 |
* then we verify that after MaxTenuringThreshold minor GC cycles survivor space |
054d452e4e06
8081317: [NEWTEST] documented GC ratio tuning and new size options should be covered by regression tests
mchernov
parents:
diff
changeset
|
57 |
* is almost empty. |
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 |
public class TestTargetSurvivorRatioFlag { |
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 |
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
|
62 |
|
054d452e4e06
8081317: [NEWTEST] documented GC ratio tuning and new size options should be covered by regression tests
mchernov
parents:
diff
changeset
|
63 |
// VM option values |
054d452e4e06
8081317: [NEWTEST] documented GC ratio tuning and new size options should be covered by regression tests
mchernov
parents:
diff
changeset
|
64 |
public static final long MAX_NEW_SIZE = 40 * M; |
054d452e4e06
8081317: [NEWTEST] documented GC ratio tuning and new size options should be covered by regression tests
mchernov
parents:
diff
changeset
|
65 |
public static final int SURVIVOR_RATIO = 8; |
054d452e4e06
8081317: [NEWTEST] documented GC ratio tuning and new size options should be covered by regression tests
mchernov
parents:
diff
changeset
|
66 |
public static final int MAX_TENURING_THRESHOLD = 15; |
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 |
// Value used to estimate amount of memory that should be allocated |
054d452e4e06
8081317: [NEWTEST] documented GC ratio tuning and new size options should be covered by regression tests
mchernov
parents:
diff
changeset
|
69 |
// and placed in survivor space. |
054d452e4e06
8081317: [NEWTEST] documented GC ratio tuning and new size options should be covered by regression tests
mchernov
parents:
diff
changeset
|
70 |
public static final double DELTA = 0.25; |
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 |
// Max variance of observed ratio |
054d452e4e06
8081317: [NEWTEST] documented GC ratio tuning and new size options should be covered by regression tests
mchernov
parents:
diff
changeset
|
73 |
public static double VARIANCE = 1; |
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 |
// Messages used by debuggee |
054d452e4e06
8081317: [NEWTEST] documented GC ratio tuning and new size options should be covered by regression tests
mchernov
parents:
diff
changeset
|
76 |
public static final String UNSUPPORTED_GC = "Unsupported GC"; |
054d452e4e06
8081317: [NEWTEST] documented GC ratio tuning and new size options should be covered by regression tests
mchernov
parents:
diff
changeset
|
77 |
public static final String START_TEST = "Start test"; |
054d452e4e06
8081317: [NEWTEST] documented GC ratio tuning and new size options should be covered by regression tests
mchernov
parents:
diff
changeset
|
78 |
public static final String END_TEST = "End test"; |
054d452e4e06
8081317: [NEWTEST] documented GC ratio tuning and new size options should be covered by regression tests
mchernov
parents:
diff
changeset
|
79 |
|
054d452e4e06
8081317: [NEWTEST] documented GC ratio tuning and new size options should be covered by regression tests
mchernov
parents:
diff
changeset
|
80 |
// Patterns used during log parsing |
054d452e4e06
8081317: [NEWTEST] documented GC ratio tuning and new size options should be covered by regression tests
mchernov
parents:
diff
changeset
|
81 |
public static final String TENURING_DISTRIBUTION = "Desired survivor size"; |
35061 | 82 |
public static final String AGE_TABLE_ENTRY = ".*-[\\s]+age[\\s]+([0-9]+):[\\s]+([0-9]+)[\\s]+bytes,[\\s]+([0-9]+)[\\s]+total"; |
32625
054d452e4e06
8081317: [NEWTEST] documented GC ratio tuning and new size options should be covered by regression tests
mchernov
parents:
diff
changeset
|
83 |
public static final String MAX_SURVIVOR_SIZE = "Max survivor size: ([0-9]+)"; |
054d452e4e06
8081317: [NEWTEST] documented GC ratio tuning and new size options should be covered by regression tests
mchernov
parents:
diff
changeset
|
84 |
|
054d452e4e06
8081317: [NEWTEST] documented GC ratio tuning and new size options should be covered by regression tests
mchernov
parents:
diff
changeset
|
85 |
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
|
86 |
|
054d452e4e06
8081317: [NEWTEST] documented GC ratio tuning and new size options should be covered by regression tests
mchernov
parents:
diff
changeset
|
87 |
LinkedList<String> options = new LinkedList<>(Arrays.asList(Utils.getTestJavaOpts())); |
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 |
// Need to consider the effect of TargetPLABWastePct=1 for G1 GC |
054d452e4e06
8081317: [NEWTEST] documented GC ratio tuning and new size options should be covered by regression tests
mchernov
parents:
diff
changeset
|
90 |
if (options.contains("-XX:+UseG1GC")) { |
054d452e4e06
8081317: [NEWTEST] documented GC ratio tuning and new size options should be covered by regression tests
mchernov
parents:
diff
changeset
|
91 |
VARIANCE = 2; |
054d452e4e06
8081317: [NEWTEST] documented GC ratio tuning and new size options should be covered by regression tests
mchernov
parents:
diff
changeset
|
92 |
} else { |
054d452e4e06
8081317: [NEWTEST] documented GC ratio tuning and new size options should be covered by regression tests
mchernov
parents:
diff
changeset
|
93 |
VARIANCE = 1; |
054d452e4e06
8081317: [NEWTEST] documented GC ratio tuning and new size options should be covered by regression tests
mchernov
parents:
diff
changeset
|
94 |
} |
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 |
negativeTest(-1, options); |
054d452e4e06
8081317: [NEWTEST] documented GC ratio tuning and new size options should be covered by regression tests
mchernov
parents:
diff
changeset
|
97 |
negativeTest(101, options); |
054d452e4e06
8081317: [NEWTEST] documented GC ratio tuning and new size options should be covered by regression tests
mchernov
parents:
diff
changeset
|
98 |
|
054d452e4e06
8081317: [NEWTEST] documented GC ratio tuning and new size options should be covered by regression tests
mchernov
parents:
diff
changeset
|
99 |
positiveTest(20, options); |
054d452e4e06
8081317: [NEWTEST] documented GC ratio tuning and new size options should be covered by regression tests
mchernov
parents:
diff
changeset
|
100 |
positiveTest(30, options); |
054d452e4e06
8081317: [NEWTEST] documented GC ratio tuning and new size options should be covered by regression tests
mchernov
parents:
diff
changeset
|
101 |
positiveTest(55, options); |
054d452e4e06
8081317: [NEWTEST] documented GC ratio tuning and new size options should be covered by regression tests
mchernov
parents:
diff
changeset
|
102 |
positiveTest(70, options); |
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 |
|
054d452e4e06
8081317: [NEWTEST] documented GC ratio tuning and new size options should be covered by regression tests
mchernov
parents:
diff
changeset
|
105 |
/** |
054d452e4e06
8081317: [NEWTEST] documented GC ratio tuning and new size options should be covered by regression tests
mchernov
parents:
diff
changeset
|
106 |
* Verify that VM will fail to start with specified TargetSurvivorRatio |
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 |
* @param ratio value of TargetSurvivorRatio |
054d452e4e06
8081317: [NEWTEST] documented GC ratio tuning and new size options should be covered by regression tests
mchernov
parents:
diff
changeset
|
109 |
* @param options additional VM options |
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 |
public static void negativeTest(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
|
112 |
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
|
113 |
vmOptions.add("-XX:TargetSurvivorRatio=" + ratio); |
054d452e4e06
8081317: [NEWTEST] documented GC ratio tuning and new size options should be covered by regression tests
mchernov
parents:
diff
changeset
|
114 |
vmOptions.add("-version"); |
054d452e4e06
8081317: [NEWTEST] documented GC ratio tuning and new size options should be covered by regression tests
mchernov
parents:
diff
changeset
|
115 |
|
054d452e4e06
8081317: [NEWTEST] documented GC ratio tuning and new size options should be covered by regression tests
mchernov
parents:
diff
changeset
|
116 |
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
|
117 |
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
|
118 |
|
054d452e4e06
8081317: [NEWTEST] documented GC ratio tuning and new size options should be covered by regression tests
mchernov
parents:
diff
changeset
|
119 |
analyzer.shouldHaveExitValue(1); |
054d452e4e06
8081317: [NEWTEST] documented GC ratio tuning and new size options should be covered by regression tests
mchernov
parents:
diff
changeset
|
120 |
analyzer.shouldContain("Error: Could not create the Java Virtual Machine."); |
054d452e4e06
8081317: [NEWTEST] documented GC ratio tuning and new size options should be covered by regression tests
mchernov
parents:
diff
changeset
|
121 |
} |
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 |
/** |
054d452e4e06
8081317: [NEWTEST] documented GC ratio tuning and new size options should be covered by regression tests
mchernov
parents:
diff
changeset
|
124 |
* Verify that actual survivor space usage ratio conforms specified TargetSurvivorRatio |
054d452e4e06
8081317: [NEWTEST] documented GC ratio tuning and new size options should be covered by regression tests
mchernov
parents:
diff
changeset
|
125 |
* |
054d452e4e06
8081317: [NEWTEST] documented GC ratio tuning and new size options should be covered by regression tests
mchernov
parents:
diff
changeset
|
126 |
* @param ratio value of TargetSurvivorRatio |
054d452e4e06
8081317: [NEWTEST] documented GC ratio tuning and new size options should be covered by regression tests
mchernov
parents:
diff
changeset
|
127 |
* @param options additional VM options |
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 |
public static void positiveTest(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
|
130 |
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
|
131 |
Collections.addAll(vmOptions, |
054d452e4e06
8081317: [NEWTEST] documented GC ratio tuning and new size options should be covered by regression tests
mchernov
parents:
diff
changeset
|
132 |
"-Xbootclasspath/a:.", |
40244
b3055c216762
8136930: Simplify use of module-system options by custom launchers
hseigel
parents:
39226
diff
changeset
|
133 |
"--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
|
134 |
"-XX:+UnlockDiagnosticVMOptions", |
054d452e4e06
8081317: [NEWTEST] documented GC ratio tuning and new size options should be covered by regression tests
mchernov
parents:
diff
changeset
|
135 |
"-XX:+WhiteBoxAPI", |
054d452e4e06
8081317: [NEWTEST] documented GC ratio tuning and new size options should be covered by regression tests
mchernov
parents:
diff
changeset
|
136 |
"-XX:+UseAdaptiveSizePolicy", |
35061 | 137 |
"-Xlog:gc+age=trace", |
32625
054d452e4e06
8081317: [NEWTEST] documented GC ratio tuning and new size options should be covered by regression tests
mchernov
parents:
diff
changeset
|
138 |
"-XX:MaxTenuringThreshold=" + MAX_TENURING_THRESHOLD, |
054d452e4e06
8081317: [NEWTEST] documented GC ratio tuning and new size options should be covered by regression tests
mchernov
parents:
diff
changeset
|
139 |
"-XX:NewSize=" + MAX_NEW_SIZE, |
054d452e4e06
8081317: [NEWTEST] documented GC ratio tuning and new size options should be covered by regression tests
mchernov
parents:
diff
changeset
|
140 |
"-XX:MaxNewSize=" + MAX_NEW_SIZE, |
054d452e4e06
8081317: [NEWTEST] documented GC ratio tuning and new size options should be covered by regression tests
mchernov
parents:
diff
changeset
|
141 |
"-XX:InitialHeapSize=" + 2 * MAX_NEW_SIZE, |
054d452e4e06
8081317: [NEWTEST] documented GC ratio tuning and new size options should be covered by regression tests
mchernov
parents:
diff
changeset
|
142 |
"-XX:MaxHeapSize=" + 2 * MAX_NEW_SIZE, |
054d452e4e06
8081317: [NEWTEST] documented GC ratio tuning and new size options should be covered by regression tests
mchernov
parents:
diff
changeset
|
143 |
"-XX:SurvivorRatio=" + SURVIVOR_RATIO, |
054d452e4e06
8081317: [NEWTEST] documented GC ratio tuning and new size options should be covered by regression tests
mchernov
parents:
diff
changeset
|
144 |
"-XX:TargetSurvivorRatio=" + ratio, |
054d452e4e06
8081317: [NEWTEST] documented GC ratio tuning and new size options should be covered by regression tests
mchernov
parents:
diff
changeset
|
145 |
// For reducing variance of survivor size. |
054d452e4e06
8081317: [NEWTEST] documented GC ratio tuning and new size options should be covered by regression tests
mchernov
parents:
diff
changeset
|
146 |
"-XX:TargetPLABWastePct=" + 1, |
054d452e4e06
8081317: [NEWTEST] documented GC ratio tuning and new size options should be covered by regression tests
mchernov
parents:
diff
changeset
|
147 |
TargetSurvivorRatioVerifier.class.getName(), |
054d452e4e06
8081317: [NEWTEST] documented GC ratio tuning and new size options should be covered by regression tests
mchernov
parents:
diff
changeset
|
148 |
Integer.toString(ratio) |
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 |
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
|
152 |
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
|
153 |
|
054d452e4e06
8081317: [NEWTEST] documented GC ratio tuning and new size options should be covered by regression tests
mchernov
parents:
diff
changeset
|
154 |
analyzer.shouldHaveExitValue(0); |
054d452e4e06
8081317: [NEWTEST] documented GC ratio tuning and new size options should be covered by regression tests
mchernov
parents:
diff
changeset
|
155 |
|
054d452e4e06
8081317: [NEWTEST] documented GC ratio tuning and new size options should be covered by regression tests
mchernov
parents:
diff
changeset
|
156 |
String output = analyzer.getOutput(); |
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 |
// Test avoids verification for parallel GC |
054d452e4e06
8081317: [NEWTEST] documented GC ratio tuning and new size options should be covered by regression tests
mchernov
parents:
diff
changeset
|
159 |
if (!output.contains(UNSUPPORTED_GC)) { |
054d452e4e06
8081317: [NEWTEST] documented GC ratio tuning and new size options should be covered by regression tests
mchernov
parents:
diff
changeset
|
160 |
// Two tests should be done - when actual ratio is lower than TargetSurvivorRatio |
054d452e4e06
8081317: [NEWTEST] documented GC ratio tuning and new size options should be covered by regression tests
mchernov
parents:
diff
changeset
|
161 |
// and when it is higher. We chech that output contains results for exactly two tests. |
054d452e4e06
8081317: [NEWTEST] documented GC ratio tuning and new size options should be covered by regression tests
mchernov
parents:
diff
changeset
|
162 |
List<Double> ratios = parseTestOutput(output); |
054d452e4e06
8081317: [NEWTEST] documented GC ratio tuning and new size options should be covered by regression tests
mchernov
parents:
diff
changeset
|
163 |
|
054d452e4e06
8081317: [NEWTEST] documented GC ratio tuning and new size options should be covered by regression tests
mchernov
parents:
diff
changeset
|
164 |
if (ratios.size() != 2) { |
054d452e4e06
8081317: [NEWTEST] documented GC ratio tuning and new size options should be covered by regression tests
mchernov
parents:
diff
changeset
|
165 |
System.out.println(output); |
054d452e4e06
8081317: [NEWTEST] documented GC ratio tuning and new size options should be covered by regression tests
mchernov
parents:
diff
changeset
|
166 |
throw new RuntimeException("Expected number of ratios extraced for output is 2," |
054d452e4e06
8081317: [NEWTEST] documented GC ratio tuning and new size options should be covered by regression tests
mchernov
parents:
diff
changeset
|
167 |
+ " but " + ratios.size() + " ratios were extracted"); |
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 |
|
054d452e4e06
8081317: [NEWTEST] documented GC ratio tuning and new size options should be covered by regression tests
mchernov
parents:
diff
changeset
|
170 |
// At the end of the first test survivor space usage ratio should lies between |
054d452e4e06
8081317: [NEWTEST] documented GC ratio tuning and new size options should be covered by regression tests
mchernov
parents:
diff
changeset
|
171 |
// TargetSurvivorRatio and TargetSurvivorRatio - 2*DELTA |
054d452e4e06
8081317: [NEWTEST] documented GC ratio tuning and new size options should be covered by regression tests
mchernov
parents:
diff
changeset
|
172 |
if (ratio < ratios.get(0) || ratio - ratios.get(0) > VARIANCE) { |
054d452e4e06
8081317: [NEWTEST] documented GC ratio tuning and new size options should be covered by regression tests
mchernov
parents:
diff
changeset
|
173 |
System.out.println(output); |
054d452e4e06
8081317: [NEWTEST] documented GC ratio tuning and new size options should be covered by regression tests
mchernov
parents:
diff
changeset
|
174 |
throw new RuntimeException("Survivor space usage ratio expected to be close to " |
054d452e4e06
8081317: [NEWTEST] documented GC ratio tuning and new size options should be covered by regression tests
mchernov
parents:
diff
changeset
|
175 |
+ ratio + ", but observed ratio is: " + ratios.get(0)); |
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 |
|
054d452e4e06
8081317: [NEWTEST] documented GC ratio tuning and new size options should be covered by regression tests
mchernov
parents:
diff
changeset
|
178 |
// After second test survivor space should be almost empty. |
054d452e4e06
8081317: [NEWTEST] documented GC ratio tuning and new size options should be covered by regression tests
mchernov
parents:
diff
changeset
|
179 |
if (ratios.get(1) > VARIANCE) { |
054d452e4e06
8081317: [NEWTEST] documented GC ratio tuning and new size options should be covered by regression tests
mchernov
parents:
diff
changeset
|
180 |
System.out.println(output); |
054d452e4e06
8081317: [NEWTEST] documented GC ratio tuning and new size options should be covered by regression tests
mchernov
parents:
diff
changeset
|
181 |
throw new RuntimeException("Survivor space expected to be empty due to " |
054d452e4e06
8081317: [NEWTEST] documented GC ratio tuning and new size options should be covered by regression tests
mchernov
parents:
diff
changeset
|
182 |
+ "TargetSurvivorRatio overlimit, however observed " |
054d452e4e06
8081317: [NEWTEST] documented GC ratio tuning and new size options should be covered by regression tests
mchernov
parents:
diff
changeset
|
183 |
+ "survivor space usage ratio is: " + ratios.get(1)); |
054d452e4e06
8081317: [NEWTEST] documented GC ratio tuning and new size options should be covered by regression tests
mchernov
parents:
diff
changeset
|
184 |
} |
054d452e4e06
8081317: [NEWTEST] documented GC ratio tuning and new size options should be covered by regression tests
mchernov
parents:
diff
changeset
|
185 |
} else { |
054d452e4e06
8081317: [NEWTEST] documented GC ratio tuning and new size options should be covered by regression tests
mchernov
parents:
diff
changeset
|
186 |
System.out.println("Selected GC does not support TargetSurvivorRatio option."); |
054d452e4e06
8081317: [NEWTEST] documented GC ratio tuning and new size options should be covered by regression tests
mchernov
parents:
diff
changeset
|
187 |
} |
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 |
|
054d452e4e06
8081317: [NEWTEST] documented GC ratio tuning and new size options should be covered by regression tests
mchernov
parents:
diff
changeset
|
190 |
/** |
054d452e4e06
8081317: [NEWTEST] documented GC ratio tuning and new size options should be covered by regression tests
mchernov
parents:
diff
changeset
|
191 |
* Parse output produced by TargetSurvivorRatioVerifier. |
054d452e4e06
8081317: [NEWTEST] documented GC ratio tuning and new size options should be covered by regression tests
mchernov
parents:
diff
changeset
|
192 |
* |
054d452e4e06
8081317: [NEWTEST] documented GC ratio tuning and new size options should be covered by regression tests
mchernov
parents:
diff
changeset
|
193 |
* @param output output obtained from TargetSurvivorRatioVerifier |
054d452e4e06
8081317: [NEWTEST] documented GC ratio tuning and new size options should be covered by regression tests
mchernov
parents:
diff
changeset
|
194 |
* @return list of parsed test results, where each result is an actual |
054d452e4e06
8081317: [NEWTEST] documented GC ratio tuning and new size options should be covered by regression tests
mchernov
parents:
diff
changeset
|
195 |
* survivor ratio after MaxTenuringThreshold minor GC cycles. |
054d452e4e06
8081317: [NEWTEST] documented GC ratio tuning and new size options should be covered by regression tests
mchernov
parents:
diff
changeset
|
196 |
*/ |
054d452e4e06
8081317: [NEWTEST] documented GC ratio tuning and new size options should be covered by regression tests
mchernov
parents:
diff
changeset
|
197 |
public static List<Double> parseTestOutput(String output) { |
054d452e4e06
8081317: [NEWTEST] documented GC ratio tuning and new size options should be covered by regression tests
mchernov
parents:
diff
changeset
|
198 |
List<Double> ratios = new LinkedList<Double>(); |
054d452e4e06
8081317: [NEWTEST] documented GC ratio tuning and new size options should be covered by regression tests
mchernov
parents:
diff
changeset
|
199 |
String lines[] = output.split("[\n\r]"); |
054d452e4e06
8081317: [NEWTEST] documented GC ratio tuning and new size options should be covered by regression tests
mchernov
parents:
diff
changeset
|
200 |
boolean testStarted = false; |
054d452e4e06
8081317: [NEWTEST] documented GC ratio tuning and new size options should be covered by regression tests
mchernov
parents:
diff
changeset
|
201 |
long survivorSize = 0; |
054d452e4e06
8081317: [NEWTEST] documented GC ratio tuning and new size options should be covered by regression tests
mchernov
parents:
diff
changeset
|
202 |
long survivorOccupancy = 0; |
054d452e4e06
8081317: [NEWTEST] documented GC ratio tuning and new size options should be covered by regression tests
mchernov
parents:
diff
changeset
|
203 |
int gcCount = 0; |
054d452e4e06
8081317: [NEWTEST] documented GC ratio tuning and new size options should be covered by regression tests
mchernov
parents:
diff
changeset
|
204 |
Pattern ageTableEntry = Pattern.compile(AGE_TABLE_ENTRY); |
054d452e4e06
8081317: [NEWTEST] documented GC ratio tuning and new size options should be covered by regression tests
mchernov
parents:
diff
changeset
|
205 |
Pattern maxSurvivorSize = Pattern.compile(MAX_SURVIVOR_SIZE); |
054d452e4e06
8081317: [NEWTEST] documented GC ratio tuning and new size options should be covered by regression tests
mchernov
parents:
diff
changeset
|
206 |
for (String line : lines) { |
054d452e4e06
8081317: [NEWTEST] documented GC ratio tuning and new size options should be covered by regression tests
mchernov
parents:
diff
changeset
|
207 |
if (Pattern.matches(MAX_SURVIVOR_SIZE, line)) { |
054d452e4e06
8081317: [NEWTEST] documented GC ratio tuning and new size options should be covered by regression tests
mchernov
parents:
diff
changeset
|
208 |
// We found estimated survivor space size |
054d452e4e06
8081317: [NEWTEST] documented GC ratio tuning and new size options should be covered by regression tests
mchernov
parents:
diff
changeset
|
209 |
Matcher m = maxSurvivorSize.matcher(line); |
054d452e4e06
8081317: [NEWTEST] documented GC ratio tuning and new size options should be covered by regression tests
mchernov
parents:
diff
changeset
|
210 |
m.find(); |
054d452e4e06
8081317: [NEWTEST] documented GC ratio tuning and new size options should be covered by regression tests
mchernov
parents:
diff
changeset
|
211 |
survivorSize = Long.valueOf(m.group(1)); |
054d452e4e06
8081317: [NEWTEST] documented GC ratio tuning and new size options should be covered by regression tests
mchernov
parents:
diff
changeset
|
212 |
} else if (line.contains(START_TEST) && !testStarted) { |
054d452e4e06
8081317: [NEWTEST] documented GC ratio tuning and new size options should be covered by regression tests
mchernov
parents:
diff
changeset
|
213 |
// Start collecting test results |
054d452e4e06
8081317: [NEWTEST] documented GC ratio tuning and new size options should be covered by regression tests
mchernov
parents:
diff
changeset
|
214 |
testStarted = true; |
054d452e4e06
8081317: [NEWTEST] documented GC ratio tuning and new size options should be covered by regression tests
mchernov
parents:
diff
changeset
|
215 |
gcCount = 0; |
054d452e4e06
8081317: [NEWTEST] documented GC ratio tuning and new size options should be covered by regression tests
mchernov
parents:
diff
changeset
|
216 |
} else if (testStarted) { |
054d452e4e06
8081317: [NEWTEST] documented GC ratio tuning and new size options should be covered by regression tests
mchernov
parents:
diff
changeset
|
217 |
if (line.contains(TENURING_DISTRIBUTION)) { |
054d452e4e06
8081317: [NEWTEST] documented GC ratio tuning and new size options should be covered by regression tests
mchernov
parents:
diff
changeset
|
218 |
// We found start of output emitted by -XX:+PrintTenuringDistribution |
054d452e4e06
8081317: [NEWTEST] documented GC ratio tuning and new size options should be covered by regression tests
mchernov
parents:
diff
changeset
|
219 |
// If it is associated with "MaxTenuringThreshold" GC cycle, then it's |
054d452e4e06
8081317: [NEWTEST] documented GC ratio tuning and new size options should be covered by regression tests
mchernov
parents:
diff
changeset
|
220 |
// time to report observed survivor usage ratio |
054d452e4e06
8081317: [NEWTEST] documented GC ratio tuning and new size options should be covered by regression tests
mchernov
parents:
diff
changeset
|
221 |
gcCount++; |
054d452e4e06
8081317: [NEWTEST] documented GC ratio tuning and new size options should be covered by regression tests
mchernov
parents:
diff
changeset
|
222 |
double survivorRatio = survivorOccupancy / (double) survivorSize; |
054d452e4e06
8081317: [NEWTEST] documented GC ratio tuning and new size options should be covered by regression tests
mchernov
parents:
diff
changeset
|
223 |
if (gcCount == MAX_TENURING_THRESHOLD || gcCount == MAX_TENURING_THRESHOLD * 2) { |
054d452e4e06
8081317: [NEWTEST] documented GC ratio tuning and new size options should be covered by regression tests
mchernov
parents:
diff
changeset
|
224 |
ratios.add(survivorRatio * 100.0); |
054d452e4e06
8081317: [NEWTEST] documented GC ratio tuning and new size options should be covered by regression tests
mchernov
parents:
diff
changeset
|
225 |
testStarted = false; |
054d452e4e06
8081317: [NEWTEST] documented GC ratio tuning and new size options should be covered by regression tests
mchernov
parents:
diff
changeset
|
226 |
} |
054d452e4e06
8081317: [NEWTEST] documented GC ratio tuning and new size options should be covered by regression tests
mchernov
parents:
diff
changeset
|
227 |
survivorOccupancy = 0; |
054d452e4e06
8081317: [NEWTEST] documented GC ratio tuning and new size options should be covered by regression tests
mchernov
parents:
diff
changeset
|
228 |
} else if (Pattern.matches(AGE_TABLE_ENTRY, line)) { |
054d452e4e06
8081317: [NEWTEST] documented GC ratio tuning and new size options should be covered by regression tests
mchernov
parents:
diff
changeset
|
229 |
// Obtain survivor space usage from "total" age table log entry |
054d452e4e06
8081317: [NEWTEST] documented GC ratio tuning and new size options should be covered by regression tests
mchernov
parents:
diff
changeset
|
230 |
Matcher m = ageTableEntry.matcher(line); |
054d452e4e06
8081317: [NEWTEST] documented GC ratio tuning and new size options should be covered by regression tests
mchernov
parents:
diff
changeset
|
231 |
m.find(); |
054d452e4e06
8081317: [NEWTEST] documented GC ratio tuning and new size options should be covered by regression tests
mchernov
parents:
diff
changeset
|
232 |
survivorOccupancy = Long.valueOf(m.group(3)); |
054d452e4e06
8081317: [NEWTEST] documented GC ratio tuning and new size options should be covered by regression tests
mchernov
parents:
diff
changeset
|
233 |
} else if (line.contains(END_TEST)) { |
054d452e4e06
8081317: [NEWTEST] documented GC ratio tuning and new size options should be covered by regression tests
mchernov
parents:
diff
changeset
|
234 |
// It is expected to find at least MaxTenuringThreshold GC events |
054d452e4e06
8081317: [NEWTEST] documented GC ratio tuning and new size options should be covered by regression tests
mchernov
parents:
diff
changeset
|
235 |
// until test end |
054d452e4e06
8081317: [NEWTEST] documented GC ratio tuning and new size options should be covered by regression tests
mchernov
parents:
diff
changeset
|
236 |
if (gcCount < MAX_TENURING_THRESHOLD) { |
054d452e4e06
8081317: [NEWTEST] documented GC ratio tuning and new size options should be covered by regression tests
mchernov
parents:
diff
changeset
|
237 |
throw new RuntimeException("Observed " + gcCount + " GC events, " |
054d452e4e06
8081317: [NEWTEST] documented GC ratio tuning and new size options should be covered by regression tests
mchernov
parents:
diff
changeset
|
238 |
+ "while it is expected to see at least " |
054d452e4e06
8081317: [NEWTEST] documented GC ratio tuning and new size options should be covered by regression tests
mchernov
parents:
diff
changeset
|
239 |
+ MAX_TENURING_THRESHOLD); |
054d452e4e06
8081317: [NEWTEST] documented GC ratio tuning and new size options should be covered by regression tests
mchernov
parents:
diff
changeset
|
240 |
} |
054d452e4e06
8081317: [NEWTEST] documented GC ratio tuning and new size options should be covered by regression tests
mchernov
parents:
diff
changeset
|
241 |
testStarted = false; |
054d452e4e06
8081317: [NEWTEST] documented GC ratio tuning and new size options should be covered by regression tests
mchernov
parents:
diff
changeset
|
242 |
} |
054d452e4e06
8081317: [NEWTEST] documented GC ratio tuning and new size options should be covered by regression tests
mchernov
parents:
diff
changeset
|
243 |
} |
054d452e4e06
8081317: [NEWTEST] documented GC ratio tuning and new size options should be covered by regression tests
mchernov
parents:
diff
changeset
|
244 |
} |
054d452e4e06
8081317: [NEWTEST] documented GC ratio tuning and new size options should be covered by regression tests
mchernov
parents:
diff
changeset
|
245 |
return ratios; |
054d452e4e06
8081317: [NEWTEST] documented GC ratio tuning and new size options should be covered by regression tests
mchernov
parents:
diff
changeset
|
246 |
} |
054d452e4e06
8081317: [NEWTEST] documented GC ratio tuning and new size options should be covered by regression tests
mchernov
parents:
diff
changeset
|
247 |
|
054d452e4e06
8081317: [NEWTEST] documented GC ratio tuning and new size options should be covered by regression tests
mchernov
parents:
diff
changeset
|
248 |
public static class TargetSurvivorRatioVerifier { |
054d452e4e06
8081317: [NEWTEST] documented GC ratio tuning and new size options should be covered by regression tests
mchernov
parents:
diff
changeset
|
249 |
|
054d452e4e06
8081317: [NEWTEST] documented GC ratio tuning and new size options should be covered by regression tests
mchernov
parents:
diff
changeset
|
250 |
static final WhiteBox wb = WhiteBox.getWhiteBox(); |
41092
c388d897472d
8165889: Remove jdk.test.lib.unsafe.UnsafeHelper
gtriantafill
parents:
40855
diff
changeset
|
251 |
static final Unsafe unsafe = Unsafe.getUnsafe(); |
32625
054d452e4e06
8081317: [NEWTEST] documented GC ratio tuning and new size options should be covered by regression tests
mchernov
parents:
diff
changeset
|
252 |
|
054d452e4e06
8081317: [NEWTEST] documented GC ratio tuning and new size options should be covered by regression tests
mchernov
parents:
diff
changeset
|
253 |
// Desired size of memory allocated at once |
054d452e4e06
8081317: [NEWTEST] documented GC ratio tuning and new size options should be covered by regression tests
mchernov
parents:
diff
changeset
|
254 |
public static final int CHUNK_SIZE = 1024; |
054d452e4e06
8081317: [NEWTEST] documented GC ratio tuning and new size options should be covered by regression tests
mchernov
parents:
diff
changeset
|
255 |
// Length of byte[] array that will have occupy CHUNK_SIZE bytes in heap |
054d452e4e06
8081317: [NEWTEST] documented GC ratio tuning and new size options should be covered by regression tests
mchernov
parents:
diff
changeset
|
256 |
public static final int ARRAY_LENGTH = CHUNK_SIZE - Unsafe.ARRAY_BYTE_BASE_OFFSET; |
054d452e4e06
8081317: [NEWTEST] documented GC ratio tuning and new size options should be covered by regression tests
mchernov
parents:
diff
changeset
|
257 |
|
054d452e4e06
8081317: [NEWTEST] documented GC ratio tuning and new size options should be covered by regression tests
mchernov
parents:
diff
changeset
|
258 |
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
|
259 |
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
|
260 |
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
|
261 |
} |
054d452e4e06
8081317: [NEWTEST] documented GC ratio tuning and new size options should be covered by regression tests
mchernov
parents:
diff
changeset
|
262 |
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
|
263 |
System.out.println(UNSUPPORTED_GC); |
054d452e4e06
8081317: [NEWTEST] documented GC ratio tuning and new size options should be covered by regression tests
mchernov
parents:
diff
changeset
|
264 |
return; |
054d452e4e06
8081317: [NEWTEST] documented GC ratio tuning and new size options should be covered by regression tests
mchernov
parents:
diff
changeset
|
265 |
} |
054d452e4e06
8081317: [NEWTEST] documented GC ratio tuning and new size options should be covered by regression tests
mchernov
parents:
diff
changeset
|
266 |
|
054d452e4e06
8081317: [NEWTEST] documented GC ratio tuning and new size options should be covered by regression tests
mchernov
parents:
diff
changeset
|
267 |
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
|
268 |
long maxSurvivorSize = getMaxSurvivorSize(); |
054d452e4e06
8081317: [NEWTEST] documented GC ratio tuning and new size options should be covered by regression tests
mchernov
parents:
diff
changeset
|
269 |
System.out.println("Max survivor size: " + maxSurvivorSize); |
054d452e4e06
8081317: [NEWTEST] documented GC ratio tuning and new size options should be covered by regression tests
mchernov
parents:
diff
changeset
|
270 |
|
054d452e4e06
8081317: [NEWTEST] documented GC ratio tuning and new size options should be covered by regression tests
mchernov
parents:
diff
changeset
|
271 |
allocateMemory(ratio - DELTA, maxSurvivorSize); |
054d452e4e06
8081317: [NEWTEST] documented GC ratio tuning and new size options should be covered by regression tests
mchernov
parents:
diff
changeset
|
272 |
allocateMemory(ratio + DELTA, maxSurvivorSize); |
054d452e4e06
8081317: [NEWTEST] documented GC ratio tuning and new size options should be covered by regression tests
mchernov
parents:
diff
changeset
|
273 |
} |
054d452e4e06
8081317: [NEWTEST] documented GC ratio tuning and new size options should be covered by regression tests
mchernov
parents:
diff
changeset
|
274 |
|
054d452e4e06
8081317: [NEWTEST] documented GC ratio tuning and new size options should be covered by regression tests
mchernov
parents:
diff
changeset
|
275 |
/** |
054d452e4e06
8081317: [NEWTEST] documented GC ratio tuning and new size options should be covered by regression tests
mchernov
parents:
diff
changeset
|
276 |
* Allocate (<b>ratio</b> * <b>maxSize</b> / 100) bytes of objects |
054d452e4e06
8081317: [NEWTEST] documented GC ratio tuning and new size options should be covered by regression tests
mchernov
parents:
diff
changeset
|
277 |
* and force at least "MaxTenuringThreshold" minor GCs. |
054d452e4e06
8081317: [NEWTEST] documented GC ratio tuning and new size options should be covered by regression tests
mchernov
parents:
diff
changeset
|
278 |
* |
054d452e4e06
8081317: [NEWTEST] documented GC ratio tuning and new size options should be covered by regression tests
mchernov
parents:
diff
changeset
|
279 |
* @param ratio ratio used to calculate how many objects should be allocated |
054d452e4e06
8081317: [NEWTEST] documented GC ratio tuning and new size options should be covered by regression tests
mchernov
parents:
diff
changeset
|
280 |
* @param maxSize estimated max survivor space size |
054d452e4e06
8081317: [NEWTEST] documented GC ratio tuning and new size options should be covered by regression tests
mchernov
parents:
diff
changeset
|
281 |
*/ |
054d452e4e06
8081317: [NEWTEST] documented GC ratio tuning and new size options should be covered by regression tests
mchernov
parents:
diff
changeset
|
282 |
public static void allocateMemory(double ratio, long maxSize) throws Exception { |
054d452e4e06
8081317: [NEWTEST] documented GC ratio tuning and new size options should be covered by regression tests
mchernov
parents:
diff
changeset
|
283 |
GarbageCollectorMXBean youngGCBean = GCTypes.YoungGCType.getYoungGCBean(); |
054d452e4e06
8081317: [NEWTEST] documented GC ratio tuning and new size options should be covered by regression tests
mchernov
parents:
diff
changeset
|
284 |
long garbageSize = (long) (maxSize * (ratio / 100.0)); |
054d452e4e06
8081317: [NEWTEST] documented GC ratio tuning and new size options should be covered by regression tests
mchernov
parents:
diff
changeset
|
285 |
int arrayLength = (int) (garbageSize / CHUNK_SIZE); |
054d452e4e06
8081317: [NEWTEST] documented GC ratio tuning and new size options should be covered by regression tests
mchernov
parents:
diff
changeset
|
286 |
AllocationHelper allocator = new AllocationHelper(1, arrayLength, ARRAY_LENGTH, null); |
054d452e4e06
8081317: [NEWTEST] documented GC ratio tuning and new size options should be covered by regression tests
mchernov
parents:
diff
changeset
|
287 |
|
054d452e4e06
8081317: [NEWTEST] documented GC ratio tuning and new size options should be covered by regression tests
mchernov
parents:
diff
changeset
|
288 |
System.out.println(START_TEST); |
054d452e4e06
8081317: [NEWTEST] documented GC ratio tuning and new size options should be covered by regression tests
mchernov
parents:
diff
changeset
|
289 |
System.gc(); |
054d452e4e06
8081317: [NEWTEST] documented GC ratio tuning and new size options should be covered by regression tests
mchernov
parents:
diff
changeset
|
290 |
final long initialGcId = youngGCBean.getCollectionCount(); |
054d452e4e06
8081317: [NEWTEST] documented GC ratio tuning and new size options should be covered by regression tests
mchernov
parents:
diff
changeset
|
291 |
// allocate memory |
054d452e4e06
8081317: [NEWTEST] documented GC ratio tuning and new size options should be covered by regression tests
mchernov
parents:
diff
changeset
|
292 |
allocator.allocateMemoryAndVerify(); |
054d452e4e06
8081317: [NEWTEST] documented GC ratio tuning and new size options should be covered by regression tests
mchernov
parents:
diff
changeset
|
293 |
|
054d452e4e06
8081317: [NEWTEST] documented GC ratio tuning and new size options should be covered by regression tests
mchernov
parents:
diff
changeset
|
294 |
// force minor GC |
054d452e4e06
8081317: [NEWTEST] documented GC ratio tuning and new size options should be covered by regression tests
mchernov
parents:
diff
changeset
|
295 |
while (youngGCBean.getCollectionCount() <= initialGcId + MAX_TENURING_THRESHOLD * 2) { |
054d452e4e06
8081317: [NEWTEST] documented GC ratio tuning and new size options should be covered by regression tests
mchernov
parents:
diff
changeset
|
296 |
byte b[] = 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
|
297 |
} |
054d452e4e06
8081317: [NEWTEST] documented GC ratio tuning and new size options should be covered by regression tests
mchernov
parents:
diff
changeset
|
298 |
|
054d452e4e06
8081317: [NEWTEST] documented GC ratio tuning and new size options should be covered by regression tests
mchernov
parents:
diff
changeset
|
299 |
allocator.release(); |
054d452e4e06
8081317: [NEWTEST] documented GC ratio tuning and new size options should be covered by regression tests
mchernov
parents:
diff
changeset
|
300 |
System.out.println(END_TEST); |
054d452e4e06
8081317: [NEWTEST] documented GC ratio tuning and new size options should be covered by regression tests
mchernov
parents:
diff
changeset
|
301 |
} |
054d452e4e06
8081317: [NEWTEST] documented GC ratio tuning and new size options should be covered by regression tests
mchernov
parents:
diff
changeset
|
302 |
|
054d452e4e06
8081317: [NEWTEST] documented GC ratio tuning and new size options should be covered by regression tests
mchernov
parents:
diff
changeset
|
303 |
/** |
054d452e4e06
8081317: [NEWTEST] documented GC ratio tuning and new size options should be covered by regression tests
mchernov
parents:
diff
changeset
|
304 |
* Estimate max survivor space size. |
054d452e4e06
8081317: [NEWTEST] documented GC ratio tuning and new size options should be covered by regression tests
mchernov
parents:
diff
changeset
|
305 |
* |
054d452e4e06
8081317: [NEWTEST] documented GC ratio tuning and new size options should be covered by regression tests
mchernov
parents:
diff
changeset
|
306 |
* For non-G1 GC returns value reported by MemoryPoolMXBean |
054d452e4e06
8081317: [NEWTEST] documented GC ratio tuning and new size options should be covered by regression tests
mchernov
parents:
diff
changeset
|
307 |
* associated with survivor space. |
054d452e4e06
8081317: [NEWTEST] documented GC ratio tuning and new size options should be covered by regression tests
mchernov
parents:
diff
changeset
|
308 |
* For G1 GC return max number of survivor regions * region size. |
054d452e4e06
8081317: [NEWTEST] documented GC ratio tuning and new size options should be covered by regression tests
mchernov
parents:
diff
changeset
|
309 |
* Number if survivor regions estimated from MaxNewSize and SurvivorRatio. |
054d452e4e06
8081317: [NEWTEST] documented GC ratio tuning and new size options should be covered by regression tests
mchernov
parents:
diff
changeset
|
310 |
*/ |
054d452e4e06
8081317: [NEWTEST] documented GC ratio tuning and new size options should be covered by regression tests
mchernov
parents:
diff
changeset
|
311 |
public static long getMaxSurvivorSize() { |
054d452e4e06
8081317: [NEWTEST] documented GC ratio tuning and new size options should be covered by regression tests
mchernov
parents:
diff
changeset
|
312 |
if (GCTypes.YoungGCType.getYoungGCType() == GCTypes.YoungGCType.G1) { |
054d452e4e06
8081317: [NEWTEST] documented GC ratio tuning and new size options should be covered by regression tests
mchernov
parents:
diff
changeset
|
313 |
int youngLength = (int) Math.max(MAX_NEW_SIZE / wb.g1RegionSize(), 1); |
054d452e4e06
8081317: [NEWTEST] documented GC ratio tuning and new size options should be covered by regression tests
mchernov
parents:
diff
changeset
|
314 |
return (long) Math.ceil(youngLength / (double) SURVIVOR_RATIO) * wb.g1RegionSize(); |
054d452e4e06
8081317: [NEWTEST] documented GC ratio tuning and new size options should be covered by regression tests
mchernov
parents:
diff
changeset
|
315 |
} else { |
054d452e4e06
8081317: [NEWTEST] documented GC ratio tuning and new size options should be covered by regression tests
mchernov
parents:
diff
changeset
|
316 |
return HeapRegionUsageTool.getSurvivorUsage().getMax(); |
054d452e4e06
8081317: [NEWTEST] documented GC ratio tuning and new size options should be covered by regression tests
mchernov
parents:
diff
changeset
|
317 |
} |
054d452e4e06
8081317: [NEWTEST] documented GC ratio tuning and new size options should be covered by regression tests
mchernov
parents:
diff
changeset
|
318 |
} |
054d452e4e06
8081317: [NEWTEST] documented GC ratio tuning and new size options should be covered by regression tests
mchernov
parents:
diff
changeset
|
319 |
} |
054d452e4e06
8081317: [NEWTEST] documented GC ratio tuning and new size options should be covered by regression tests
mchernov
parents:
diff
changeset
|
320 |
} |