hotspot/test/gc/g1/TestPLABOutput.java
author sangheki
Thu, 10 Aug 2017 18:09:19 -0700
changeset 46795 623a5e42deb6
parent 40631 ed82623d7831
permissions -rw-r--r--
8173335: Improve logging for j.l.ref.reference processing Summary: Add logs for each phases of references and stats for each worker threads Reviewed-by: tschatzl, shade
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
33803
d61d5830df80 8140585: PLAB statistics are flushed too late
tschatzl
parents:
diff changeset
     1
/*
36390
a2d991d1d628 8141141: Young and Old gen PLAB stats are similar in output with -XX:+PrintPLAB
tschatzl
parents: 35753
diff changeset
     2
 * Copyright (c) 2015, 2016, Oracle and/or its affiliates. All rights reserved.
33803
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.
39414
4adf52148100 8160088: update hotspot tests depending on GC to use @requires vm.gc.X
dfazunen
parents: 38152
diff changeset
    28
 * @requires vm.gc.G1
33803
d61d5830df80 8140585: PLAB statistics are flushed too late
tschatzl
parents:
diff changeset
    29
 * @key gc
38152
80e5da81fb2c 8154258: [TESTBUG] Various serviceability tests fail compilation
dsamersoff
parents: 36390
diff changeset
    30
 * @modules java.base/jdk.internal.misc
40631
ed82623d7831 8157957: ClassNotFoundException: jdk.test.lib.JDKToolFinder
ctornqvi
parents: 39414
diff changeset
    31
 * @library /test/lib
33803
d61d5830df80 8140585: PLAB statistics are flushed too late
tschatzl
parents:
diff changeset
    32
 * @build sun.hotspot.WhiteBox
d61d5830df80 8140585: PLAB statistics are flushed too late
tschatzl
parents:
diff changeset
    33
 * @run main ClassFileInstaller sun.hotspot.WhiteBox
d61d5830df80 8140585: PLAB statistics are flushed too late
tschatzl
parents:
diff changeset
    34
 * @run driver TestPLABOutput
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
d61d5830df80 8140585: PLAB statistics are flushed too late
tschatzl
parents:
diff changeset
    37
import sun.hotspot.WhiteBox;
d61d5830df80 8140585: PLAB statistics are flushed too late
tschatzl
parents:
diff changeset
    38
d61d5830df80 8140585: PLAB statistics are flushed too late
tschatzl
parents:
diff changeset
    39
import java.util.regex.Matcher;
d61d5830df80 8140585: PLAB statistics are flushed too late
tschatzl
parents:
diff changeset
    40
import java.util.regex.Pattern;
d61d5830df80 8140585: PLAB statistics are flushed too late
tschatzl
parents:
diff changeset
    41
d61d5830df80 8140585: PLAB statistics are flushed too late
tschatzl
parents:
diff changeset
    42
import jdk.test.lib.Platform;
40631
ed82623d7831 8157957: ClassNotFoundException: jdk.test.lib.JDKToolFinder
ctornqvi
parents: 39414
diff changeset
    43
import jdk.test.lib.process.OutputAnalyzer;
ed82623d7831 8157957: ClassNotFoundException: jdk.test.lib.JDKToolFinder
ctornqvi
parents: 39414
diff changeset
    44
import jdk.test.lib.process.ProcessTools;
33803
d61d5830df80 8140585: PLAB statistics are flushed too late
tschatzl
parents:
diff changeset
    45
d61d5830df80 8140585: PLAB statistics are flushed too late
tschatzl
parents:
diff changeset
    46
import static jdk.test.lib.Asserts.*;
d61d5830df80 8140585: PLAB statistics are flushed too late
tschatzl
parents:
diff changeset
    47
d61d5830df80 8140585: PLAB statistics are flushed too late
tschatzl
parents:
diff changeset
    48
public class TestPLABOutput {
d61d5830df80 8140585: PLAB statistics are flushed too late
tschatzl
parents:
diff changeset
    49
d61d5830df80 8140585: PLAB statistics are flushed too late
tschatzl
parents:
diff changeset
    50
    public static void runTest() throws Exception {
d61d5830df80 8140585: PLAB statistics are flushed too late
tschatzl
parents:
diff changeset
    51
        final String[] arguments = {
d61d5830df80 8140585: PLAB statistics are flushed too late
tschatzl
parents:
diff changeset
    52
            "-Xbootclasspath/a:.",
d61d5830df80 8140585: PLAB statistics are flushed too late
tschatzl
parents:
diff changeset
    53
            "-XX:+UnlockExperimentalVMOptions",
d61d5830df80 8140585: PLAB statistics are flushed too late
tschatzl
parents:
diff changeset
    54
            "-XX:+UnlockDiagnosticVMOptions",
d61d5830df80 8140585: PLAB statistics are flushed too late
tschatzl
parents:
diff changeset
    55
            "-XX:+WhiteBoxAPI",
d61d5830df80 8140585: PLAB statistics are flushed too late
tschatzl
parents:
diff changeset
    56
            "-XX:+UseG1GC",
d61d5830df80 8140585: PLAB statistics are flushed too late
tschatzl
parents:
diff changeset
    57
            "-Xmx10M",
35061
be6025ebffea 8145092: Use Unified Logging for the GC logging
brutisso
parents: 33803
diff changeset
    58
            "-Xlog:gc+plab=debug",
33803
d61d5830df80 8140585: PLAB statistics are flushed too late
tschatzl
parents:
diff changeset
    59
            GCTest.class.getName()
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
d61d5830df80 8140585: PLAB statistics are flushed too late
tschatzl
parents:
diff changeset
    62
        ProcessBuilder pb = ProcessTools.createJavaProcessBuilder(arguments);
d61d5830df80 8140585: PLAB statistics are flushed too late
tschatzl
parents:
diff changeset
    63
        OutputAnalyzer output = new OutputAnalyzer(pb.start());
d61d5830df80 8140585: PLAB statistics are flushed too late
tschatzl
parents:
diff changeset
    64
d61d5830df80 8140585: PLAB statistics are flushed too late
tschatzl
parents:
diff changeset
    65
        output.shouldHaveExitValue(0);
d61d5830df80 8140585: PLAB statistics are flushed too late
tschatzl
parents:
diff changeset
    66
d61d5830df80 8140585: PLAB statistics are flushed too late
tschatzl
parents:
diff changeset
    67
        System.out.println(output.getStdout());
d61d5830df80 8140585: PLAB statistics are flushed too late
tschatzl
parents:
diff changeset
    68
36390
a2d991d1d628 8141141: Young and Old gen PLAB stats are similar in output with -XX:+PrintPLAB
tschatzl
parents: 35753
diff changeset
    69
        String pattern = ".*GC\\(0\\) .*allocated: (\\d+).*";
33803
d61d5830df80 8140585: PLAB statistics are flushed too late
tschatzl
parents:
diff changeset
    70
        Pattern r = Pattern.compile(pattern);
d61d5830df80 8140585: PLAB statistics are flushed too late
tschatzl
parents:
diff changeset
    71
        Matcher m = r.matcher(output.getStdout());
d61d5830df80 8140585: PLAB statistics are flushed too late
tschatzl
parents:
diff changeset
    72
d61d5830df80 8140585: PLAB statistics are flushed too late
tschatzl
parents:
diff changeset
    73
        if (!m.find()) {
d61d5830df80 8140585: PLAB statistics are flushed too late
tschatzl
parents:
diff changeset
    74
            throw new RuntimeException("Could not find any PLAB statistics output");
d61d5830df80 8140585: PLAB statistics are flushed too late
tschatzl
parents:
diff changeset
    75
        }
d61d5830df80 8140585: PLAB statistics are flushed too late
tschatzl
parents:
diff changeset
    76
        int allocated = Integer.parseInt(m.group(1));
d61d5830df80 8140585: PLAB statistics are flushed too late
tschatzl
parents:
diff changeset
    77
        assertGT(allocated, 0, "Did not allocate any memory during test");
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
d61d5830df80 8140585: PLAB statistics are flushed too late
tschatzl
parents:
diff changeset
    80
    public static void main(String[] args) throws Exception {
d61d5830df80 8140585: PLAB statistics are flushed too late
tschatzl
parents:
diff changeset
    81
        runTest();
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
d61d5830df80 8140585: PLAB statistics are flushed too late
tschatzl
parents:
diff changeset
    84
    static class GCTest {
d61d5830df80 8140585: PLAB statistics are flushed too late
tschatzl
parents:
diff changeset
    85
        private static final WhiteBox WB = WhiteBox.getWhiteBox();
d61d5830df80 8140585: PLAB statistics are flushed too late
tschatzl
parents:
diff changeset
    86
d61d5830df80 8140585: PLAB statistics are flushed too late
tschatzl
parents:
diff changeset
    87
        public static Object holder;
d61d5830df80 8140585: PLAB statistics are flushed too late
tschatzl
parents:
diff changeset
    88
d61d5830df80 8140585: PLAB statistics are flushed too late
tschatzl
parents:
diff changeset
    89
        public static void main(String [] args) {
d61d5830df80 8140585: PLAB statistics are flushed too late
tschatzl
parents:
diff changeset
    90
            holder = new byte[100];
d61d5830df80 8140585: PLAB statistics are flushed too late
tschatzl
parents:
diff changeset
    91
            WB.youngGC();
d61d5830df80 8140585: PLAB statistics are flushed too late
tschatzl
parents:
diff changeset
    92
            System.out.println(holder);
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
}
d61d5830df80 8140585: PLAB statistics are flushed too late
tschatzl
parents:
diff changeset
    96