test/gc/g1/TestGCLogMessages.java

Mon, 21 Jul 2014 09:40:19 +0200

author
tschatzl
date
Mon, 21 Jul 2014 09:40:19 +0200
changeset 6930
570cb6369f17
parent 6413
595c0f60d50d
child 6950
6e1f418b39c3
permissions
-rw-r--r--

8019342: G1: High "Other" time most likely due to card redirtying
Summary: Parallelize card redirtying to decrease the time it takes.
Reviewed-by: brutisso

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

mercurial