test/hotspot/jtreg/gc/survivorAlignment/TestPromotionFromSurvivorToTenuredAfterMinorGC.java
author rkennke
Mon, 10 Dec 2018 15:47:44 +0100
changeset 52925 9c18c9d839d3
parent 50525 767cdb97f103
child 53523 4c5184c56dc2
permissions -rw-r--r--
8214259: Implementation: JEP 189: Shenandoah: A Low-Pause-Time Garbage Collector (Experimental) Reviewed-by: kvn, roland, shade, coleenp, lmesnik, pliden, jgeorge, ihse, erikj Contributed-by: Christine Flood <chf@redhat.com>, Aleksey Shipilev <shade@redhat.com>, Roland Westrelin <rwestrel@redhat.com>, Zhenygu Gu <zgu@redhat.com>, Andrew Haley <aph@redhat.com>, Andrew Dinn <adinn@redhat.com>, Mario Torre <mtorre@redhat.com>, Roman Kennke <rkennke@redhat.com>
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
27890
9c0e6a049e1f 8037968: Add tests on alignment of objects copied to survivor space
fzhinkin
parents:
diff changeset
     1
/*
52925
9c18c9d839d3 8214259: Implementation: JEP 189: Shenandoah: A Low-Pause-Time Garbage Collector (Experimental)
rkennke
parents: 50525
diff changeset
     2
 * Copyright (c) 2014, 2018, Oracle and/or its affiliates. All rights reserved.
27890
9c0e6a049e1f 8037968: Add tests on alignment of objects copied to survivor space
fzhinkin
parents:
diff changeset
     3
 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
9c0e6a049e1f 8037968: Add tests on alignment of objects copied to survivor space
fzhinkin
parents:
diff changeset
     4
 *
9c0e6a049e1f 8037968: Add tests on alignment of objects copied to survivor space
fzhinkin
parents:
diff changeset
     5
 * This code is free software; you can redistribute it and/or modify it
9c0e6a049e1f 8037968: Add tests on alignment of objects copied to survivor space
fzhinkin
parents:
diff changeset
     6
 * under the terms of the GNU General Public License version 2 only, as
9c0e6a049e1f 8037968: Add tests on alignment of objects copied to survivor space
fzhinkin
parents:
diff changeset
     7
 * published by the Free Software Foundation.
9c0e6a049e1f 8037968: Add tests on alignment of objects copied to survivor space
fzhinkin
parents:
diff changeset
     8
 *
9c0e6a049e1f 8037968: Add tests on alignment of objects copied to survivor space
fzhinkin
parents:
diff changeset
     9
 * This code is distributed in the hope that it will be useful, but WITHOUT
9c0e6a049e1f 8037968: Add tests on alignment of objects copied to survivor space
fzhinkin
parents:
diff changeset
    10
 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
9c0e6a049e1f 8037968: Add tests on alignment of objects copied to survivor space
fzhinkin
parents:
diff changeset
    11
 * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
9c0e6a049e1f 8037968: Add tests on alignment of objects copied to survivor space
fzhinkin
parents:
diff changeset
    12
 * version 2 for more details (a copy is included in the LICENSE file that
9c0e6a049e1f 8037968: Add tests on alignment of objects copied to survivor space
fzhinkin
parents:
diff changeset
    13
 * accompanied this code).
9c0e6a049e1f 8037968: Add tests on alignment of objects copied to survivor space
fzhinkin
parents:
diff changeset
    14
 *
9c0e6a049e1f 8037968: Add tests on alignment of objects copied to survivor space
fzhinkin
parents:
diff changeset
    15
 * You should have received a copy of the GNU General Public License version
9c0e6a049e1f 8037968: Add tests on alignment of objects copied to survivor space
fzhinkin
parents:
diff changeset
    16
 * 2 along with this work; if not, write to the Free Software Foundation,
9c0e6a049e1f 8037968: Add tests on alignment of objects copied to survivor space
fzhinkin
parents:
diff changeset
    17
 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
9c0e6a049e1f 8037968: Add tests on alignment of objects copied to survivor space
fzhinkin
parents:
diff changeset
    18
 *
9c0e6a049e1f 8037968: Add tests on alignment of objects copied to survivor space
fzhinkin
parents:
diff changeset
    19
 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
9c0e6a049e1f 8037968: Add tests on alignment of objects copied to survivor space
fzhinkin
parents:
diff changeset
    20
 * or visit www.oracle.com if you need additional information or have any
9c0e6a049e1f 8037968: Add tests on alignment of objects copied to survivor space
fzhinkin
parents:
diff changeset
    21
 * questions.
9c0e6a049e1f 8037968: Add tests on alignment of objects copied to survivor space
fzhinkin
parents:
diff changeset
    22
 */
9c0e6a049e1f 8037968: Add tests on alignment of objects copied to survivor space
fzhinkin
parents:
diff changeset
    23
9c0e6a049e1f 8037968: Add tests on alignment of objects copied to survivor space
fzhinkin
parents:
diff changeset
    24
/**
9c0e6a049e1f 8037968: Add tests on alignment of objects copied to survivor space
fzhinkin
parents:
diff changeset
    25
 * @test
9c0e6a049e1f 8037968: Add tests on alignment of objects copied to survivor space
fzhinkin
parents:
diff changeset
    26
 * @bug 8031323
9c0e6a049e1f 8037968: Add tests on alignment of objects copied to survivor space
fzhinkin
parents:
diff changeset
    27
 * @summary Verify that objects promoted from survivor space to tenured space
9c0e6a049e1f 8037968: Add tests on alignment of objects copied to survivor space
fzhinkin
parents:
diff changeset
    28
 *          when their age exceeded tenuring threshold are not aligned to
9c0e6a049e1f 8037968: Add tests on alignment of objects copied to survivor space
fzhinkin
parents:
diff changeset
    29
 *          SurvivorAlignmentInBytes value.
52925
9c18c9d839d3 8214259: Implementation: JEP 189: Shenandoah: A Low-Pause-Time Garbage Collector (Experimental)
rkennke
parents: 50525
diff changeset
    30
 * @requires vm.gc != "Z" & vm.gc != "Shenandoah"
40631
ed82623d7831 8157957: ClassNotFoundException: jdk.test.lib.JDKToolFinder
ctornqvi
parents: 36851
diff changeset
    31
 * @library /test/lib
36851
03e2f4d0a421 8153737: Unsupported Module
chegar
parents: 33730
diff changeset
    32
 * @modules java.base/jdk.internal.misc
29678
dd2f3932c21e 8075586: Add @modules as needed to the open hotspot tests
ykantser
parents: 28203
diff changeset
    33
 *          java.management
40631
ed82623d7831 8157957: ClassNotFoundException: jdk.test.lib.JDKToolFinder
ctornqvi
parents: 36851
diff changeset
    34
 * @build sun.hotspot.WhiteBox
48791
6e079ff6c83c 8186635: ClassFileInstaller should be run as a driver
iignatyev
parents: 47216
diff changeset
    35
 * @run driver ClassFileInstaller sun.hotspot.WhiteBox
27890
9c0e6a049e1f 8037968: Add tests on alignment of objects copied to survivor space
fzhinkin
parents:
diff changeset
    36
 *                              sun.hotspot.WhiteBox$WhiteBoxPermission
9c0e6a049e1f 8037968: Add tests on alignment of objects copied to survivor space
fzhinkin
parents:
diff changeset
    37
 * @run main/othervm -Xbootclasspath/a:. -XX:+UnlockDiagnosticVMOptions
9c0e6a049e1f 8037968: Add tests on alignment of objects copied to survivor space
fzhinkin
parents:
diff changeset
    38
 *                   -XX:+WhiteBoxAPI -XX:NewSize=128m -XX:MaxNewSize=128m
31370
e27de7435453 8078669: G1 applies SurvivorAlignmentInBytes to both survivor and old gen
tschatzl
parents: 29678
diff changeset
    39
 *                   -XX:OldSize=32M -XX:MaxHeapSize=160m -XX:SurvivorRatio=1 -XX:-ResizePLAB
27890
9c0e6a049e1f 8037968: Add tests on alignment of objects copied to survivor space
fzhinkin
parents:
diff changeset
    40
 *                   -XX:-ExplicitGCInvokesConcurrent
9c0e6a049e1f 8037968: Add tests on alignment of objects copied to survivor space
fzhinkin
parents:
diff changeset
    41
 *                   -XX:+UnlockExperimentalVMOptions
9c0e6a049e1f 8037968: Add tests on alignment of objects copied to survivor space
fzhinkin
parents:
diff changeset
    42
 *                   -XX:SurvivorAlignmentInBytes=32
9c0e6a049e1f 8037968: Add tests on alignment of objects copied to survivor space
fzhinkin
parents:
diff changeset
    43
 *                   TestPromotionFromSurvivorToTenuredAfterMinorGC 10m 9
9c0e6a049e1f 8037968: Add tests on alignment of objects copied to survivor space
fzhinkin
parents:
diff changeset
    44
 *                   TENURED
9c0e6a049e1f 8037968: Add tests on alignment of objects copied to survivor space
fzhinkin
parents:
diff changeset
    45
 * @run main/othervm -Xbootclasspath/a:. -XX:+UnlockDiagnosticVMOptions
9c0e6a049e1f 8037968: Add tests on alignment of objects copied to survivor space
fzhinkin
parents:
diff changeset
    46
 *                   -XX:+WhiteBoxAPI -XX:NewSize=128m -XX:MaxNewSize=128m
31370
e27de7435453 8078669: G1 applies SurvivorAlignmentInBytes to both survivor and old gen
tschatzl
parents: 29678
diff changeset
    47
 *                   -XX:OldSize=32M -XX:MaxHeapSize=160m -XX:SurvivorRatio=1 -XX:-ResizePLAB
27890
9c0e6a049e1f 8037968: Add tests on alignment of objects copied to survivor space
fzhinkin
parents:
diff changeset
    48
 *                   -XX:-ExplicitGCInvokesConcurrent
9c0e6a049e1f 8037968: Add tests on alignment of objects copied to survivor space
fzhinkin
parents:
diff changeset
    49
 *                   -XX:+UnlockExperimentalVMOptions
9c0e6a049e1f 8037968: Add tests on alignment of objects copied to survivor space
fzhinkin
parents:
diff changeset
    50
 *                   -XX:SurvivorAlignmentInBytes=32
9c0e6a049e1f 8037968: Add tests on alignment of objects copied to survivor space
fzhinkin
parents:
diff changeset
    51
 *                   TestPromotionFromSurvivorToTenuredAfterMinorGC 20m 47
9c0e6a049e1f 8037968: Add tests on alignment of objects copied to survivor space
fzhinkin
parents:
diff changeset
    52
 *                   TENURED
9c0e6a049e1f 8037968: Add tests on alignment of objects copied to survivor space
fzhinkin
parents:
diff changeset
    53
 * @run main/othervm -Xbootclasspath/a:. -XX:+UnlockDiagnosticVMOptions
9c0e6a049e1f 8037968: Add tests on alignment of objects copied to survivor space
fzhinkin
parents:
diff changeset
    54
 *                   -XX:+WhiteBoxAPI -XX:NewSize=200m -XX:MaxNewSize=200m
31370
e27de7435453 8078669: G1 applies SurvivorAlignmentInBytes to both survivor and old gen
tschatzl
parents: 29678
diff changeset
    55
 *                   -XX:OldSize=32M -XX:MaxHeapSize=232m -XX:SurvivorRatio=1 -XX:-ResizePLAB
28182
8a51e754d3d8 8066143: [TESTBUG] New tests in gc/survivorAlignment/ fails
fzhinkin
parents: 27890
diff changeset
    56
 *                   -XX:-ExplicitGCInvokesConcurrent
27890
9c0e6a049e1f 8037968: Add tests on alignment of objects copied to survivor space
fzhinkin
parents:
diff changeset
    57
 *                   -XX:+UnlockExperimentalVMOptions
9c0e6a049e1f 8037968: Add tests on alignment of objects copied to survivor space
fzhinkin
parents:
diff changeset
    58
 *                   -XX:SurvivorAlignmentInBytes=64
9c0e6a049e1f 8037968: Add tests on alignment of objects copied to survivor space
fzhinkin
parents:
diff changeset
    59
 *                   TestPromotionFromSurvivorToTenuredAfterMinorGC 10m 9
9c0e6a049e1f 8037968: Add tests on alignment of objects copied to survivor space
fzhinkin
parents:
diff changeset
    60
 *                   TENURED
9c0e6a049e1f 8037968: Add tests on alignment of objects copied to survivor space
fzhinkin
parents:
diff changeset
    61
 * @run main/othervm -Xbootclasspath/a:. -XX:+UnlockDiagnosticVMOptions
9c0e6a049e1f 8037968: Add tests on alignment of objects copied to survivor space
fzhinkin
parents:
diff changeset
    62
 *                   -XX:+WhiteBoxAPI -XX:NewSize=128m -XX:MaxNewSize=128m
31370
e27de7435453 8078669: G1 applies SurvivorAlignmentInBytes to both survivor and old gen
tschatzl
parents: 29678
diff changeset
    63
 *                   -XX:OldSize=32M -XX:MaxHeapSize=160m -XX:SurvivorRatio=1 -XX:-ResizePLAB
27890
9c0e6a049e1f 8037968: Add tests on alignment of objects copied to survivor space
fzhinkin
parents:
diff changeset
    64
 *                   -XX:-ExplicitGCInvokesConcurrent
9c0e6a049e1f 8037968: Add tests on alignment of objects copied to survivor space
fzhinkin
parents:
diff changeset
    65
 *                   -XX:+UnlockExperimentalVMOptions
9c0e6a049e1f 8037968: Add tests on alignment of objects copied to survivor space
fzhinkin
parents:
diff changeset
    66
 *                   -XX:SurvivorAlignmentInBytes=64
9c0e6a049e1f 8037968: Add tests on alignment of objects copied to survivor space
fzhinkin
parents:
diff changeset
    67
 *                   TestPromotionFromSurvivorToTenuredAfterMinorGC 20m 87
9c0e6a049e1f 8037968: Add tests on alignment of objects copied to survivor space
fzhinkin
parents:
diff changeset
    68
 *                   TENURED
9c0e6a049e1f 8037968: Add tests on alignment of objects copied to survivor space
fzhinkin
parents:
diff changeset
    69
 * @run main/othervm -Xbootclasspath/a:. -XX:+UnlockDiagnosticVMOptions
9c0e6a049e1f 8037968: Add tests on alignment of objects copied to survivor space
fzhinkin
parents:
diff changeset
    70
 *                   -XX:+WhiteBoxAPI -XX:NewSize=256m -XX:MaxNewSize=256m
31370
e27de7435453 8078669: G1 applies SurvivorAlignmentInBytes to both survivor and old gen
tschatzl
parents: 29678
diff changeset
    71
 *                   -XX:OldSize=32M -XX:MaxHeapSize=288m -XX:SurvivorRatio=1 -XX:-ResizePLAB
28182
8a51e754d3d8 8066143: [TESTBUG] New tests in gc/survivorAlignment/ fails
fzhinkin
parents: 27890
diff changeset
    72
 *                   -XX:-ExplicitGCInvokesConcurrent
27890
9c0e6a049e1f 8037968: Add tests on alignment of objects copied to survivor space
fzhinkin
parents:
diff changeset
    73
 *                   -XX:+UnlockExperimentalVMOptions
9c0e6a049e1f 8037968: Add tests on alignment of objects copied to survivor space
fzhinkin
parents:
diff changeset
    74
 *                   -XX:SurvivorAlignmentInBytes=128
9c0e6a049e1f 8037968: Add tests on alignment of objects copied to survivor space
fzhinkin
parents:
diff changeset
    75
 *                    TestPromotionFromSurvivorToTenuredAfterMinorGC 10m 9
9c0e6a049e1f 8037968: Add tests on alignment of objects copied to survivor space
fzhinkin
parents:
diff changeset
    76
 *                    TENURED
9c0e6a049e1f 8037968: Add tests on alignment of objects copied to survivor space
fzhinkin
parents:
diff changeset
    77
 * @run main/othervm -Xbootclasspath/a:. -XX:+UnlockDiagnosticVMOptions
9c0e6a049e1f 8037968: Add tests on alignment of objects copied to survivor space
fzhinkin
parents:
diff changeset
    78
 *                   -XX:+WhiteBoxAPI -XX:NewSize=128m -XX:MaxNewSize=128m
31370
e27de7435453 8078669: G1 applies SurvivorAlignmentInBytes to both survivor and old gen
tschatzl
parents: 29678
diff changeset
    79
 *                   -XX:OldSize=32M -XX:MaxHeapSize=160m -XX:SurvivorRatio=1 -XX:-ResizePLAB
27890
9c0e6a049e1f 8037968: Add tests on alignment of objects copied to survivor space
fzhinkin
parents:
diff changeset
    80
 *                   -XX:-ExplicitGCInvokesConcurrent
9c0e6a049e1f 8037968: Add tests on alignment of objects copied to survivor space
fzhinkin
parents:
diff changeset
    81
 *                   -XX:+UnlockExperimentalVMOptions
9c0e6a049e1f 8037968: Add tests on alignment of objects copied to survivor space
fzhinkin
parents:
diff changeset
    82
 *                   -XX:SurvivorAlignmentInBytes=128
9c0e6a049e1f 8037968: Add tests on alignment of objects copied to survivor space
fzhinkin
parents:
diff changeset
    83
 *                   TestPromotionFromSurvivorToTenuredAfterMinorGC 20m 147
9c0e6a049e1f 8037968: Add tests on alignment of objects copied to survivor space
fzhinkin
parents:
diff changeset
    84
 *                   TENURED
9c0e6a049e1f 8037968: Add tests on alignment of objects copied to survivor space
fzhinkin
parents:
diff changeset
    85
 */
9c0e6a049e1f 8037968: Add tests on alignment of objects copied to survivor space
fzhinkin
parents:
diff changeset
    86
public class TestPromotionFromSurvivorToTenuredAfterMinorGC {
9c0e6a049e1f 8037968: Add tests on alignment of objects copied to survivor space
fzhinkin
parents:
diff changeset
    87
    public static void main(String args[]) throws Exception {
9c0e6a049e1f 8037968: Add tests on alignment of objects copied to survivor space
fzhinkin
parents:
diff changeset
    88
        SurvivorAlignmentTestMain test
9c0e6a049e1f 8037968: Add tests on alignment of objects copied to survivor space
fzhinkin
parents:
diff changeset
    89
                = SurvivorAlignmentTestMain.fromArgs(args);
9c0e6a049e1f 8037968: Add tests on alignment of objects copied to survivor space
fzhinkin
parents:
diff changeset
    90
        System.out.println(test);
9c0e6a049e1f 8037968: Add tests on alignment of objects copied to survivor space
fzhinkin
parents:
diff changeset
    91
9c0e6a049e1f 8037968: Add tests on alignment of objects copied to survivor space
fzhinkin
parents:
diff changeset
    92
        long expectedMemoryUsage = test.getExpectedMemoryUsage();
9c0e6a049e1f 8037968: Add tests on alignment of objects copied to survivor space
fzhinkin
parents:
diff changeset
    93
        test.baselineMemoryAllocation();
9c0e6a049e1f 8037968: Add tests on alignment of objects copied to survivor space
fzhinkin
parents:
diff changeset
    94
        SurvivorAlignmentTestMain.WHITE_BOX.fullGC();
9c0e6a049e1f 8037968: Add tests on alignment of objects copied to survivor space
fzhinkin
parents:
diff changeset
    95
        // increase expected usage by current old gen usage
9c0e6a049e1f 8037968: Add tests on alignment of objects copied to survivor space
fzhinkin
parents:
diff changeset
    96
        expectedMemoryUsage += SurvivorAlignmentTestMain.getAlignmentHelper(
9c0e6a049e1f 8037968: Add tests on alignment of objects copied to survivor space
fzhinkin
parents:
diff changeset
    97
                SurvivorAlignmentTestMain.HeapSpace.TENURED)
9c0e6a049e1f 8037968: Add tests on alignment of objects copied to survivor space
fzhinkin
parents:
diff changeset
    98
                .getActualMemoryUsage();
9c0e6a049e1f 8037968: Add tests on alignment of objects copied to survivor space
fzhinkin
parents:
diff changeset
    99
9c0e6a049e1f 8037968: Add tests on alignment of objects copied to survivor space
fzhinkin
parents:
diff changeset
   100
        test.allocate();
32367
8527712452de 8130308: Too low memory usage in TestPromotionFromSurvivorToTenuredAfterMinorGC.java
jwilhelm
parents: 31626
diff changeset
   101
        for (int i = 0; i <= SurvivorAlignmentTestMain.MAX_TENURING_THRESHOLD; i++) {
27890
9c0e6a049e1f 8037968: Add tests on alignment of objects copied to survivor space
fzhinkin
parents:
diff changeset
   102
            SurvivorAlignmentTestMain.WHITE_BOX.youngGC();
9c0e6a049e1f 8037968: Add tests on alignment of objects copied to survivor space
fzhinkin
parents:
diff changeset
   103
        }
9c0e6a049e1f 8037968: Add tests on alignment of objects copied to survivor space
fzhinkin
parents:
diff changeset
   104
32367
8527712452de 8130308: Too low memory usage in TestPromotionFromSurvivorToTenuredAfterMinorGC.java
jwilhelm
parents: 31626
diff changeset
   105
        // Sometimes we see that data unrelated to the test has been allocated during
8527712452de 8130308: Too low memory usage in TestPromotionFromSurvivorToTenuredAfterMinorGC.java
jwilhelm
parents: 31626
diff changeset
   106
        // the loop. This data is included in the expectedMemoryUsage since we look
8527712452de 8130308: Too low memory usage in TestPromotionFromSurvivorToTenuredAfterMinorGC.java
jwilhelm
parents: 31626
diff changeset
   107
        // through all threads to see what they allocated. If this data is still in
8527712452de 8130308: Too low memory usage in TestPromotionFromSurvivorToTenuredAfterMinorGC.java
jwilhelm
parents: 31626
diff changeset
   108
        // the survivor area however, it should not be included in expectedMemoryUsage
8527712452de 8130308: Too low memory usage in TestPromotionFromSurvivorToTenuredAfterMinorGC.java
jwilhelm
parents: 31626
diff changeset
   109
        // since the verification below only look at what's in tenured space.
8527712452de 8130308: Too low memory usage in TestPromotionFromSurvivorToTenuredAfterMinorGC.java
jwilhelm
parents: 31626
diff changeset
   110
        expectedMemoryUsage -= SurvivorAlignmentTestMain.getAlignmentHelper(
8527712452de 8130308: Too low memory usage in TestPromotionFromSurvivorToTenuredAfterMinorGC.java
jwilhelm
parents: 31626
diff changeset
   111
                                   SurvivorAlignmentTestMain.HeapSpace.SURVIVOR)
8527712452de 8130308: Too low memory usage in TestPromotionFromSurvivorToTenuredAfterMinorGC.java
jwilhelm
parents: 31626
diff changeset
   112
                                   .getActualMemoryUsage();
27890
9c0e6a049e1f 8037968: Add tests on alignment of objects copied to survivor space
fzhinkin
parents:
diff changeset
   113
        test.verifyMemoryUsage(expectedMemoryUsage);
9c0e6a049e1f 8037968: Add tests on alignment of objects copied to survivor space
fzhinkin
parents:
diff changeset
   114
    }
9c0e6a049e1f 8037968: Add tests on alignment of objects copied to survivor space
fzhinkin
parents:
diff changeset
   115
}