hotspot/test/gc/g1/TestHumongousAllocInitialMark.java
author mikael
Tue, 24 Dec 2013 11:48:39 -0800
changeset 22234 da823d78ad65
parent 20725 bac04ff7a443
child 28497 a7aecf0ffb6b
permissions -rw-r--r--
8029233: Update copyright year to match last edit in jdk8 hotspot repository for 2013 Summary: Copyright year updated for files modified during 2013 Reviewed-by: twisti, iveresov
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
12777
57370da2f61d 7168848: Add test to check that humongous object allocation path also checks the heap occupancy.
mnunez
parents:
diff changeset
     1
/*
22234
da823d78ad65 8029233: Update copyright year to match last edit in jdk8 hotspot repository for 2013
mikael
parents: 20725
diff changeset
     2
 * Copyright (c) 2012, 2013, Oracle and/or its affiliates. All rights reserved.
12777
57370da2f61d 7168848: Add test to check that humongous object allocation path also checks the heap occupancy.
mnunez
parents:
diff changeset
     3
 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
57370da2f61d 7168848: Add test to check that humongous object allocation path also checks the heap occupancy.
mnunez
parents:
diff changeset
     4
 *
57370da2f61d 7168848: Add test to check that humongous object allocation path also checks the heap occupancy.
mnunez
parents:
diff changeset
     5
 * This code is free software; you can redistribute it and/or modify it
57370da2f61d 7168848: Add test to check that humongous object allocation path also checks the heap occupancy.
mnunez
parents:
diff changeset
     6
 * under the terms of the GNU General Public License version 2 only, as
57370da2f61d 7168848: Add test to check that humongous object allocation path also checks the heap occupancy.
mnunez
parents:
diff changeset
     7
 * published by the Free Software Foundation.
57370da2f61d 7168848: Add test to check that humongous object allocation path also checks the heap occupancy.
mnunez
parents:
diff changeset
     8
 *
57370da2f61d 7168848: Add test to check that humongous object allocation path also checks the heap occupancy.
mnunez
parents:
diff changeset
     9
 * This code is distributed in the hope that it will be useful, but WITHOUT
57370da2f61d 7168848: Add test to check that humongous object allocation path also checks the heap occupancy.
mnunez
parents:
diff changeset
    10
 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
57370da2f61d 7168848: Add test to check that humongous object allocation path also checks the heap occupancy.
mnunez
parents:
diff changeset
    11
 * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
57370da2f61d 7168848: Add test to check that humongous object allocation path also checks the heap occupancy.
mnunez
parents:
diff changeset
    12
 * version 2 for more details (a copy is included in the LICENSE file that
57370da2f61d 7168848: Add test to check that humongous object allocation path also checks the heap occupancy.
mnunez
parents:
diff changeset
    13
 * accompanied this code).
57370da2f61d 7168848: Add test to check that humongous object allocation path also checks the heap occupancy.
mnunez
parents:
diff changeset
    14
 *
57370da2f61d 7168848: Add test to check that humongous object allocation path also checks the heap occupancy.
mnunez
parents:
diff changeset
    15
 * You should have received a copy of the GNU General Public License version
57370da2f61d 7168848: Add test to check that humongous object allocation path also checks the heap occupancy.
mnunez
parents:
diff changeset
    16
 * 2 along with this work; if not, write to the Free Software Foundation,
57370da2f61d 7168848: Add test to check that humongous object allocation path also checks the heap occupancy.
mnunez
parents:
diff changeset
    17
 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
57370da2f61d 7168848: Add test to check that humongous object allocation path also checks the heap occupancy.
mnunez
parents:
diff changeset
    18
 *
57370da2f61d 7168848: Add test to check that humongous object allocation path also checks the heap occupancy.
mnunez
parents:
diff changeset
    19
 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
57370da2f61d 7168848: Add test to check that humongous object allocation path also checks the heap occupancy.
mnunez
parents:
diff changeset
    20
 * or visit www.oracle.com if you need additional information or have any
57370da2f61d 7168848: Add test to check that humongous object allocation path also checks the heap occupancy.
mnunez
parents:
diff changeset
    21
 * questions.
57370da2f61d 7168848: Add test to check that humongous object allocation path also checks the heap occupancy.
mnunez
parents:
diff changeset
    22
 */
57370da2f61d 7168848: Add test to check that humongous object allocation path also checks the heap occupancy.
mnunez
parents:
diff changeset
    23
57370da2f61d 7168848: Add test to check that humongous object allocation path also checks the heap occupancy.
mnunez
parents:
diff changeset
    24
/*
20725
bac04ff7a443 8023158: hotspot/test/gc/7168848/HumongousAlloc.java fails 14 full gcs, expect 0 full gcs
pliden
parents: 12777
diff changeset
    25
 * @test TestHumongousAllocInitialMark
12777
57370da2f61d 7168848: Add test to check that humongous object allocation path also checks the heap occupancy.
mnunez
parents:
diff changeset
    26
 * @bug 7168848
57370da2f61d 7168848: Add test to check that humongous object allocation path also checks the heap occupancy.
mnunez
parents:
diff changeset
    27
 * @summary G1: humongous object allocations should initiate marking cycles when necessary
20725
bac04ff7a443 8023158: hotspot/test/gc/7168848/HumongousAlloc.java fails 14 full gcs, expect 0 full gcs
pliden
parents: 12777
diff changeset
    28
 * @library /testlibrary
12777
57370da2f61d 7168848: Add test to check that humongous object allocation path also checks the heap occupancy.
mnunez
parents:
diff changeset
    29
 */
20725
bac04ff7a443 8023158: hotspot/test/gc/7168848/HumongousAlloc.java fails 14 full gcs, expect 0 full gcs
pliden
parents: 12777
diff changeset
    30
bac04ff7a443 8023158: hotspot/test/gc/7168848/HumongousAlloc.java fails 14 full gcs, expect 0 full gcs
pliden
parents: 12777
diff changeset
    31
import com.oracle.java.testlibrary.*;
12777
57370da2f61d 7168848: Add test to check that humongous object allocation path also checks the heap occupancy.
mnunez
parents:
diff changeset
    32
20725
bac04ff7a443 8023158: hotspot/test/gc/7168848/HumongousAlloc.java fails 14 full gcs, expect 0 full gcs
pliden
parents: 12777
diff changeset
    33
public class TestHumongousAllocInitialMark {
bac04ff7a443 8023158: hotspot/test/gc/7168848/HumongousAlloc.java fails 14 full gcs, expect 0 full gcs
pliden
parents: 12777
diff changeset
    34
    private static final int heapSize                       = 200; // MB
bac04ff7a443 8023158: hotspot/test/gc/7168848/HumongousAlloc.java fails 14 full gcs, expect 0 full gcs
pliden
parents: 12777
diff changeset
    35
    private static final int heapRegionSize                 = 1;   // MB
bac04ff7a443 8023158: hotspot/test/gc/7168848/HumongousAlloc.java fails 14 full gcs, expect 0 full gcs
pliden
parents: 12777
diff changeset
    36
    private static final int initiatingHeapOccupancyPercent = 50;  // %
12777
57370da2f61d 7168848: Add test to check that humongous object allocation path also checks the heap occupancy.
mnunez
parents:
diff changeset
    37
20725
bac04ff7a443 8023158: hotspot/test/gc/7168848/HumongousAlloc.java fails 14 full gcs, expect 0 full gcs
pliden
parents: 12777
diff changeset
    38
    public static void main(String[] args) throws Exception {
bac04ff7a443 8023158: hotspot/test/gc/7168848/HumongousAlloc.java fails 14 full gcs, expect 0 full gcs
pliden
parents: 12777
diff changeset
    39
        ProcessBuilder pb = ProcessTools.createJavaProcessBuilder(
bac04ff7a443 8023158: hotspot/test/gc/7168848/HumongousAlloc.java fails 14 full gcs, expect 0 full gcs
pliden
parents: 12777
diff changeset
    40
            "-XX:+UseG1GC",
bac04ff7a443 8023158: hotspot/test/gc/7168848/HumongousAlloc.java fails 14 full gcs, expect 0 full gcs
pliden
parents: 12777
diff changeset
    41
            "-Xms" + heapSize + "m",
bac04ff7a443 8023158: hotspot/test/gc/7168848/HumongousAlloc.java fails 14 full gcs, expect 0 full gcs
pliden
parents: 12777
diff changeset
    42
            "-Xmx" + heapSize + "m",
bac04ff7a443 8023158: hotspot/test/gc/7168848/HumongousAlloc.java fails 14 full gcs, expect 0 full gcs
pliden
parents: 12777
diff changeset
    43
            "-XX:G1HeapRegionSize=" + heapRegionSize + "m",
bac04ff7a443 8023158: hotspot/test/gc/7168848/HumongousAlloc.java fails 14 full gcs, expect 0 full gcs
pliden
parents: 12777
diff changeset
    44
            "-XX:InitiatingHeapOccupancyPercent=" + initiatingHeapOccupancyPercent,
bac04ff7a443 8023158: hotspot/test/gc/7168848/HumongousAlloc.java fails 14 full gcs, expect 0 full gcs
pliden
parents: 12777
diff changeset
    45
            "-XX:+PrintGC",
bac04ff7a443 8023158: hotspot/test/gc/7168848/HumongousAlloc.java fails 14 full gcs, expect 0 full gcs
pliden
parents: 12777
diff changeset
    46
            HumongousObjectAllocator.class.getName());
12777
57370da2f61d 7168848: Add test to check that humongous object allocation path also checks the heap occupancy.
mnunez
parents:
diff changeset
    47
20725
bac04ff7a443 8023158: hotspot/test/gc/7168848/HumongousAlloc.java fails 14 full gcs, expect 0 full gcs
pliden
parents: 12777
diff changeset
    48
        OutputAnalyzer output = new OutputAnalyzer(pb.start());
bac04ff7a443 8023158: hotspot/test/gc/7168848/HumongousAlloc.java fails 14 full gcs, expect 0 full gcs
pliden
parents: 12777
diff changeset
    49
        output.shouldContain("GC pause (G1 Humongous Allocation) (young) (initial-mark)");
bac04ff7a443 8023158: hotspot/test/gc/7168848/HumongousAlloc.java fails 14 full gcs, expect 0 full gcs
pliden
parents: 12777
diff changeset
    50
        output.shouldNotContain("Full GC");
bac04ff7a443 8023158: hotspot/test/gc/7168848/HumongousAlloc.java fails 14 full gcs, expect 0 full gcs
pliden
parents: 12777
diff changeset
    51
        output.shouldHaveExitValue(0);
12777
57370da2f61d 7168848: Add test to check that humongous object allocation path also checks the heap occupancy.
mnunez
parents:
diff changeset
    52
    }
57370da2f61d 7168848: Add test to check that humongous object allocation path also checks the heap occupancy.
mnunez
parents:
diff changeset
    53
20725
bac04ff7a443 8023158: hotspot/test/gc/7168848/HumongousAlloc.java fails 14 full gcs, expect 0 full gcs
pliden
parents: 12777
diff changeset
    54
    static class HumongousObjectAllocator {
bac04ff7a443 8023158: hotspot/test/gc/7168848/HumongousAlloc.java fails 14 full gcs, expect 0 full gcs
pliden
parents: 12777
diff changeset
    55
        private static byte[] dummy;
bac04ff7a443 8023158: hotspot/test/gc/7168848/HumongousAlloc.java fails 14 full gcs, expect 0 full gcs
pliden
parents: 12777
diff changeset
    56
bac04ff7a443 8023158: hotspot/test/gc/7168848/HumongousAlloc.java fails 14 full gcs, expect 0 full gcs
pliden
parents: 12777
diff changeset
    57
        public static void main(String [] args) throws Exception {
bac04ff7a443 8023158: hotspot/test/gc/7168848/HumongousAlloc.java fails 14 full gcs, expect 0 full gcs
pliden
parents: 12777
diff changeset
    58
            // Make object size 75% of region size
bac04ff7a443 8023158: hotspot/test/gc/7168848/HumongousAlloc.java fails 14 full gcs, expect 0 full gcs
pliden
parents: 12777
diff changeset
    59
            final int humongousObjectSize =
bac04ff7a443 8023158: hotspot/test/gc/7168848/HumongousAlloc.java fails 14 full gcs, expect 0 full gcs
pliden
parents: 12777
diff changeset
    60
                (int)(heapRegionSize * 1024 * 1024 * 0.75);
bac04ff7a443 8023158: hotspot/test/gc/7168848/HumongousAlloc.java fails 14 full gcs, expect 0 full gcs
pliden
parents: 12777
diff changeset
    61
bac04ff7a443 8023158: hotspot/test/gc/7168848/HumongousAlloc.java fails 14 full gcs, expect 0 full gcs
pliden
parents: 12777
diff changeset
    62
            // Number of objects to allocate to go above IHOP
bac04ff7a443 8023158: hotspot/test/gc/7168848/HumongousAlloc.java fails 14 full gcs, expect 0 full gcs
pliden
parents: 12777
diff changeset
    63
            final int humongousObjectAllocations =
bac04ff7a443 8023158: hotspot/test/gc/7168848/HumongousAlloc.java fails 14 full gcs, expect 0 full gcs
pliden
parents: 12777
diff changeset
    64
                (int)((heapSize * initiatingHeapOccupancyPercent / 100.0) / heapRegionSize) + 1;
bac04ff7a443 8023158: hotspot/test/gc/7168848/HumongousAlloc.java fails 14 full gcs, expect 0 full gcs
pliden
parents: 12777
diff changeset
    65
bac04ff7a443 8023158: hotspot/test/gc/7168848/HumongousAlloc.java fails 14 full gcs, expect 0 full gcs
pliden
parents: 12777
diff changeset
    66
            // Allocate
bac04ff7a443 8023158: hotspot/test/gc/7168848/HumongousAlloc.java fails 14 full gcs, expect 0 full gcs
pliden
parents: 12777
diff changeset
    67
            for (int i = 1; i <= humongousObjectAllocations; i++) {
bac04ff7a443 8023158: hotspot/test/gc/7168848/HumongousAlloc.java fails 14 full gcs, expect 0 full gcs
pliden
parents: 12777
diff changeset
    68
                System.out.println("Allocating humongous object " + i + "/" + humongousObjectAllocations +
bac04ff7a443 8023158: hotspot/test/gc/7168848/HumongousAlloc.java fails 14 full gcs, expect 0 full gcs
pliden
parents: 12777
diff changeset
    69
                                   " of size " + humongousObjectSize + " bytes");
bac04ff7a443 8023158: hotspot/test/gc/7168848/HumongousAlloc.java fails 14 full gcs, expect 0 full gcs
pliden
parents: 12777
diff changeset
    70
                dummy = new byte[humongousObjectSize];
12777
57370da2f61d 7168848: Add test to check that humongous object allocation path also checks the heap occupancy.
mnunez
parents:
diff changeset
    71
            }
57370da2f61d 7168848: Add test to check that humongous object allocation path also checks the heap occupancy.
mnunez
parents:
diff changeset
    72
        }
57370da2f61d 7168848: Add test to check that humongous object allocation path also checks the heap occupancy.
mnunez
parents:
diff changeset
    73
    }
57370da2f61d 7168848: Add test to check that humongous object allocation path also checks the heap occupancy.
mnunez
parents:
diff changeset
    74
}
57370da2f61d 7168848: Add test to check that humongous object allocation path also checks the heap occupancy.
mnunez
parents:
diff changeset
    75