Mercurial > hg > truffle
annotate test/gc/arguments/TestMaxNewSize.java @ 20543:e7d0505c8a30
8059758: Footprint regressions with JDK-8038423
Summary: Changes in JDK-8038423 always initialize (zero out) virtual memory used for auxiliary data structures. This causes a footprint regression for G1 in startup benchmarks. This is because they do not touch that memory at all, so the operating system does not actually commit these pages. The fix is to, if the initialization value of the data structures matches the default value of just committed memory (=0), do not do anything.
Reviewed-by: jwilhelm, brutisso
author | tschatzl |
---|---|
date | Fri, 10 Oct 2014 15:51:58 +0200 |
parents | 8f07aa079343 |
children |
rev | line source |
---|---|
13060
8f07aa079343
8016309: assert(eden_size > 0 && survivor_size > 0) failed: just checking
jwilhelm
parents:
diff
changeset
|
1 /* |
8f07aa079343
8016309: assert(eden_size > 0 && survivor_size > 0) failed: just checking
jwilhelm
parents:
diff
changeset
|
2 * Copyright (c) 2013, Oracle and/or its affiliates. All rights reserved. |
8f07aa079343
8016309: assert(eden_size > 0 && survivor_size > 0) failed: just checking
jwilhelm
parents:
diff
changeset
|
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. |
8f07aa079343
8016309: assert(eden_size > 0 && survivor_size > 0) failed: just checking
jwilhelm
parents:
diff
changeset
|
4 * |
8f07aa079343
8016309: assert(eden_size > 0 && survivor_size > 0) failed: just checking
jwilhelm
parents:
diff
changeset
|
5 * This code is free software; you can redistribute it and/or modify it |
8f07aa079343
8016309: assert(eden_size > 0 && survivor_size > 0) failed: just checking
jwilhelm
parents:
diff
changeset
|
6 * under the terms of the GNU General Public License version 2 only, as |
8f07aa079343
8016309: assert(eden_size > 0 && survivor_size > 0) failed: just checking
jwilhelm
parents:
diff
changeset
|
7 * published by the Free Software Foundation. |
8f07aa079343
8016309: assert(eden_size > 0 && survivor_size > 0) failed: just checking
jwilhelm
parents:
diff
changeset
|
8 * |
8f07aa079343
8016309: assert(eden_size > 0 && survivor_size > 0) failed: just checking
jwilhelm
parents:
diff
changeset
|
9 * This code is distributed in the hope that it will be useful, but WITHOUT |
8f07aa079343
8016309: assert(eden_size > 0 && survivor_size > 0) failed: just checking
jwilhelm
parents:
diff
changeset
|
10 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or |
8f07aa079343
8016309: assert(eden_size > 0 && survivor_size > 0) failed: just checking
jwilhelm
parents:
diff
changeset
|
11 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License |
8f07aa079343
8016309: assert(eden_size > 0 && survivor_size > 0) failed: just checking
jwilhelm
parents:
diff
changeset
|
12 * version 2 for more details (a copy is included in the LICENSE file that |
8f07aa079343
8016309: assert(eden_size > 0 && survivor_size > 0) failed: just checking
jwilhelm
parents:
diff
changeset
|
13 * accompanied this code). |
8f07aa079343
8016309: assert(eden_size > 0 && survivor_size > 0) failed: just checking
jwilhelm
parents:
diff
changeset
|
14 * |
8f07aa079343
8016309: assert(eden_size > 0 && survivor_size > 0) failed: just checking
jwilhelm
parents:
diff
changeset
|
15 * You should have received a copy of the GNU General Public License version |
8f07aa079343
8016309: assert(eden_size > 0 && survivor_size > 0) failed: just checking
jwilhelm
parents:
diff
changeset
|
16 * 2 along with this work; if not, write to the Free Software Foundation, |
8f07aa079343
8016309: assert(eden_size > 0 && survivor_size > 0) failed: just checking
jwilhelm
parents:
diff
changeset
|
17 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. |
8f07aa079343
8016309: assert(eden_size > 0 && survivor_size > 0) failed: just checking
jwilhelm
parents:
diff
changeset
|
18 * |
8f07aa079343
8016309: assert(eden_size > 0 && survivor_size > 0) failed: just checking
jwilhelm
parents:
diff
changeset
|
19 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA |
8f07aa079343
8016309: assert(eden_size > 0 && survivor_size > 0) failed: just checking
jwilhelm
parents:
diff
changeset
|
20 * or visit www.oracle.com if you need additional information or have any |
8f07aa079343
8016309: assert(eden_size > 0 && survivor_size > 0) failed: just checking
jwilhelm
parents:
diff
changeset
|
21 * questions. |
8f07aa079343
8016309: assert(eden_size > 0 && survivor_size > 0) failed: just checking
jwilhelm
parents:
diff
changeset
|
22 */ |
8f07aa079343
8016309: assert(eden_size > 0 && survivor_size > 0) failed: just checking
jwilhelm
parents:
diff
changeset
|
23 |
8f07aa079343
8016309: assert(eden_size > 0 && survivor_size > 0) failed: just checking
jwilhelm
parents:
diff
changeset
|
24 /* |
8f07aa079343
8016309: assert(eden_size > 0 && survivor_size > 0) failed: just checking
jwilhelm
parents:
diff
changeset
|
25 * @test TestMaxNewSize |
8f07aa079343
8016309: assert(eden_size > 0 && survivor_size > 0) failed: just checking
jwilhelm
parents:
diff
changeset
|
26 * @key gc |
8f07aa079343
8016309: assert(eden_size > 0 && survivor_size > 0) failed: just checking
jwilhelm
parents:
diff
changeset
|
27 * @bug 7057939 |
8f07aa079343
8016309: assert(eden_size > 0 && survivor_size > 0) failed: just checking
jwilhelm
parents:
diff
changeset
|
28 * @summary Make sure that MaxNewSize always has a useful value after argument |
8f07aa079343
8016309: assert(eden_size > 0 && survivor_size > 0) failed: just checking
jwilhelm
parents:
diff
changeset
|
29 * processing. |
8f07aa079343
8016309: assert(eden_size > 0 && survivor_size > 0) failed: just checking
jwilhelm
parents:
diff
changeset
|
30 * @library /testlibrary |
8f07aa079343
8016309: assert(eden_size > 0 && survivor_size > 0) failed: just checking
jwilhelm
parents:
diff
changeset
|
31 * @build TestMaxNewSize |
8f07aa079343
8016309: assert(eden_size > 0 && survivor_size > 0) failed: just checking
jwilhelm
parents:
diff
changeset
|
32 * @run main TestMaxNewSize -XX:+UseSerialGC |
8f07aa079343
8016309: assert(eden_size > 0 && survivor_size > 0) failed: just checking
jwilhelm
parents:
diff
changeset
|
33 * @run main TestMaxNewSize -XX:+UseParallelGC |
8f07aa079343
8016309: assert(eden_size > 0 && survivor_size > 0) failed: just checking
jwilhelm
parents:
diff
changeset
|
34 * @run main TestMaxNewSize -XX:+UseConcMarkSweepGC |
8f07aa079343
8016309: assert(eden_size > 0 && survivor_size > 0) failed: just checking
jwilhelm
parents:
diff
changeset
|
35 * @run main TestMaxNewSize -XX:+UseG1GC |
8f07aa079343
8016309: assert(eden_size > 0 && survivor_size > 0) failed: just checking
jwilhelm
parents:
diff
changeset
|
36 * @author thomas.schatzl@oracle.com, jesper.wilhelmsson@oracle.com |
8f07aa079343
8016309: assert(eden_size > 0 && survivor_size > 0) failed: just checking
jwilhelm
parents:
diff
changeset
|
37 */ |
8f07aa079343
8016309: assert(eden_size > 0 && survivor_size > 0) failed: just checking
jwilhelm
parents:
diff
changeset
|
38 |
8f07aa079343
8016309: assert(eden_size > 0 && survivor_size > 0) failed: just checking
jwilhelm
parents:
diff
changeset
|
39 import java.util.regex.Matcher; |
8f07aa079343
8016309: assert(eden_size > 0 && survivor_size > 0) failed: just checking
jwilhelm
parents:
diff
changeset
|
40 import java.util.regex.Pattern; |
8f07aa079343
8016309: assert(eden_size > 0 && survivor_size > 0) failed: just checking
jwilhelm
parents:
diff
changeset
|
41 |
8f07aa079343
8016309: assert(eden_size > 0 && survivor_size > 0) failed: just checking
jwilhelm
parents:
diff
changeset
|
42 import java.math.BigInteger; |
8f07aa079343
8016309: assert(eden_size > 0 && survivor_size > 0) failed: just checking
jwilhelm
parents:
diff
changeset
|
43 |
8f07aa079343
8016309: assert(eden_size > 0 && survivor_size > 0) failed: just checking
jwilhelm
parents:
diff
changeset
|
44 import java.util.ArrayList; |
8f07aa079343
8016309: assert(eden_size > 0 && survivor_size > 0) failed: just checking
jwilhelm
parents:
diff
changeset
|
45 import java.util.Arrays; |
8f07aa079343
8016309: assert(eden_size > 0 && survivor_size > 0) failed: just checking
jwilhelm
parents:
diff
changeset
|
46 |
8f07aa079343
8016309: assert(eden_size > 0 && survivor_size > 0) failed: just checking
jwilhelm
parents:
diff
changeset
|
47 import com.oracle.java.testlibrary.*; |
8f07aa079343
8016309: assert(eden_size > 0 && survivor_size > 0) failed: just checking
jwilhelm
parents:
diff
changeset
|
48 |
8f07aa079343
8016309: assert(eden_size > 0 && survivor_size > 0) failed: just checking
jwilhelm
parents:
diff
changeset
|
49 public class TestMaxNewSize { |
8f07aa079343
8016309: assert(eden_size > 0 && survivor_size > 0) failed: just checking
jwilhelm
parents:
diff
changeset
|
50 |
8f07aa079343
8016309: assert(eden_size > 0 && survivor_size > 0) failed: just checking
jwilhelm
parents:
diff
changeset
|
51 private static void checkMaxNewSize(String[] flags, int heapsize) throws Exception { |
8f07aa079343
8016309: assert(eden_size > 0 && survivor_size > 0) failed: just checking
jwilhelm
parents:
diff
changeset
|
52 BigInteger actual = new BigInteger(getMaxNewSize(flags)); |
8f07aa079343
8016309: assert(eden_size > 0 && survivor_size > 0) failed: just checking
jwilhelm
parents:
diff
changeset
|
53 System.out.println(actual); |
8f07aa079343
8016309: assert(eden_size > 0 && survivor_size > 0) failed: just checking
jwilhelm
parents:
diff
changeset
|
54 if (actual.compareTo(new BigInteger((new Long(heapsize)).toString())) == 1) { |
8f07aa079343
8016309: assert(eden_size > 0 && survivor_size > 0) failed: just checking
jwilhelm
parents:
diff
changeset
|
55 throw new RuntimeException("MaxNewSize value set to \"" + actual + |
8f07aa079343
8016309: assert(eden_size > 0 && survivor_size > 0) failed: just checking
jwilhelm
parents:
diff
changeset
|
56 "\", expected otherwise when running with the following flags: " + Arrays.asList(flags).toString()); |
8f07aa079343
8016309: assert(eden_size > 0 && survivor_size > 0) failed: just checking
jwilhelm
parents:
diff
changeset
|
57 } |
8f07aa079343
8016309: assert(eden_size > 0 && survivor_size > 0) failed: just checking
jwilhelm
parents:
diff
changeset
|
58 } |
8f07aa079343
8016309: assert(eden_size > 0 && survivor_size > 0) failed: just checking
jwilhelm
parents:
diff
changeset
|
59 |
8f07aa079343
8016309: assert(eden_size > 0 && survivor_size > 0) failed: just checking
jwilhelm
parents:
diff
changeset
|
60 private static void checkIncompatibleNewSize(String[] flags) throws Exception { |
8f07aa079343
8016309: assert(eden_size > 0 && survivor_size > 0) failed: just checking
jwilhelm
parents:
diff
changeset
|
61 ArrayList<String> finalargs = new ArrayList<String>(); |
8f07aa079343
8016309: assert(eden_size > 0 && survivor_size > 0) failed: just checking
jwilhelm
parents:
diff
changeset
|
62 finalargs.addAll(Arrays.asList(flags)); |
8f07aa079343
8016309: assert(eden_size > 0 && survivor_size > 0) failed: just checking
jwilhelm
parents:
diff
changeset
|
63 finalargs.add("-version"); |
8f07aa079343
8016309: assert(eden_size > 0 && survivor_size > 0) failed: just checking
jwilhelm
parents:
diff
changeset
|
64 |
8f07aa079343
8016309: assert(eden_size > 0 && survivor_size > 0) failed: just checking
jwilhelm
parents:
diff
changeset
|
65 ProcessBuilder pb = ProcessTools.createJavaProcessBuilder(finalargs.toArray(new String[0])); |
8f07aa079343
8016309: assert(eden_size > 0 && survivor_size > 0) failed: just checking
jwilhelm
parents:
diff
changeset
|
66 OutputAnalyzer output = new OutputAnalyzer(pb.start()); |
8f07aa079343
8016309: assert(eden_size > 0 && survivor_size > 0) failed: just checking
jwilhelm
parents:
diff
changeset
|
67 output.shouldContain("Initial young gen size set larger than the maximum young gen size"); |
8f07aa079343
8016309: assert(eden_size > 0 && survivor_size > 0) failed: just checking
jwilhelm
parents:
diff
changeset
|
68 } |
8f07aa079343
8016309: assert(eden_size > 0 && survivor_size > 0) failed: just checking
jwilhelm
parents:
diff
changeset
|
69 |
8f07aa079343
8016309: assert(eden_size > 0 && survivor_size > 0) failed: just checking
jwilhelm
parents:
diff
changeset
|
70 private static boolean isRunningG1(String[] args) { |
8f07aa079343
8016309: assert(eden_size > 0 && survivor_size > 0) failed: just checking
jwilhelm
parents:
diff
changeset
|
71 for (int i = 0; i < args.length; i++) { |
8f07aa079343
8016309: assert(eden_size > 0 && survivor_size > 0) failed: just checking
jwilhelm
parents:
diff
changeset
|
72 if (args[i].contains("+UseG1GC")) { |
8f07aa079343
8016309: assert(eden_size > 0 && survivor_size > 0) failed: just checking
jwilhelm
parents:
diff
changeset
|
73 return true; |
8f07aa079343
8016309: assert(eden_size > 0 && survivor_size > 0) failed: just checking
jwilhelm
parents:
diff
changeset
|
74 } |
8f07aa079343
8016309: assert(eden_size > 0 && survivor_size > 0) failed: just checking
jwilhelm
parents:
diff
changeset
|
75 } |
8f07aa079343
8016309: assert(eden_size > 0 && survivor_size > 0) failed: just checking
jwilhelm
parents:
diff
changeset
|
76 return false; |
8f07aa079343
8016309: assert(eden_size > 0 && survivor_size > 0) failed: just checking
jwilhelm
parents:
diff
changeset
|
77 } |
8f07aa079343
8016309: assert(eden_size > 0 && survivor_size > 0) failed: just checking
jwilhelm
parents:
diff
changeset
|
78 |
8f07aa079343
8016309: assert(eden_size > 0 && survivor_size > 0) failed: just checking
jwilhelm
parents:
diff
changeset
|
79 private static String getMaxNewSize(String[] flags) throws Exception { |
8f07aa079343
8016309: assert(eden_size > 0 && survivor_size > 0) failed: just checking
jwilhelm
parents:
diff
changeset
|
80 ArrayList<String> finalargs = new ArrayList<String>(); |
8f07aa079343
8016309: assert(eden_size > 0 && survivor_size > 0) failed: just checking
jwilhelm
parents:
diff
changeset
|
81 finalargs.addAll(Arrays.asList(flags)); |
8f07aa079343
8016309: assert(eden_size > 0 && survivor_size > 0) failed: just checking
jwilhelm
parents:
diff
changeset
|
82 if (isRunningG1(flags)) { |
8f07aa079343
8016309: assert(eden_size > 0 && survivor_size > 0) failed: just checking
jwilhelm
parents:
diff
changeset
|
83 finalargs.add("-XX:G1HeapRegionSize=1M"); |
8f07aa079343
8016309: assert(eden_size > 0 && survivor_size > 0) failed: just checking
jwilhelm
parents:
diff
changeset
|
84 } |
8f07aa079343
8016309: assert(eden_size > 0 && survivor_size > 0) failed: just checking
jwilhelm
parents:
diff
changeset
|
85 finalargs.add("-XX:+PrintFlagsFinal"); |
8f07aa079343
8016309: assert(eden_size > 0 && survivor_size > 0) failed: just checking
jwilhelm
parents:
diff
changeset
|
86 finalargs.add("-version"); |
8f07aa079343
8016309: assert(eden_size > 0 && survivor_size > 0) failed: just checking
jwilhelm
parents:
diff
changeset
|
87 |
8f07aa079343
8016309: assert(eden_size > 0 && survivor_size > 0) failed: just checking
jwilhelm
parents:
diff
changeset
|
88 ProcessBuilder pb = ProcessTools.createJavaProcessBuilder(finalargs.toArray(new String[0])); |
8f07aa079343
8016309: assert(eden_size > 0 && survivor_size > 0) failed: just checking
jwilhelm
parents:
diff
changeset
|
89 OutputAnalyzer output = new OutputAnalyzer(pb.start()); |
8f07aa079343
8016309: assert(eden_size > 0 && survivor_size > 0) failed: just checking
jwilhelm
parents:
diff
changeset
|
90 output.shouldHaveExitValue(0); |
8f07aa079343
8016309: assert(eden_size > 0 && survivor_size > 0) failed: just checking
jwilhelm
parents:
diff
changeset
|
91 String stdout = output.getStdout(); |
8f07aa079343
8016309: assert(eden_size > 0 && survivor_size > 0) failed: just checking
jwilhelm
parents:
diff
changeset
|
92 //System.out.println(stdout); |
8f07aa079343
8016309: assert(eden_size > 0 && survivor_size > 0) failed: just checking
jwilhelm
parents:
diff
changeset
|
93 return getFlagValue("MaxNewSize", stdout); |
8f07aa079343
8016309: assert(eden_size > 0 && survivor_size > 0) failed: just checking
jwilhelm
parents:
diff
changeset
|
94 } |
8f07aa079343
8016309: assert(eden_size > 0 && survivor_size > 0) failed: just checking
jwilhelm
parents:
diff
changeset
|
95 |
8f07aa079343
8016309: assert(eden_size > 0 && survivor_size > 0) failed: just checking
jwilhelm
parents:
diff
changeset
|
96 private static String getFlagValue(String flag, String where) { |
8f07aa079343
8016309: assert(eden_size > 0 && survivor_size > 0) failed: just checking
jwilhelm
parents:
diff
changeset
|
97 Matcher m = Pattern.compile(flag + "\\s+:?=\\s+\\d+").matcher(where); |
8f07aa079343
8016309: assert(eden_size > 0 && survivor_size > 0) failed: just checking
jwilhelm
parents:
diff
changeset
|
98 if (!m.find()) { |
8f07aa079343
8016309: assert(eden_size > 0 && survivor_size > 0) failed: just checking
jwilhelm
parents:
diff
changeset
|
99 throw new RuntimeException("Could not find value for flag " + flag + " in output string"); |
8f07aa079343
8016309: assert(eden_size > 0 && survivor_size > 0) failed: just checking
jwilhelm
parents:
diff
changeset
|
100 } |
8f07aa079343
8016309: assert(eden_size > 0 && survivor_size > 0) failed: just checking
jwilhelm
parents:
diff
changeset
|
101 String match = m.group(); |
8f07aa079343
8016309: assert(eden_size > 0 && survivor_size > 0) failed: just checking
jwilhelm
parents:
diff
changeset
|
102 return match.substring(match.lastIndexOf(" ") + 1, match.length()); |
8f07aa079343
8016309: assert(eden_size > 0 && survivor_size > 0) failed: just checking
jwilhelm
parents:
diff
changeset
|
103 } |
8f07aa079343
8016309: assert(eden_size > 0 && survivor_size > 0) failed: just checking
jwilhelm
parents:
diff
changeset
|
104 |
8f07aa079343
8016309: assert(eden_size > 0 && survivor_size > 0) failed: just checking
jwilhelm
parents:
diff
changeset
|
105 public static void main(String args[]) throws Exception { |
8f07aa079343
8016309: assert(eden_size > 0 && survivor_size > 0) failed: just checking
jwilhelm
parents:
diff
changeset
|
106 String gcName = args[0]; |
8f07aa079343
8016309: assert(eden_size > 0 && survivor_size > 0) failed: just checking
jwilhelm
parents:
diff
changeset
|
107 final int M32 = 32 * 1024 * 1024; |
8f07aa079343
8016309: assert(eden_size > 0 && survivor_size > 0) failed: just checking
jwilhelm
parents:
diff
changeset
|
108 final int M64 = 64 * 1024 * 1024; |
8f07aa079343
8016309: assert(eden_size > 0 && survivor_size > 0) failed: just checking
jwilhelm
parents:
diff
changeset
|
109 final int M96 = 96 * 1024 * 1024; |
8f07aa079343
8016309: assert(eden_size > 0 && survivor_size > 0) failed: just checking
jwilhelm
parents:
diff
changeset
|
110 final int M128 = 128 * 1024 * 1024; |
8f07aa079343
8016309: assert(eden_size > 0 && survivor_size > 0) failed: just checking
jwilhelm
parents:
diff
changeset
|
111 checkMaxNewSize(new String[] { gcName, "-Xmx128M" }, M128); |
8f07aa079343
8016309: assert(eden_size > 0 && survivor_size > 0) failed: just checking
jwilhelm
parents:
diff
changeset
|
112 checkMaxNewSize(new String[] { gcName, "-Xmx128M", "-XX:NewRatio=5" }, M128); |
8f07aa079343
8016309: assert(eden_size > 0 && survivor_size > 0) failed: just checking
jwilhelm
parents:
diff
changeset
|
113 checkMaxNewSize(new String[] { gcName, "-Xmx128M", "-XX:NewSize=32M" }, M128); |
8f07aa079343
8016309: assert(eden_size > 0 && survivor_size > 0) failed: just checking
jwilhelm
parents:
diff
changeset
|
114 checkMaxNewSize(new String[] { gcName, "-Xmx128M", "-XX:OldSize=96M" }, M128); |
8f07aa079343
8016309: assert(eden_size > 0 && survivor_size > 0) failed: just checking
jwilhelm
parents:
diff
changeset
|
115 checkMaxNewSize(new String[] { gcName, "-Xmx128M", "-XX:MaxNewSize=32M" }, M32); |
8f07aa079343
8016309: assert(eden_size > 0 && survivor_size > 0) failed: just checking
jwilhelm
parents:
diff
changeset
|
116 checkMaxNewSize(new String[] { gcName, "-Xmx128M", "-XX:NewSize=32M", "-XX:MaxNewSize=32M" }, M32); |
8f07aa079343
8016309: assert(eden_size > 0 && survivor_size > 0) failed: just checking
jwilhelm
parents:
diff
changeset
|
117 checkMaxNewSize(new String[] { gcName, "-Xmx128M", "-XX:NewRatio=6", "-XX:MaxNewSize=32M" }, M32); |
8f07aa079343
8016309: assert(eden_size > 0 && survivor_size > 0) failed: just checking
jwilhelm
parents:
diff
changeset
|
118 checkMaxNewSize(new String[] { gcName, "-Xmx128M", "-Xms96M" }, M128); |
8f07aa079343
8016309: assert(eden_size > 0 && survivor_size > 0) failed: just checking
jwilhelm
parents:
diff
changeset
|
119 checkMaxNewSize(new String[] { gcName, "-Xmx96M", "-Xms96M" }, M96); |
8f07aa079343
8016309: assert(eden_size > 0 && survivor_size > 0) failed: just checking
jwilhelm
parents:
diff
changeset
|
120 checkMaxNewSize(new String[] { gcName, "-XX:NewSize=128M", "-XX:MaxNewSize=50M"}, M128); |
8f07aa079343
8016309: assert(eden_size > 0 && survivor_size > 0) failed: just checking
jwilhelm
parents:
diff
changeset
|
121 } |
8f07aa079343
8016309: assert(eden_size > 0 && survivor_size > 0) failed: just checking
jwilhelm
parents:
diff
changeset
|
122 } |