hotspot/test/gc/g1/TestPLABOutput.java
author brutisso
Thu, 10 Dec 2015 14:57:55 +0100
changeset 35061 be6025ebffea
parent 33803 d61d5830df80
child 35753 ee7921f045d2
permissions -rw-r--r--
8145092: Use Unified Logging for the GC logging Summary: JEP-271. VM changes contributed by brutisso, test changes contributed by david. Reviewed-by: sjohanss, david, brutisso Contributed-by: bengt.rutisson@oracle.com, david.lindholm@oralce.com
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
33803
d61d5830df80 8140585: PLAB statistics are flushed too late
tschatzl
parents:
diff changeset
     1
/*
d61d5830df80 8140585: PLAB statistics are flushed too late
tschatzl
parents:
diff changeset
     2
 * Copyright (c) 2015, Oracle and/or its affiliates. All rights reserved.
d61d5830df80 8140585: PLAB statistics are flushed too late
tschatzl
parents:
diff changeset
     3
 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
d61d5830df80 8140585: PLAB statistics are flushed too late
tschatzl
parents:
diff changeset
     4
 *
d61d5830df80 8140585: PLAB statistics are flushed too late
tschatzl
parents:
diff changeset
     5
 * This code is free software; you can redistribute it and/or modify it
d61d5830df80 8140585: PLAB statistics are flushed too late
tschatzl
parents:
diff changeset
     6
 * under the terms of the GNU General Public License version 2 only, as
d61d5830df80 8140585: PLAB statistics are flushed too late
tschatzl
parents:
diff changeset
     7
 * published by the Free Software Foundation.
d61d5830df80 8140585: PLAB statistics are flushed too late
tschatzl
parents:
diff changeset
     8
 *
d61d5830df80 8140585: PLAB statistics are flushed too late
tschatzl
parents:
diff changeset
     9
 * This code is distributed in the hope that it will be useful, but WITHOUT
d61d5830df80 8140585: PLAB statistics are flushed too late
tschatzl
parents:
diff changeset
    10
 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
d61d5830df80 8140585: PLAB statistics are flushed too late
tschatzl
parents:
diff changeset
    11
 * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
d61d5830df80 8140585: PLAB statistics are flushed too late
tschatzl
parents:
diff changeset
    12
 * version 2 for more details (a copy is included in the LICENSE file that
d61d5830df80 8140585: PLAB statistics are flushed too late
tschatzl
parents:
diff changeset
    13
 * accompanied this code).
d61d5830df80 8140585: PLAB statistics are flushed too late
tschatzl
parents:
diff changeset
    14
 *
d61d5830df80 8140585: PLAB statistics are flushed too late
tschatzl
parents:
diff changeset
    15
 * You should have received a copy of the GNU General Public License version
d61d5830df80 8140585: PLAB statistics are flushed too late
tschatzl
parents:
diff changeset
    16
 * 2 along with this work; if not, write to the Free Software Foundation,
d61d5830df80 8140585: PLAB statistics are flushed too late
tschatzl
parents:
diff changeset
    17
 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
d61d5830df80 8140585: PLAB statistics are flushed too late
tschatzl
parents:
diff changeset
    18
 *
d61d5830df80 8140585: PLAB statistics are flushed too late
tschatzl
parents:
diff changeset
    19
 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
d61d5830df80 8140585: PLAB statistics are flushed too late
tschatzl
parents:
diff changeset
    20
 * or visit www.oracle.com if you need additional information or have any
d61d5830df80 8140585: PLAB statistics are flushed too late
tschatzl
parents:
diff changeset
    21
 * questions.
d61d5830df80 8140585: PLAB statistics are flushed too late
tschatzl
parents:
diff changeset
    22
 */
d61d5830df80 8140585: PLAB statistics are flushed too late
tschatzl
parents:
diff changeset
    23
d61d5830df80 8140585: PLAB statistics are flushed too late
tschatzl
parents:
diff changeset
    24
/*
d61d5830df80 8140585: PLAB statistics are flushed too late
tschatzl
parents:
diff changeset
    25
 * @test TestPLABOutput
d61d5830df80 8140585: PLAB statistics are flushed too late
tschatzl
parents:
diff changeset
    26
 * @bug 8140585
d61d5830df80 8140585: PLAB statistics are flushed too late
tschatzl
parents:
diff changeset
    27
 * @summary Check that G1 does not report empty PLAB statistics in the first evacuation.
d61d5830df80 8140585: PLAB statistics are flushed too late
tschatzl
parents:
diff changeset
    28
 * @requires vm.gc=="G1" | vm.gc=="null"
d61d5830df80 8140585: PLAB statistics are flushed too late
tschatzl
parents:
diff changeset
    29
 * @key gc
d61d5830df80 8140585: PLAB statistics are flushed too late
tschatzl
parents:
diff changeset
    30
 * @library /testlibrary /../../test/lib
d61d5830df80 8140585: PLAB statistics are flushed too late
tschatzl
parents:
diff changeset
    31
 * @build sun.hotspot.WhiteBox
d61d5830df80 8140585: PLAB statistics are flushed too late
tschatzl
parents:
diff changeset
    32
 * @run main ClassFileInstaller sun.hotspot.WhiteBox
d61d5830df80 8140585: PLAB statistics are flushed too late
tschatzl
parents:
diff changeset
    33
 * @run driver TestPLABOutput
d61d5830df80 8140585: PLAB statistics are flushed too late
tschatzl
parents:
diff changeset
    34
 */
d61d5830df80 8140585: PLAB statistics are flushed too late
tschatzl
parents:
diff changeset
    35
d61d5830df80 8140585: PLAB statistics are flushed too late
tschatzl
parents:
diff changeset
    36
import sun.hotspot.WhiteBox;
d61d5830df80 8140585: PLAB statistics are flushed too late
tschatzl
parents:
diff changeset
    37
d61d5830df80 8140585: PLAB statistics are flushed too late
tschatzl
parents:
diff changeset
    38
import java.util.regex.Matcher;
d61d5830df80 8140585: PLAB statistics are flushed too late
tschatzl
parents:
diff changeset
    39
import java.util.regex.Pattern;
d61d5830df80 8140585: PLAB statistics are flushed too late
tschatzl
parents:
diff changeset
    40
d61d5830df80 8140585: PLAB statistics are flushed too late
tschatzl
parents:
diff changeset
    41
import jdk.test.lib.OutputAnalyzer;
d61d5830df80 8140585: PLAB statistics are flushed too late
tschatzl
parents:
diff changeset
    42
import jdk.test.lib.Platform;
d61d5830df80 8140585: PLAB statistics are flushed too late
tschatzl
parents:
diff changeset
    43
import jdk.test.lib.ProcessTools;
d61d5830df80 8140585: PLAB statistics are flushed too late
tschatzl
parents:
diff changeset
    44
d61d5830df80 8140585: PLAB statistics are flushed too late
tschatzl
parents:
diff changeset
    45
import static jdk.test.lib.Asserts.*;
d61d5830df80 8140585: PLAB statistics are flushed too late
tschatzl
parents:
diff changeset
    46
d61d5830df80 8140585: PLAB statistics are flushed too late
tschatzl
parents:
diff changeset
    47
public class TestPLABOutput {
d61d5830df80 8140585: PLAB statistics are flushed too late
tschatzl
parents:
diff changeset
    48
d61d5830df80 8140585: PLAB statistics are flushed too late
tschatzl
parents:
diff changeset
    49
    public static void runTest() throws Exception {
d61d5830df80 8140585: PLAB statistics are flushed too late
tschatzl
parents:
diff changeset
    50
        final String[] arguments = {
d61d5830df80 8140585: PLAB statistics are flushed too late
tschatzl
parents:
diff changeset
    51
            "-Xbootclasspath/a:.",
d61d5830df80 8140585: PLAB statistics are flushed too late
tschatzl
parents:
diff changeset
    52
            "-XX:+UnlockExperimentalVMOptions",
d61d5830df80 8140585: PLAB statistics are flushed too late
tschatzl
parents:
diff changeset
    53
            "-XX:+UnlockDiagnosticVMOptions",
d61d5830df80 8140585: PLAB statistics are flushed too late
tschatzl
parents:
diff changeset
    54
            "-XX:+WhiteBoxAPI",
d61d5830df80 8140585: PLAB statistics are flushed too late
tschatzl
parents:
diff changeset
    55
            "-XX:+UseG1GC",
d61d5830df80 8140585: PLAB statistics are flushed too late
tschatzl
parents:
diff changeset
    56
            "-Xmx10M",
35061
be6025ebffea 8145092: Use Unified Logging for the GC logging
brutisso
parents: 33803
diff changeset
    57
            "-Xlog:gc+plab=debug",
33803
d61d5830df80 8140585: PLAB statistics are flushed too late
tschatzl
parents:
diff changeset
    58
            GCTest.class.getName()
d61d5830df80 8140585: PLAB statistics are flushed too late
tschatzl
parents:
diff changeset
    59
            };
d61d5830df80 8140585: PLAB statistics are flushed too late
tschatzl
parents:
diff changeset
    60
d61d5830df80 8140585: PLAB statistics are flushed too late
tschatzl
parents:
diff changeset
    61
        ProcessBuilder pb = ProcessTools.createJavaProcessBuilder(arguments);
d61d5830df80 8140585: PLAB statistics are flushed too late
tschatzl
parents:
diff changeset
    62
        OutputAnalyzer output = new OutputAnalyzer(pb.start());
d61d5830df80 8140585: PLAB statistics are flushed too late
tschatzl
parents:
diff changeset
    63
d61d5830df80 8140585: PLAB statistics are flushed too late
tschatzl
parents:
diff changeset
    64
        output.shouldHaveExitValue(0);
d61d5830df80 8140585: PLAB statistics are flushed too late
tschatzl
parents:
diff changeset
    65
d61d5830df80 8140585: PLAB statistics are flushed too late
tschatzl
parents:
diff changeset
    66
        System.out.println(output.getStdout());
d61d5830df80 8140585: PLAB statistics are flushed too late
tschatzl
parents:
diff changeset
    67
35061
be6025ebffea 8145092: Use Unified Logging for the GC logging
brutisso
parents: 33803
diff changeset
    68
        String pattern = ".*GC\\(0\\) .*allocated = (\\d+).*";
33803
d61d5830df80 8140585: PLAB statistics are flushed too late
tschatzl
parents:
diff changeset
    69
        Pattern r = Pattern.compile(pattern);
d61d5830df80 8140585: PLAB statistics are flushed too late
tschatzl
parents:
diff changeset
    70
        Matcher m = r.matcher(output.getStdout());
d61d5830df80 8140585: PLAB statistics are flushed too late
tschatzl
parents:
diff changeset
    71
d61d5830df80 8140585: PLAB statistics are flushed too late
tschatzl
parents:
diff changeset
    72
        if (!m.find()) {
d61d5830df80 8140585: PLAB statistics are flushed too late
tschatzl
parents:
diff changeset
    73
            throw new RuntimeException("Could not find any PLAB statistics output");
d61d5830df80 8140585: PLAB statistics are flushed too late
tschatzl
parents:
diff changeset
    74
        }
d61d5830df80 8140585: PLAB statistics are flushed too late
tschatzl
parents:
diff changeset
    75
        int allocated = Integer.parseInt(m.group(1));
d61d5830df80 8140585: PLAB statistics are flushed too late
tschatzl
parents:
diff changeset
    76
        assertGT(allocated, 0, "Did not allocate any memory during test");
d61d5830df80 8140585: PLAB statistics are flushed too late
tschatzl
parents:
diff changeset
    77
    }
d61d5830df80 8140585: PLAB statistics are flushed too late
tschatzl
parents:
diff changeset
    78
d61d5830df80 8140585: PLAB statistics are flushed too late
tschatzl
parents:
diff changeset
    79
    public static void main(String[] args) throws Exception {
d61d5830df80 8140585: PLAB statistics are flushed too late
tschatzl
parents:
diff changeset
    80
        runTest();
d61d5830df80 8140585: PLAB statistics are flushed too late
tschatzl
parents:
diff changeset
    81
    }
d61d5830df80 8140585: PLAB statistics are flushed too late
tschatzl
parents:
diff changeset
    82
d61d5830df80 8140585: PLAB statistics are flushed too late
tschatzl
parents:
diff changeset
    83
    static class GCTest {
d61d5830df80 8140585: PLAB statistics are flushed too late
tschatzl
parents:
diff changeset
    84
        private static final WhiteBox WB = WhiteBox.getWhiteBox();
d61d5830df80 8140585: PLAB statistics are flushed too late
tschatzl
parents:
diff changeset
    85
d61d5830df80 8140585: PLAB statistics are flushed too late
tschatzl
parents:
diff changeset
    86
        public static Object holder;
d61d5830df80 8140585: PLAB statistics are flushed too late
tschatzl
parents:
diff changeset
    87
d61d5830df80 8140585: PLAB statistics are flushed too late
tschatzl
parents:
diff changeset
    88
        public static void main(String [] args) {
d61d5830df80 8140585: PLAB statistics are flushed too late
tschatzl
parents:
diff changeset
    89
            holder = new byte[100];
d61d5830df80 8140585: PLAB statistics are flushed too late
tschatzl
parents:
diff changeset
    90
            WB.youngGC();
d61d5830df80 8140585: PLAB statistics are flushed too late
tschatzl
parents:
diff changeset
    91
            System.out.println(holder);
d61d5830df80 8140585: PLAB statistics are flushed too late
tschatzl
parents:
diff changeset
    92
        }
d61d5830df80 8140585: PLAB statistics are flushed too late
tschatzl
parents:
diff changeset
    93
    }
d61d5830df80 8140585: PLAB statistics are flushed too late
tschatzl
parents:
diff changeset
    94
}
d61d5830df80 8140585: PLAB statistics are flushed too late
tschatzl
parents:
diff changeset
    95