test/gc/g1/TestGCLogMessages.java

Wed, 27 Aug 2014 08:19:12 -0400

author
zgu
date
Wed, 27 Aug 2014 08:19:12 -0400
changeset 7074
833b0f92429a
parent 7010
a3953c777565
child 7535
7ae4e26cb1e0
child 7660
3ca53859c3c7
permissions
-rw-r--r--

8046598: Scalable Native memory tracking development
Summary: Enhance scalability of native memory tracking
Reviewed-by: coleenp, ctornqvi, gtriantafill

tschatzl@6402 1 /*
tschatzl@6402 2 * Copyright (c) 2014, Oracle and/or its affiliates. All rights reserved.
tschatzl@6402 3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
tschatzl@6402 4 *
tschatzl@6402 5 * This code is free software; you can redistribute it and/or modify it
tschatzl@6402 6 * under the terms of the GNU General Public License version 2 only, as
tschatzl@6402 7 * published by the Free Software Foundation.
tschatzl@6402 8 *
tschatzl@6402 9 * This code is distributed in the hope that it will be useful, but WITHOUT
tschatzl@6402 10 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
tschatzl@6402 11 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
tschatzl@6402 12 * version 2 for more details (a copy is included in the LICENSE file that
tschatzl@6402 13 * accompanied this code).
tschatzl@6402 14 *
tschatzl@6402 15 * You should have received a copy of the GNU General Public License version
tschatzl@6402 16 * 2 along with this work; if not, write to the Free Software Foundation,
tschatzl@6402 17 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
tschatzl@6402 18 *
tschatzl@6402 19 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
tschatzl@6402 20 * or visit www.oracle.com if you need additional information or have any
tschatzl@6402 21 * questions.
tschatzl@6402 22 */
tschatzl@6402 23
tschatzl@6402 24 /*
jmasa@6950 25 * @test TestGCLogMessages
tschatzl@7010 26 * @bug 8035406 8027295 8035398 8019342 8027959
tschatzl@6402 27 * @summary Ensure that the PrintGCDetails output for a minor GC with G1
tschatzl@6402 28 * includes the expected necessary messages.
tschatzl@6402 29 * @key gc
tschatzl@6402 30 * @library /testlibrary
tschatzl@6402 31 */
tschatzl@6402 32
tschatzl@6402 33 import com.oracle.java.testlibrary.ProcessTools;
tschatzl@6402 34 import com.oracle.java.testlibrary.OutputAnalyzer;
tschatzl@6402 35
tschatzl@6402 36 public class TestGCLogMessages {
tschatzl@6402 37 public static void main(String[] args) throws Exception {
tschatzl@6406 38 testNormalLogs();
tschatzl@6406 39 testWithToSpaceExhaustionLogs();
tschatzl@6406 40 }
tschatzl@6406 41
tschatzl@6406 42 private static void testNormalLogs() throws Exception {
tschatzl@6402 43
tschatzl@6402 44 ProcessBuilder pb = ProcessTools.createJavaProcessBuilder("-XX:+UseG1GC",
tschatzl@6402 45 "-Xmx10M",
tschatzl@6402 46 GCTest.class.getName());
tschatzl@6402 47
tschatzl@6402 48 OutputAnalyzer output = new OutputAnalyzer(pb.start());
tschatzl@6402 49
tschatzl@6405 50 output.shouldNotContain("[Redirty Cards");
tschatzl@6930 51 output.shouldNotContain("[Parallel Redirty");
tschatzl@6930 52 output.shouldNotContain("[Redirtied Cards");
tschatzl@6404 53 output.shouldNotContain("[Code Root Purge");
pliden@6413 54 output.shouldNotContain("[String Dedup Fixup");
tschatzl@6404 55 output.shouldNotContain("[Young Free CSet");
tschatzl@6404 56 output.shouldNotContain("[Non-Young Free CSet");
tschatzl@7010 57 output.shouldNotContain("[Humongous Reclaim");
tschatzl@6404 58 output.shouldHaveExitValue(0);
tschatzl@6404 59
tschatzl@6404 60 pb = ProcessTools.createJavaProcessBuilder("-XX:+UseG1GC",
pliden@6413 61 "-XX:+UseStringDeduplication",
tschatzl@6404 62 "-Xmx10M",
tschatzl@6404 63 "-XX:+PrintGCDetails",
tschatzl@6404 64 GCTest.class.getName());
tschatzl@6404 65
tschatzl@6404 66 output = new OutputAnalyzer(pb.start());
tschatzl@6404 67
tschatzl@6405 68 output.shouldContain("[Redirty Cards");
tschatzl@6930 69 output.shouldNotContain("[Parallel Redirty");
tschatzl@6930 70 output.shouldNotContain("[Redirtied Cards");
tschatzl@6402 71 output.shouldContain("[Code Root Purge");
pliden@6413 72 output.shouldContain("[String Dedup Fixup");
tschatzl@6404 73 output.shouldNotContain("[Young Free CSet");
tschatzl@6404 74 output.shouldNotContain("[Non-Young Free CSet");
tschatzl@7010 75 output.shouldContain("[Humongous Reclaim");
tschatzl@7010 76 output.shouldNotContain("[Humongous Total");
tschatzl@7010 77 output.shouldNotContain("[Humongous Candidate");
tschatzl@7010 78 output.shouldNotContain("[Humongous Reclaimed");
tschatzl@6402 79 output.shouldHaveExitValue(0);
tschatzl@6404 80
tschatzl@6404 81 pb = ProcessTools.createJavaProcessBuilder("-XX:+UseG1GC",
pliden@6413 82 "-XX:+UseStringDeduplication",
tschatzl@6404 83 "-Xmx10M",
tschatzl@6404 84 "-XX:+PrintGCDetails",
tschatzl@6404 85 "-XX:+UnlockExperimentalVMOptions",
tschatzl@6404 86 "-XX:G1LogLevel=finest",
tschatzl@6404 87 GCTest.class.getName());
tschatzl@6404 88
tschatzl@6404 89 output = new OutputAnalyzer(pb.start());
tschatzl@6404 90
tschatzl@6405 91 output.shouldContain("[Redirty Cards");
tschatzl@6930 92 output.shouldContain("[Parallel Redirty");
tschatzl@6930 93 output.shouldContain("[Redirtied Cards");
tschatzl@6404 94 output.shouldContain("[Code Root Purge");
pliden@6413 95 output.shouldContain("[String Dedup Fixup");
tschatzl@6404 96 output.shouldContain("[Young Free CSet");
tschatzl@6404 97 output.shouldContain("[Non-Young Free CSet");
tschatzl@7010 98 output.shouldContain("[Humongous Reclaim");
tschatzl@7010 99 output.shouldContain("[Humongous Total");
tschatzl@7010 100 output.shouldContain("[Humongous Candidate");
tschatzl@7010 101 output.shouldContain("[Humongous Reclaimed");
tschatzl@6406 102 output.shouldHaveExitValue(0);
tschatzl@6406 103 }
tschatzl@6406 104
tschatzl@6406 105 private static void testWithToSpaceExhaustionLogs() throws Exception {
tschatzl@6406 106 ProcessBuilder pb = ProcessTools.createJavaProcessBuilder("-XX:+UseG1GC",
tschatzl@6406 107 "-Xmx10M",
tschatzl@6406 108 "-Xmn5M",
tschatzl@6406 109 "-XX:+PrintGCDetails",
tschatzl@6406 110 GCTestWithToSpaceExhaustion.class.getName());
tschatzl@6406 111
tschatzl@6406 112 OutputAnalyzer output = new OutputAnalyzer(pb.start());
tschatzl@6406 113 output.shouldContain("[Evacuation Failure");
tschatzl@6406 114 output.shouldNotContain("[Recalculate Used");
tschatzl@6406 115 output.shouldNotContain("[Remove Self Forwards");
tschatzl@6406 116 output.shouldNotContain("[Restore RemSet");
tschatzl@6404 117 output.shouldHaveExitValue(0);
tschatzl@6404 118
tschatzl@6406 119 pb = ProcessTools.createJavaProcessBuilder("-XX:+UseG1GC",
tschatzl@6406 120 "-Xmx10M",
tschatzl@6406 121 "-Xmn5M",
tschatzl@6406 122 "-XX:+PrintGCDetails",
tschatzl@6406 123 "-XX:+UnlockExperimentalVMOptions",
tschatzl@6406 124 "-XX:G1LogLevel=finest",
tschatzl@6406 125 GCTestWithToSpaceExhaustion.class.getName());
tschatzl@6406 126
tschatzl@6406 127 output = new OutputAnalyzer(pb.start());
tschatzl@6406 128 output.shouldContain("[Evacuation Failure");
tschatzl@6406 129 output.shouldContain("[Recalculate Used");
tschatzl@6406 130 output.shouldContain("[Remove Self Forwards");
tschatzl@6406 131 output.shouldContain("[Restore RemSet");
tschatzl@6406 132 output.shouldHaveExitValue(0);
tschatzl@6402 133 }
tschatzl@6402 134
tschatzl@6402 135 static class GCTest {
tschatzl@6402 136 private static byte[] garbage;
tschatzl@6402 137 public static void main(String [] args) {
tschatzl@6402 138 System.out.println("Creating garbage");
tschatzl@6402 139 // create 128MB of garbage. This should result in at least one GC
tschatzl@6402 140 for (int i = 0; i < 1024; i++) {
tschatzl@6402 141 garbage = new byte[128 * 1024];
tschatzl@6402 142 }
tschatzl@6402 143 System.out.println("Done");
tschatzl@6402 144 }
tschatzl@6402 145 }
tschatzl@6406 146
tschatzl@6406 147 static class GCTestWithToSpaceExhaustion {
tschatzl@6406 148 private static byte[] garbage;
tschatzl@6406 149 private static byte[] largeObject;
tschatzl@6406 150 public static void main(String [] args) {
tschatzl@6406 151 largeObject = new byte[5*1024*1024];
tschatzl@6406 152 System.out.println("Creating garbage");
tschatzl@6406 153 // create 128MB of garbage. This should result in at least one GC,
tschatzl@6406 154 // some of them with to-space exhaustion.
tschatzl@6406 155 for (int i = 0; i < 1024; i++) {
tschatzl@6406 156 garbage = new byte[128 * 1024];
tschatzl@6406 157 }
tschatzl@6406 158 System.out.println("Done");
tschatzl@6406 159 }
tschatzl@6406 160 }
tschatzl@6402 161 }

mercurial