hotspot/test/gc/g1/TestHumongousAllocInitialMark.java
author goetz
Mon, 12 Jan 2015 14:43:34 -0800
changeset 28497 a7aecf0ffb6b
parent 22234 da823d78ad65
child 29678 dd2f3932c21e
permissions -rw-r--r--
8067941: [TESTBUG] Fix tests for OS with 64K page size. Reviewed-by: kvn, tschatzl, ctornqvi
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 {
28497
a7aecf0ffb6b 8067941: [TESTBUG] Fix tests for OS with 64K page size.
goetz
parents: 22234
diff changeset
    34
    // Heap sizes < 224 MB are increased to 224 MB if vm_page_size == 64K to
a7aecf0ffb6b 8067941: [TESTBUG] Fix tests for OS with 64K page size.
goetz
parents: 22234
diff changeset
    35
    // fulfill alignment constraints.
a7aecf0ffb6b 8067941: [TESTBUG] Fix tests for OS with 64K page size.
goetz
parents: 22234
diff changeset
    36
    private static final int heapSize                       = 224; // MB
20725
bac04ff7a443 8023158: hotspot/test/gc/7168848/HumongousAlloc.java fails 14 full gcs, expect 0 full gcs
pliden
parents: 12777
diff changeset
    37
    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
    38
    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
    39
20725
bac04ff7a443 8023158: hotspot/test/gc/7168848/HumongousAlloc.java fails 14 full gcs, expect 0 full gcs
pliden
parents: 12777
diff changeset
    40
    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
    41
        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
    42
            "-XX:+UseG1GC",
bac04ff7a443 8023158: hotspot/test/gc/7168848/HumongousAlloc.java fails 14 full gcs, expect 0 full gcs
pliden
parents: 12777
diff changeset
    43
            "-Xms" + heapSize + "m",
bac04ff7a443 8023158: hotspot/test/gc/7168848/HumongousAlloc.java fails 14 full gcs, expect 0 full gcs
pliden
parents: 12777
diff changeset
    44
            "-Xmx" + heapSize + "m",
bac04ff7a443 8023158: hotspot/test/gc/7168848/HumongousAlloc.java fails 14 full gcs, expect 0 full gcs
pliden
parents: 12777
diff changeset
    45
            "-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
    46
            "-XX:InitiatingHeapOccupancyPercent=" + initiatingHeapOccupancyPercent,
bac04ff7a443 8023158: hotspot/test/gc/7168848/HumongousAlloc.java fails 14 full gcs, expect 0 full gcs
pliden
parents: 12777
diff changeset
    47
            "-XX:+PrintGC",
bac04ff7a443 8023158: hotspot/test/gc/7168848/HumongousAlloc.java fails 14 full gcs, expect 0 full gcs
pliden
parents: 12777
diff changeset
    48
            HumongousObjectAllocator.class.getName());
12777
57370da2f61d 7168848: Add test to check that humongous object allocation path also checks the heap occupancy.
mnunez
parents:
diff changeset
    49
20725
bac04ff7a443 8023158: hotspot/test/gc/7168848/HumongousAlloc.java fails 14 full gcs, expect 0 full gcs
pliden
parents: 12777
diff changeset
    50
        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
    51
        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
    52
        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
    53
        output.shouldHaveExitValue(0);
12777
57370da2f61d 7168848: Add test to check that humongous object allocation path also checks the heap occupancy.
mnunez
parents:
diff changeset
    54
    }
57370da2f61d 7168848: Add test to check that humongous object allocation path also checks the heap occupancy.
mnunez
parents:
diff changeset
    55
20725
bac04ff7a443 8023158: hotspot/test/gc/7168848/HumongousAlloc.java fails 14 full gcs, expect 0 full gcs
pliden
parents: 12777
diff changeset
    56
    static class HumongousObjectAllocator {
bac04ff7a443 8023158: hotspot/test/gc/7168848/HumongousAlloc.java fails 14 full gcs, expect 0 full gcs
pliden
parents: 12777
diff changeset
    57
        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
    58
bac04ff7a443 8023158: hotspot/test/gc/7168848/HumongousAlloc.java fails 14 full gcs, expect 0 full gcs
pliden
parents: 12777
diff changeset
    59
        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
    60
            // 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
    61
            final int humongousObjectSize =
bac04ff7a443 8023158: hotspot/test/gc/7168848/HumongousAlloc.java fails 14 full gcs, expect 0 full gcs
pliden
parents: 12777
diff changeset
    62
                (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
    63
bac04ff7a443 8023158: hotspot/test/gc/7168848/HumongousAlloc.java fails 14 full gcs, expect 0 full gcs
pliden
parents: 12777
diff changeset
    64
            // 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
    65
            final int humongousObjectAllocations =
bac04ff7a443 8023158: hotspot/test/gc/7168848/HumongousAlloc.java fails 14 full gcs, expect 0 full gcs
pliden
parents: 12777
diff changeset
    66
                (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
    67
bac04ff7a443 8023158: hotspot/test/gc/7168848/HumongousAlloc.java fails 14 full gcs, expect 0 full gcs
pliden
parents: 12777
diff changeset
    68
            // Allocate
bac04ff7a443 8023158: hotspot/test/gc/7168848/HumongousAlloc.java fails 14 full gcs, expect 0 full gcs
pliden
parents: 12777
diff changeset
    69
            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
    70
                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
    71
                                   " 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
    72
                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
    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
    }
57370da2f61d 7168848: Add test to check that humongous object allocation path also checks the heap occupancy.
mnunez
parents:
diff changeset
    76
}
57370da2f61d 7168848: Add test to check that humongous object allocation path also checks the heap occupancy.
mnunez
parents:
diff changeset
    77