hotspot/test/gc/g1/TestPrintRegionRememberedSetInfo.java
author sangheki
Thu, 10 Aug 2017 18:09:19 -0700
changeset 46795 623a5e42deb6
parent 40886 98cb935dc074
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:
17395
2cd3ef1be718 8014240: G1: Add remembered set size information to output of G1PrintRegionLivenessInfo
tschatzl
parents:
diff changeset
     1
/*
40631
ed82623d7831 8157957: ClassNotFoundException: jdk.test.lib.JDKToolFinder
ctornqvi
parents: 36851
diff changeset
     2
 * Copyright (c) 2013, 2016, Oracle and/or its affiliates. All rights reserved.
17395
2cd3ef1be718 8014240: G1: Add remembered set size information to output of G1PrintRegionLivenessInfo
tschatzl
parents:
diff changeset
     3
 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
2cd3ef1be718 8014240: G1: Add remembered set size information to output of G1PrintRegionLivenessInfo
tschatzl
parents:
diff changeset
     4
 *
2cd3ef1be718 8014240: G1: Add remembered set size information to output of G1PrintRegionLivenessInfo
tschatzl
parents:
diff changeset
     5
 * This code is free software; you can redistribute it and/or modify it
2cd3ef1be718 8014240: G1: Add remembered set size information to output of G1PrintRegionLivenessInfo
tschatzl
parents:
diff changeset
     6
 * under the terms of the GNU General Public License version 2 only, as
2cd3ef1be718 8014240: G1: Add remembered set size information to output of G1PrintRegionLivenessInfo
tschatzl
parents:
diff changeset
     7
 * published by the Free Software Foundation.
2cd3ef1be718 8014240: G1: Add remembered set size information to output of G1PrintRegionLivenessInfo
tschatzl
parents:
diff changeset
     8
 *
2cd3ef1be718 8014240: G1: Add remembered set size information to output of G1PrintRegionLivenessInfo
tschatzl
parents:
diff changeset
     9
 * This code is distributed in the hope that it will be useful, but WITHOUT
2cd3ef1be718 8014240: G1: Add remembered set size information to output of G1PrintRegionLivenessInfo
tschatzl
parents:
diff changeset
    10
 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
2cd3ef1be718 8014240: G1: Add remembered set size information to output of G1PrintRegionLivenessInfo
tschatzl
parents:
diff changeset
    11
 * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
2cd3ef1be718 8014240: G1: Add remembered set size information to output of G1PrintRegionLivenessInfo
tschatzl
parents:
diff changeset
    12
 * version 2 for more details (a copy is included in the LICENSE file that
2cd3ef1be718 8014240: G1: Add remembered set size information to output of G1PrintRegionLivenessInfo
tschatzl
parents:
diff changeset
    13
 * accompanied this code).
2cd3ef1be718 8014240: G1: Add remembered set size information to output of G1PrintRegionLivenessInfo
tschatzl
parents:
diff changeset
    14
 *
2cd3ef1be718 8014240: G1: Add remembered set size information to output of G1PrintRegionLivenessInfo
tschatzl
parents:
diff changeset
    15
 * You should have received a copy of the GNU General Public License version
2cd3ef1be718 8014240: G1: Add remembered set size information to output of G1PrintRegionLivenessInfo
tschatzl
parents:
diff changeset
    16
 * 2 along with this work; if not, write to the Free Software Foundation,
2cd3ef1be718 8014240: G1: Add remembered set size information to output of G1PrintRegionLivenessInfo
tschatzl
parents:
diff changeset
    17
 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
2cd3ef1be718 8014240: G1: Add remembered set size information to output of G1PrintRegionLivenessInfo
tschatzl
parents:
diff changeset
    18
 *
2cd3ef1be718 8014240: G1: Add remembered set size information to output of G1PrintRegionLivenessInfo
tschatzl
parents:
diff changeset
    19
 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
2cd3ef1be718 8014240: G1: Add remembered set size information to output of G1PrintRegionLivenessInfo
tschatzl
parents:
diff changeset
    20
 * or visit www.oracle.com if you need additional information or have any
2cd3ef1be718 8014240: G1: Add remembered set size information to output of G1PrintRegionLivenessInfo
tschatzl
parents:
diff changeset
    21
 * questions.
2cd3ef1be718 8014240: G1: Add remembered set size information to output of G1PrintRegionLivenessInfo
tschatzl
parents:
diff changeset
    22
 */
2cd3ef1be718 8014240: G1: Add remembered set size information to output of G1PrintRegionLivenessInfo
tschatzl
parents:
diff changeset
    23
2cd3ef1be718 8014240: G1: Add remembered set size information to output of G1PrintRegionLivenessInfo
tschatzl
parents:
diff changeset
    24
/**
2cd3ef1be718 8014240: G1: Add remembered set size information to output of G1PrintRegionLivenessInfo
tschatzl
parents:
diff changeset
    25
 * @test TestPrintRegionRememberedSetInfo
2cd3ef1be718 8014240: G1: Add remembered set size information to output of G1PrintRegionLivenessInfo
tschatzl
parents:
diff changeset
    26
 * @key gc
2cd3ef1be718 8014240: G1: Add remembered set size information to output of G1PrintRegionLivenessInfo
tschatzl
parents:
diff changeset
    27
 * @bug 8014240
2cd3ef1be718 8014240: G1: Add remembered set size information to output of G1PrintRegionLivenessInfo
tschatzl
parents:
diff changeset
    28
 * @summary Test output of G1PrintRegionRememberedSetInfo
40886
98cb935dc074 8164660: MinimalVM is not tested with GC tests
dfazunen
parents: 40631
diff changeset
    29
 * @requires vm.gc.G1
40631
ed82623d7831 8157957: ClassNotFoundException: jdk.test.lib.JDKToolFinder
ctornqvi
parents: 36851
diff changeset
    30
 * @library /test/lib
36851
03e2f4d0a421 8153737: Unsupported Module
chegar
parents: 35061
diff changeset
    31
 * @modules java.base/jdk.internal.misc
29678
dd2f3932c21e 8075586: Add @modules as needed to the open hotspot tests
ykantser
parents: 18993
diff changeset
    32
 *          java.management
18993
58423218a3f6 8020123: Test gc/g1/TestPrintRegionRememberedSetInfo.java fails with "test result: Error. No action after @build"
tschatzl
parents: 17395
diff changeset
    33
 * @run main TestPrintRegionRememberedSetInfo
17395
2cd3ef1be718 8014240: G1: Add remembered set size information to output of G1PrintRegionLivenessInfo
tschatzl
parents:
diff changeset
    34
 * @author thomas.schatzl@oracle.com
2cd3ef1be718 8014240: G1: Add remembered set size information to output of G1PrintRegionLivenessInfo
tschatzl
parents:
diff changeset
    35
 */
2cd3ef1be718 8014240: G1: Add remembered set size information to output of G1PrintRegionLivenessInfo
tschatzl
parents:
diff changeset
    36
40631
ed82623d7831 8157957: ClassNotFoundException: jdk.test.lib.JDKToolFinder
ctornqvi
parents: 36851
diff changeset
    37
import jdk.test.lib.process.OutputAnalyzer;
ed82623d7831 8157957: ClassNotFoundException: jdk.test.lib.JDKToolFinder
ctornqvi
parents: 36851
diff changeset
    38
import jdk.test.lib.process.ProcessTools;
17395
2cd3ef1be718 8014240: G1: Add remembered set size information to output of G1PrintRegionLivenessInfo
tschatzl
parents:
diff changeset
    39
import java.lang.Thread;
2cd3ef1be718 8014240: G1: Add remembered set size information to output of G1PrintRegionLivenessInfo
tschatzl
parents:
diff changeset
    40
import java.util.ArrayList;
2cd3ef1be718 8014240: G1: Add remembered set size information to output of G1PrintRegionLivenessInfo
tschatzl
parents:
diff changeset
    41
import java.util.Arrays;
2cd3ef1be718 8014240: G1: Add remembered set size information to output of G1PrintRegionLivenessInfo
tschatzl
parents:
diff changeset
    42
2cd3ef1be718 8014240: G1: Add remembered set size information to output of G1PrintRegionLivenessInfo
tschatzl
parents:
diff changeset
    43
class RunAndWaitForMarking {
2cd3ef1be718 8014240: G1: Add remembered set size information to output of G1PrintRegionLivenessInfo
tschatzl
parents:
diff changeset
    44
    public static void main(String[] args) {
2cd3ef1be718 8014240: G1: Add remembered set size information to output of G1PrintRegionLivenessInfo
tschatzl
parents:
diff changeset
    45
        System.gc();
2cd3ef1be718 8014240: G1: Add remembered set size information to output of G1PrintRegionLivenessInfo
tschatzl
parents:
diff changeset
    46
        try {
2cd3ef1be718 8014240: G1: Add remembered set size information to output of G1PrintRegionLivenessInfo
tschatzl
parents:
diff changeset
    47
            Thread.sleep(200);
2cd3ef1be718 8014240: G1: Add remembered set size information to output of G1PrintRegionLivenessInfo
tschatzl
parents:
diff changeset
    48
        } catch (InterruptedException e) {
2cd3ef1be718 8014240: G1: Add remembered set size information to output of G1PrintRegionLivenessInfo
tschatzl
parents:
diff changeset
    49
        }
2cd3ef1be718 8014240: G1: Add remembered set size information to output of G1PrintRegionLivenessInfo
tschatzl
parents:
diff changeset
    50
    }
2cd3ef1be718 8014240: G1: Add remembered set size information to output of G1PrintRegionLivenessInfo
tschatzl
parents:
diff changeset
    51
}
2cd3ef1be718 8014240: G1: Add remembered set size information to output of G1PrintRegionLivenessInfo
tschatzl
parents:
diff changeset
    52
2cd3ef1be718 8014240: G1: Add remembered set size information to output of G1PrintRegionLivenessInfo
tschatzl
parents:
diff changeset
    53
public class TestPrintRegionRememberedSetInfo {
2cd3ef1be718 8014240: G1: Add remembered set size information to output of G1PrintRegionLivenessInfo
tschatzl
parents:
diff changeset
    54
2cd3ef1be718 8014240: G1: Add remembered set size information to output of G1PrintRegionLivenessInfo
tschatzl
parents:
diff changeset
    55
    public static String runTest(String arg) throws Exception {
2cd3ef1be718 8014240: G1: Add remembered set size information to output of G1PrintRegionLivenessInfo
tschatzl
parents:
diff changeset
    56
        ArrayList<String> finalargs = new ArrayList<String>();
2cd3ef1be718 8014240: G1: Add remembered set size information to output of G1PrintRegionLivenessInfo
tschatzl
parents:
diff changeset
    57
        String[] defaultArgs = new String[] {
2cd3ef1be718 8014240: G1: Add remembered set size information to output of G1PrintRegionLivenessInfo
tschatzl
parents:
diff changeset
    58
            "-XX:+UseG1GC",
2cd3ef1be718 8014240: G1: Add remembered set size information to output of G1PrintRegionLivenessInfo
tschatzl
parents:
diff changeset
    59
            "-Xmx10m",
2cd3ef1be718 8014240: G1: Add remembered set size information to output of G1PrintRegionLivenessInfo
tschatzl
parents:
diff changeset
    60
            "-XX:+ExplicitGCInvokesConcurrent",
2cd3ef1be718 8014240: G1: Add remembered set size information to output of G1PrintRegionLivenessInfo
tschatzl
parents:
diff changeset
    61
            "-XX:+UnlockDiagnosticVMOptions",
2cd3ef1be718 8014240: G1: Add remembered set size information to output of G1PrintRegionLivenessInfo
tschatzl
parents:
diff changeset
    62
            "-XX:G1HeapRegionSize=1M",
2cd3ef1be718 8014240: G1: Add remembered set size information to output of G1PrintRegionLivenessInfo
tschatzl
parents:
diff changeset
    63
            "-XX:InitiatingHeapOccupancyPercent=0",
2cd3ef1be718 8014240: G1: Add remembered set size information to output of G1PrintRegionLivenessInfo
tschatzl
parents:
diff changeset
    64
        };
2cd3ef1be718 8014240: G1: Add remembered set size information to output of G1PrintRegionLivenessInfo
tschatzl
parents:
diff changeset
    65
2cd3ef1be718 8014240: G1: Add remembered set size information to output of G1PrintRegionLivenessInfo
tschatzl
parents:
diff changeset
    66
        finalargs.addAll(Arrays.asList(defaultArgs));
2cd3ef1be718 8014240: G1: Add remembered set size information to output of G1PrintRegionLivenessInfo
tschatzl
parents:
diff changeset
    67
        finalargs.add(arg);
2cd3ef1be718 8014240: G1: Add remembered set size information to output of G1PrintRegionLivenessInfo
tschatzl
parents:
diff changeset
    68
2cd3ef1be718 8014240: G1: Add remembered set size information to output of G1PrintRegionLivenessInfo
tschatzl
parents:
diff changeset
    69
        finalargs.add(RunAndWaitForMarking.class.getName());
2cd3ef1be718 8014240: G1: Add remembered set size information to output of G1PrintRegionLivenessInfo
tschatzl
parents:
diff changeset
    70
2cd3ef1be718 8014240: G1: Add remembered set size information to output of G1PrintRegionLivenessInfo
tschatzl
parents:
diff changeset
    71
        ProcessBuilder pb = ProcessTools.createJavaProcessBuilder(
2cd3ef1be718 8014240: G1: Add remembered set size information to output of G1PrintRegionLivenessInfo
tschatzl
parents:
diff changeset
    72
            finalargs.toArray(new String[0]));
2cd3ef1be718 8014240: G1: Add remembered set size information to output of G1PrintRegionLivenessInfo
tschatzl
parents:
diff changeset
    73
        OutputAnalyzer output = new OutputAnalyzer(pb.start());
2cd3ef1be718 8014240: G1: Add remembered set size information to output of G1PrintRegionLivenessInfo
tschatzl
parents:
diff changeset
    74
        output.shouldHaveExitValue(0);
2cd3ef1be718 8014240: G1: Add remembered set size information to output of G1PrintRegionLivenessInfo
tschatzl
parents:
diff changeset
    75
2cd3ef1be718 8014240: G1: Add remembered set size information to output of G1PrintRegionLivenessInfo
tschatzl
parents:
diff changeset
    76
        String result = output.getStdout();
2cd3ef1be718 8014240: G1: Add remembered set size information to output of G1PrintRegionLivenessInfo
tschatzl
parents:
diff changeset
    77
        return result;
2cd3ef1be718 8014240: G1: Add remembered set size information to output of G1PrintRegionLivenessInfo
tschatzl
parents:
diff changeset
    78
    }
2cd3ef1be718 8014240: G1: Add remembered set size information to output of G1PrintRegionLivenessInfo
tschatzl
parents:
diff changeset
    79
2cd3ef1be718 8014240: G1: Add remembered set size information to output of G1PrintRegionLivenessInfo
tschatzl
parents:
diff changeset
    80
    public static void main(String[] args) throws Exception {
2cd3ef1be718 8014240: G1: Add remembered set size information to output of G1PrintRegionLivenessInfo
tschatzl
parents:
diff changeset
    81
        String result;
2cd3ef1be718 8014240: G1: Add remembered set size information to output of G1PrintRegionLivenessInfo
tschatzl
parents:
diff changeset
    82
35061
be6025ebffea 8145092: Use Unified Logging for the GC logging
brutisso
parents: 30604
diff changeset
    83
        result = runTest("-Xlog:gc+liveness=trace");
17395
2cd3ef1be718 8014240: G1: Add remembered set size information to output of G1PrintRegionLivenessInfo
tschatzl
parents:
diff changeset
    84
        // check that we got region statistics output
2cd3ef1be718 8014240: G1: Add remembered set size information to output of G1PrintRegionLivenessInfo
tschatzl
parents:
diff changeset
    85
        if (result.indexOf("PHASE") == -1) {
2cd3ef1be718 8014240: G1: Add remembered set size information to output of G1PrintRegionLivenessInfo
tschatzl
parents:
diff changeset
    86
            throw new RuntimeException("Unexpected output from -XX:+PrintRegionLivenessInfo found.");
2cd3ef1be718 8014240: G1: Add remembered set size information to output of G1PrintRegionLivenessInfo
tschatzl
parents:
diff changeset
    87
        }
2cd3ef1be718 8014240: G1: Add remembered set size information to output of G1PrintRegionLivenessInfo
tschatzl
parents:
diff changeset
    88
35061
be6025ebffea 8145092: Use Unified Logging for the GC logging
brutisso
parents: 30604
diff changeset
    89
        result = runTest("-Xlog:gc+liveness");
17395
2cd3ef1be718 8014240: G1: Add remembered set size information to output of G1PrintRegionLivenessInfo
tschatzl
parents:
diff changeset
    90
        if (result.indexOf("remset") != -1) {
2cd3ef1be718 8014240: G1: Add remembered set size information to output of G1PrintRegionLivenessInfo
tschatzl
parents:
diff changeset
    91
            throw new RuntimeException("Should find remembered set information in output.");
2cd3ef1be718 8014240: G1: Add remembered set size information to output of G1PrintRegionLivenessInfo
tschatzl
parents:
diff changeset
    92
        }
2cd3ef1be718 8014240: G1: Add remembered set size information to output of G1PrintRegionLivenessInfo
tschatzl
parents:
diff changeset
    93
    }
2cd3ef1be718 8014240: G1: Add remembered set size information to output of G1PrintRegionLivenessInfo
tschatzl
parents:
diff changeset
    94
}
2cd3ef1be718 8014240: G1: Add remembered set size information to output of G1PrintRegionLivenessInfo
tschatzl
parents:
diff changeset
    95