test/gc/g1/TestGCLogMessages.java

Tue, 18 Mar 2014 19:07:22 +0100

author
pliden
date
Tue, 18 Mar 2014 19:07:22 +0100
changeset 6413
595c0f60d50d
parent 6406
eff02b5bd56c
child 6876
710a3c8b516e
child 6930
570cb6369f17
permissions
-rw-r--r--

8029075: String deduplication in G1
Summary: Implementation of JEP 192, http://openjdk.java.net/jeps/192
Reviewed-by: brutisso, tschatzl, coleenp

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 /*
tschatzl@6402 25 * @test TestPrintGCDetails
tschatzl@6405 26 * @bug 8035406 8027295 8035398
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@6404 51 output.shouldNotContain("[Code Root Purge");
pliden@6413 52 output.shouldNotContain("[String Dedup Fixup");
tschatzl@6404 53 output.shouldNotContain("[Young Free CSet");
tschatzl@6404 54 output.shouldNotContain("[Non-Young Free CSet");
tschatzl@6404 55 output.shouldHaveExitValue(0);
tschatzl@6404 56
tschatzl@6404 57 pb = ProcessTools.createJavaProcessBuilder("-XX:+UseG1GC",
pliden@6413 58 "-XX:+UseStringDeduplication",
tschatzl@6404 59 "-Xmx10M",
tschatzl@6404 60 "-XX:+PrintGCDetails",
tschatzl@6404 61 GCTest.class.getName());
tschatzl@6404 62
tschatzl@6404 63 output = new OutputAnalyzer(pb.start());
tschatzl@6404 64
tschatzl@6405 65 output.shouldContain("[Redirty Cards");
tschatzl@6402 66 output.shouldContain("[Code Root Purge");
pliden@6413 67 output.shouldContain("[String Dedup Fixup");
tschatzl@6404 68 output.shouldNotContain("[Young Free CSet");
tschatzl@6404 69 output.shouldNotContain("[Non-Young Free CSet");
tschatzl@6402 70 output.shouldHaveExitValue(0);
tschatzl@6404 71
tschatzl@6404 72 pb = ProcessTools.createJavaProcessBuilder("-XX:+UseG1GC",
pliden@6413 73 "-XX:+UseStringDeduplication",
tschatzl@6404 74 "-Xmx10M",
tschatzl@6404 75 "-XX:+PrintGCDetails",
tschatzl@6404 76 "-XX:+UnlockExperimentalVMOptions",
tschatzl@6404 77 "-XX:G1LogLevel=finest",
tschatzl@6404 78 GCTest.class.getName());
tschatzl@6404 79
tschatzl@6404 80 output = new OutputAnalyzer(pb.start());
tschatzl@6404 81
tschatzl@6405 82 output.shouldContain("[Redirty Cards");
tschatzl@6404 83 output.shouldContain("[Code Root Purge");
pliden@6413 84 output.shouldContain("[String Dedup Fixup");
tschatzl@6404 85 output.shouldContain("[Young Free CSet");
tschatzl@6404 86 output.shouldContain("[Non-Young Free CSet");
tschatzl@6406 87
tschatzl@6406 88 // also check evacuation failure messages once
tschatzl@6406 89 output.shouldNotContain("[Evacuation Failure");
tschatzl@6406 90 output.shouldNotContain("[Recalculate Used");
tschatzl@6406 91 output.shouldNotContain("[Remove Self Forwards");
tschatzl@6406 92 output.shouldNotContain("[Restore RemSet");
tschatzl@6406 93 output.shouldHaveExitValue(0);
tschatzl@6406 94 }
tschatzl@6406 95
tschatzl@6406 96 private static void testWithToSpaceExhaustionLogs() throws Exception {
tschatzl@6406 97 ProcessBuilder pb = ProcessTools.createJavaProcessBuilder("-XX:+UseG1GC",
tschatzl@6406 98 "-Xmx10M",
tschatzl@6406 99 "-Xmn5M",
tschatzl@6406 100 "-XX:+PrintGCDetails",
tschatzl@6406 101 GCTestWithToSpaceExhaustion.class.getName());
tschatzl@6406 102
tschatzl@6406 103 OutputAnalyzer output = new OutputAnalyzer(pb.start());
tschatzl@6406 104 output.shouldContain("[Evacuation Failure");
tschatzl@6406 105 output.shouldNotContain("[Recalculate Used");
tschatzl@6406 106 output.shouldNotContain("[Remove Self Forwards");
tschatzl@6406 107 output.shouldNotContain("[Restore RemSet");
tschatzl@6404 108 output.shouldHaveExitValue(0);
tschatzl@6404 109
tschatzl@6406 110 pb = ProcessTools.createJavaProcessBuilder("-XX:+UseG1GC",
tschatzl@6406 111 "-Xmx10M",
tschatzl@6406 112 "-Xmn5M",
tschatzl@6406 113 "-XX:+PrintGCDetails",
tschatzl@6406 114 "-XX:+UnlockExperimentalVMOptions",
tschatzl@6406 115 "-XX:G1LogLevel=finest",
tschatzl@6406 116 GCTestWithToSpaceExhaustion.class.getName());
tschatzl@6406 117
tschatzl@6406 118 output = new OutputAnalyzer(pb.start());
tschatzl@6406 119 output.shouldContain("[Evacuation Failure");
tschatzl@6406 120 output.shouldContain("[Recalculate Used");
tschatzl@6406 121 output.shouldContain("[Remove Self Forwards");
tschatzl@6406 122 output.shouldContain("[Restore RemSet");
tschatzl@6406 123 output.shouldHaveExitValue(0);
tschatzl@6402 124 }
tschatzl@6402 125
tschatzl@6402 126 static class GCTest {
tschatzl@6402 127 private static byte[] garbage;
tschatzl@6402 128 public static void main(String [] args) {
tschatzl@6402 129 System.out.println("Creating garbage");
tschatzl@6402 130 // create 128MB of garbage. This should result in at least one GC
tschatzl@6402 131 for (int i = 0; i < 1024; i++) {
tschatzl@6402 132 garbage = new byte[128 * 1024];
tschatzl@6402 133 }
tschatzl@6402 134 System.out.println("Done");
tschatzl@6402 135 }
tschatzl@6402 136 }
tschatzl@6406 137
tschatzl@6406 138 static class GCTestWithToSpaceExhaustion {
tschatzl@6406 139 private static byte[] garbage;
tschatzl@6406 140 private static byte[] largeObject;
tschatzl@6406 141 public static void main(String [] args) {
tschatzl@6406 142 largeObject = new byte[5*1024*1024];
tschatzl@6406 143 System.out.println("Creating garbage");
tschatzl@6406 144 // create 128MB of garbage. This should result in at least one GC,
tschatzl@6406 145 // some of them with to-space exhaustion.
tschatzl@6406 146 for (int i = 0; i < 1024; i++) {
tschatzl@6406 147 garbage = new byte[128 * 1024];
tschatzl@6406 148 }
tschatzl@6406 149 System.out.println("Done");
tschatzl@6406 150 }
tschatzl@6406 151 }
tschatzl@6402 152 }

mercurial