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

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

mercurial