hotspot/test/gc/g1/TestPLABSizeBounds.java
author tschatzl
Fri, 04 Sep 2015 08:36:13 +0200
changeset 32616 888b4f477ec9
child 36851 03e2f4d0a421
permissions -rw-r--r--
8134857: Inconsistency in maximum TLAB/PLAB size and humongous object size Summary: Align TLAB/PLAB size with exact humongous object size threshold, not that value -1. Reviewed-by: jmasa, dfazunen
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
32616
888b4f477ec9 8134857: Inconsistency in maximum TLAB/PLAB size and humongous object size
tschatzl
parents:
diff changeset
     1
/*
888b4f477ec9 8134857: Inconsistency in maximum TLAB/PLAB size and humongous object size
tschatzl
parents:
diff changeset
     2
 * Copyright (c) 2015, Oracle and/or its affiliates. All rights reserved.
888b4f477ec9 8134857: Inconsistency in maximum TLAB/PLAB size and humongous object size
tschatzl
parents:
diff changeset
     3
 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
888b4f477ec9 8134857: Inconsistency in maximum TLAB/PLAB size and humongous object size
tschatzl
parents:
diff changeset
     4
 *
888b4f477ec9 8134857: Inconsistency in maximum TLAB/PLAB size and humongous object size
tschatzl
parents:
diff changeset
     5
 * This code is free software; you can redistribute it and/or modify it
888b4f477ec9 8134857: Inconsistency in maximum TLAB/PLAB size and humongous object size
tschatzl
parents:
diff changeset
     6
 * under the terms of the GNU General Public License version 2 only, as
888b4f477ec9 8134857: Inconsistency in maximum TLAB/PLAB size and humongous object size
tschatzl
parents:
diff changeset
     7
 * published by the Free Software Foundation.
888b4f477ec9 8134857: Inconsistency in maximum TLAB/PLAB size and humongous object size
tschatzl
parents:
diff changeset
     8
 *
888b4f477ec9 8134857: Inconsistency in maximum TLAB/PLAB size and humongous object size
tschatzl
parents:
diff changeset
     9
 * This code is distributed in the hope that it will be useful, but WITHOUT
888b4f477ec9 8134857: Inconsistency in maximum TLAB/PLAB size and humongous object size
tschatzl
parents:
diff changeset
    10
 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
888b4f477ec9 8134857: Inconsistency in maximum TLAB/PLAB size and humongous object size
tschatzl
parents:
diff changeset
    11
 * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
888b4f477ec9 8134857: Inconsistency in maximum TLAB/PLAB size and humongous object size
tschatzl
parents:
diff changeset
    12
 * version 2 for more details (a copy is included in the LICENSE file that
888b4f477ec9 8134857: Inconsistency in maximum TLAB/PLAB size and humongous object size
tschatzl
parents:
diff changeset
    13
 * accompanied this code).
888b4f477ec9 8134857: Inconsistency in maximum TLAB/PLAB size and humongous object size
tschatzl
parents:
diff changeset
    14
 *
888b4f477ec9 8134857: Inconsistency in maximum TLAB/PLAB size and humongous object size
tschatzl
parents:
diff changeset
    15
 * You should have received a copy of the GNU General Public License version
888b4f477ec9 8134857: Inconsistency in maximum TLAB/PLAB size and humongous object size
tschatzl
parents:
diff changeset
    16
 * 2 along with this work; if not, write to the Free Software Foundation,
888b4f477ec9 8134857: Inconsistency in maximum TLAB/PLAB size and humongous object size
tschatzl
parents:
diff changeset
    17
 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
888b4f477ec9 8134857: Inconsistency in maximum TLAB/PLAB size and humongous object size
tschatzl
parents:
diff changeset
    18
 *
888b4f477ec9 8134857: Inconsistency in maximum TLAB/PLAB size and humongous object size
tschatzl
parents:
diff changeset
    19
 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
888b4f477ec9 8134857: Inconsistency in maximum TLAB/PLAB size and humongous object size
tschatzl
parents:
diff changeset
    20
 * or visit www.oracle.com if you need additional information or have any
888b4f477ec9 8134857: Inconsistency in maximum TLAB/PLAB size and humongous object size
tschatzl
parents:
diff changeset
    21
 * questions.
888b4f477ec9 8134857: Inconsistency in maximum TLAB/PLAB size and humongous object size
tschatzl
parents:
diff changeset
    22
 */
888b4f477ec9 8134857: Inconsistency in maximum TLAB/PLAB size and humongous object size
tschatzl
parents:
diff changeset
    23
888b4f477ec9 8134857: Inconsistency in maximum TLAB/PLAB size and humongous object size
tschatzl
parents:
diff changeset
    24
/*
888b4f477ec9 8134857: Inconsistency in maximum TLAB/PLAB size and humongous object size
tschatzl
parents:
diff changeset
    25
 * @test TestPLABSizeBounds
888b4f477ec9 8134857: Inconsistency in maximum TLAB/PLAB size and humongous object size
tschatzl
parents:
diff changeset
    26
 * @bug 8134857
888b4f477ec9 8134857: Inconsistency in maximum TLAB/PLAB size and humongous object size
tschatzl
parents:
diff changeset
    27
 * @summary Regression test to ensure that G1 supports PLAB sizes of half a region size.
888b4f477ec9 8134857: Inconsistency in maximum TLAB/PLAB size and humongous object size
tschatzl
parents:
diff changeset
    28
 * @requires vm.gc=="G1" | vm.gc=="null"
888b4f477ec9 8134857: Inconsistency in maximum TLAB/PLAB size and humongous object size
tschatzl
parents:
diff changeset
    29
 * @key gc
888b4f477ec9 8134857: Inconsistency in maximum TLAB/PLAB size and humongous object size
tschatzl
parents:
diff changeset
    30
 * @library /testlibrary
888b4f477ec9 8134857: Inconsistency in maximum TLAB/PLAB size and humongous object size
tschatzl
parents:
diff changeset
    31
 * @modules java.base/sun.misc
888b4f477ec9 8134857: Inconsistency in maximum TLAB/PLAB size and humongous object size
tschatzl
parents:
diff changeset
    32
 *          java.management
888b4f477ec9 8134857: Inconsistency in maximum TLAB/PLAB size and humongous object size
tschatzl
parents:
diff changeset
    33
 */
888b4f477ec9 8134857: Inconsistency in maximum TLAB/PLAB size and humongous object size
tschatzl
parents:
diff changeset
    34
888b4f477ec9 8134857: Inconsistency in maximum TLAB/PLAB size and humongous object size
tschatzl
parents:
diff changeset
    35
import java.util.ArrayList;
888b4f477ec9 8134857: Inconsistency in maximum TLAB/PLAB size and humongous object size
tschatzl
parents:
diff changeset
    36
888b4f477ec9 8134857: Inconsistency in maximum TLAB/PLAB size and humongous object size
tschatzl
parents:
diff changeset
    37
import jdk.test.lib.OutputAnalyzer;
888b4f477ec9 8134857: Inconsistency in maximum TLAB/PLAB size and humongous object size
tschatzl
parents:
diff changeset
    38
import jdk.test.lib.Platform;
888b4f477ec9 8134857: Inconsistency in maximum TLAB/PLAB size and humongous object size
tschatzl
parents:
diff changeset
    39
import jdk.test.lib.ProcessTools;
888b4f477ec9 8134857: Inconsistency in maximum TLAB/PLAB size and humongous object size
tschatzl
parents:
diff changeset
    40
888b4f477ec9 8134857: Inconsistency in maximum TLAB/PLAB size and humongous object size
tschatzl
parents:
diff changeset
    41
public class TestPLABSizeBounds {
888b4f477ec9 8134857: Inconsistency in maximum TLAB/PLAB size and humongous object size
tschatzl
parents:
diff changeset
    42
888b4f477ec9 8134857: Inconsistency in maximum TLAB/PLAB size and humongous object size
tschatzl
parents:
diff changeset
    43
    public static final int M = 1024 * 1024;
888b4f477ec9 8134857: Inconsistency in maximum TLAB/PLAB size and humongous object size
tschatzl
parents:
diff changeset
    44
888b4f477ec9 8134857: Inconsistency in maximum TLAB/PLAB size and humongous object size
tschatzl
parents:
diff changeset
    45
    /**
888b4f477ec9 8134857: Inconsistency in maximum TLAB/PLAB size and humongous object size
tschatzl
parents:
diff changeset
    46
     * Starts the VM with the given region size and the given PLAB size arguments. The VM start should
888b4f477ec9 8134857: Inconsistency in maximum TLAB/PLAB size and humongous object size
tschatzl
parents:
diff changeset
    47
     * succeed if shouldSucceed is true, otherwise it should fail.
888b4f477ec9 8134857: Inconsistency in maximum TLAB/PLAB size and humongous object size
tschatzl
parents:
diff changeset
    48
     *
888b4f477ec9 8134857: Inconsistency in maximum TLAB/PLAB size and humongous object size
tschatzl
parents:
diff changeset
    49
     * @param regionSize The region size the VM should be started with in bytes.
888b4f477ec9 8134857: Inconsistency in maximum TLAB/PLAB size and humongous object size
tschatzl
parents:
diff changeset
    50
     * @param plabSize The young and old gen PLAB sizes the VM should be started with in machine words.
888b4f477ec9 8134857: Inconsistency in maximum TLAB/PLAB size and humongous object size
tschatzl
parents:
diff changeset
    51
     * @param shouldSucceed The expected result of the VM invocation.
888b4f477ec9 8134857: Inconsistency in maximum TLAB/PLAB size and humongous object size
tschatzl
parents:
diff changeset
    52
     */
888b4f477ec9 8134857: Inconsistency in maximum TLAB/PLAB size and humongous object size
tschatzl
parents:
diff changeset
    53
    public static void runTest(int regionSize, int plabSize, boolean shouldSucceed) throws Exception {
888b4f477ec9 8134857: Inconsistency in maximum TLAB/PLAB size and humongous object size
tschatzl
parents:
diff changeset
    54
        ArrayList<String> testArguments = new ArrayList<String>();
888b4f477ec9 8134857: Inconsistency in maximum TLAB/PLAB size and humongous object size
tschatzl
parents:
diff changeset
    55
888b4f477ec9 8134857: Inconsistency in maximum TLAB/PLAB size and humongous object size
tschatzl
parents:
diff changeset
    56
        testArguments.add("-XX:+UseG1GC");
888b4f477ec9 8134857: Inconsistency in maximum TLAB/PLAB size and humongous object size
tschatzl
parents:
diff changeset
    57
        testArguments.add("-Xmx256M");
888b4f477ec9 8134857: Inconsistency in maximum TLAB/PLAB size and humongous object size
tschatzl
parents:
diff changeset
    58
        testArguments.add("-XX:G1HeapRegionSize=" + regionSize);
888b4f477ec9 8134857: Inconsistency in maximum TLAB/PLAB size and humongous object size
tschatzl
parents:
diff changeset
    59
        testArguments.add("-XX:YoungPLABSize=" + plabSize);
888b4f477ec9 8134857: Inconsistency in maximum TLAB/PLAB size and humongous object size
tschatzl
parents:
diff changeset
    60
        testArguments.add("-XX:OldPLABSize=" + plabSize);
888b4f477ec9 8134857: Inconsistency in maximum TLAB/PLAB size and humongous object size
tschatzl
parents:
diff changeset
    61
        testArguments.add(GCTest.class.getName());
888b4f477ec9 8134857: Inconsistency in maximum TLAB/PLAB size and humongous object size
tschatzl
parents:
diff changeset
    62
888b4f477ec9 8134857: Inconsistency in maximum TLAB/PLAB size and humongous object size
tschatzl
parents:
diff changeset
    63
        ProcessBuilder pb = ProcessTools.createJavaProcessBuilder(testArguments.toArray(new String[0]));
888b4f477ec9 8134857: Inconsistency in maximum TLAB/PLAB size and humongous object size
tschatzl
parents:
diff changeset
    64
        OutputAnalyzer output = new OutputAnalyzer(pb.start());
888b4f477ec9 8134857: Inconsistency in maximum TLAB/PLAB size and humongous object size
tschatzl
parents:
diff changeset
    65
888b4f477ec9 8134857: Inconsistency in maximum TLAB/PLAB size and humongous object size
tschatzl
parents:
diff changeset
    66
        if (shouldSucceed) {
888b4f477ec9 8134857: Inconsistency in maximum TLAB/PLAB size and humongous object size
tschatzl
parents:
diff changeset
    67
            output.shouldHaveExitValue(0);
888b4f477ec9 8134857: Inconsistency in maximum TLAB/PLAB size and humongous object size
tschatzl
parents:
diff changeset
    68
        } else {
888b4f477ec9 8134857: Inconsistency in maximum TLAB/PLAB size and humongous object size
tschatzl
parents:
diff changeset
    69
            output.shouldHaveExitValue(1);
888b4f477ec9 8134857: Inconsistency in maximum TLAB/PLAB size and humongous object size
tschatzl
parents:
diff changeset
    70
        }
888b4f477ec9 8134857: Inconsistency in maximum TLAB/PLAB size and humongous object size
tschatzl
parents:
diff changeset
    71
    }
888b4f477ec9 8134857: Inconsistency in maximum TLAB/PLAB size and humongous object size
tschatzl
parents:
diff changeset
    72
888b4f477ec9 8134857: Inconsistency in maximum TLAB/PLAB size and humongous object size
tschatzl
parents:
diff changeset
    73
    public static void runRegionTest(int regionSize) throws Exception {
888b4f477ec9 8134857: Inconsistency in maximum TLAB/PLAB size and humongous object size
tschatzl
parents:
diff changeset
    74
        final int regionSizeInBytes = regionSize * M;
888b4f477ec9 8134857: Inconsistency in maximum TLAB/PLAB size and humongous object size
tschatzl
parents:
diff changeset
    75
        final int wordSize = Platform.is32bit() ? 4 : 8;
888b4f477ec9 8134857: Inconsistency in maximum TLAB/PLAB size and humongous object size
tschatzl
parents:
diff changeset
    76
888b4f477ec9 8134857: Inconsistency in maximum TLAB/PLAB size and humongous object size
tschatzl
parents:
diff changeset
    77
        runTest(regionSizeInBytes, (regionSizeInBytes / wordSize) / 2 - 1, true);
888b4f477ec9 8134857: Inconsistency in maximum TLAB/PLAB size and humongous object size
tschatzl
parents:
diff changeset
    78
        runTest(regionSizeInBytes, (regionSizeInBytes / wordSize) / 2, true);
888b4f477ec9 8134857: Inconsistency in maximum TLAB/PLAB size and humongous object size
tschatzl
parents:
diff changeset
    79
        runTest(regionSizeInBytes, (regionSizeInBytes / wordSize) / 2 + 1, false);
888b4f477ec9 8134857: Inconsistency in maximum TLAB/PLAB size and humongous object size
tschatzl
parents:
diff changeset
    80
    }
888b4f477ec9 8134857: Inconsistency in maximum TLAB/PLAB size and humongous object size
tschatzl
parents:
diff changeset
    81
888b4f477ec9 8134857: Inconsistency in maximum TLAB/PLAB size and humongous object size
tschatzl
parents:
diff changeset
    82
    public static void main(String[] args) throws Exception {
888b4f477ec9 8134857: Inconsistency in maximum TLAB/PLAB size and humongous object size
tschatzl
parents:
diff changeset
    83
        runRegionTest(1);
888b4f477ec9 8134857: Inconsistency in maximum TLAB/PLAB size and humongous object size
tschatzl
parents:
diff changeset
    84
        runRegionTest(2);
888b4f477ec9 8134857: Inconsistency in maximum TLAB/PLAB size and humongous object size
tschatzl
parents:
diff changeset
    85
        runRegionTest(4);
888b4f477ec9 8134857: Inconsistency in maximum TLAB/PLAB size and humongous object size
tschatzl
parents:
diff changeset
    86
        runRegionTest(8);
888b4f477ec9 8134857: Inconsistency in maximum TLAB/PLAB size and humongous object size
tschatzl
parents:
diff changeset
    87
        runRegionTest(16);
888b4f477ec9 8134857: Inconsistency in maximum TLAB/PLAB size and humongous object size
tschatzl
parents:
diff changeset
    88
        runRegionTest(32);
888b4f477ec9 8134857: Inconsistency in maximum TLAB/PLAB size and humongous object size
tschatzl
parents:
diff changeset
    89
    }
888b4f477ec9 8134857: Inconsistency in maximum TLAB/PLAB size and humongous object size
tschatzl
parents:
diff changeset
    90
888b4f477ec9 8134857: Inconsistency in maximum TLAB/PLAB size and humongous object size
tschatzl
parents:
diff changeset
    91
    static class GCTest {
888b4f477ec9 8134857: Inconsistency in maximum TLAB/PLAB size and humongous object size
tschatzl
parents:
diff changeset
    92
        public static void main(String [] args) {
888b4f477ec9 8134857: Inconsistency in maximum TLAB/PLAB size and humongous object size
tschatzl
parents:
diff changeset
    93
            System.out.println("Test completed.");
888b4f477ec9 8134857: Inconsistency in maximum TLAB/PLAB size and humongous object size
tschatzl
parents:
diff changeset
    94
        }
888b4f477ec9 8134857: Inconsistency in maximum TLAB/PLAB size and humongous object size
tschatzl
parents:
diff changeset
    95
    }
888b4f477ec9 8134857: Inconsistency in maximum TLAB/PLAB size and humongous object size
tschatzl
parents:
diff changeset
    96
}
888b4f477ec9 8134857: Inconsistency in maximum TLAB/PLAB size and humongous object size
tschatzl
parents:
diff changeset
    97