8023158: hotspot/test/gc/7168848/HumongousAlloc.java fails 14 full gcs, expect 0 full gcs

Tue, 15 Oct 2013 11:38:47 +0200

author
pliden
date
Tue, 15 Oct 2013 11:38:47 +0200
changeset 5937
6f1919cfd18c
parent 5934
d6818f623792
child 5938
bfd52054aeb8

8023158: hotspot/test/gc/7168848/HumongousAlloc.java fails 14 full gcs, expect 0 full gcs
Reviewed-by: brutisso, tschatzl

test/TEST.groups file | annotate | diff | comparison | revisions
test/gc/7168848/HumongousAlloc.java file | annotate | diff | comparison | revisions
test/gc/g1/TestHumongousAllocInitialMark.java file | annotate | diff | comparison | revisions
     1.1 --- a/test/TEST.groups	Tue Oct 15 11:18:42 2013 +0200
     1.2 +++ b/test/TEST.groups	Tue Oct 15 11:38:47 2013 +0200
     1.3 @@ -124,7 +124,7 @@
     1.4    compiler/whitebox/IsMethodCompilableTest.java \
     1.5    gc/6581734/Test6581734.java \
     1.6    gc/7072527/TestFullGCCount.java \
     1.7 -  gc/7168848/HumongousAlloc.java \
     1.8 +  gc/g1/TestHumongousAllocInitialMark.java \
     1.9    gc/arguments/TestG1HeapRegionSize.java \
    1.10    gc/metaspace/TestMetaspaceMemoryPool.java \
    1.11    runtime/InternalApi/ThreadCpuTimesDeadlock.java \
     2.1 --- a/test/gc/7168848/HumongousAlloc.java	Tue Oct 15 11:18:42 2013 +0200
     2.2 +++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
     2.3 @@ -1,74 +0,0 @@
     2.4 -/*
     2.5 - * Copyright (c) 2012, Oracle and/or its affiliates. All rights reserved.
     2.6 - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
     2.7 - *
     2.8 - * This code is free software; you can redistribute it and/or modify it
     2.9 - * under the terms of the GNU General Public License version 2 only, as
    2.10 - * published by the Free Software Foundation.
    2.11 - *
    2.12 - * This code is distributed in the hope that it will be useful, but WITHOUT
    2.13 - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
    2.14 - * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
    2.15 - * version 2 for more details (a copy is included in the LICENSE file that
    2.16 - * accompanied this code).
    2.17 - *
    2.18 - * You should have received a copy of the GNU General Public License version
    2.19 - * 2 along with this work; if not, write to the Free Software Foundation,
    2.20 - * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
    2.21 - *
    2.22 - * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
    2.23 - * or visit www.oracle.com if you need additional information or have any
    2.24 - * questions.
    2.25 - */
    2.26 -
    2.27 -/*
    2.28 - * @test Humongous.java
    2.29 - * @bug 7168848
    2.30 - * @summary G1: humongous object allocations should initiate marking cycles when necessary
    2.31 - * @run main/othervm -Xms100m -Xmx100m -XX:+PrintGC -XX:G1HeapRegionSize=1m -XX:+UseG1GC  HumongousAlloc
    2.32 - *
    2.33 - */
    2.34 -import java.lang.management.GarbageCollectorMXBean;
    2.35 -import java.lang.management.ManagementFactory;
    2.36 -import java.util.List;
    2.37 -
    2.38 -public class HumongousAlloc {
    2.39 -
    2.40 -    public static byte[] dummy;
    2.41 -    private static int sleepFreq = 40;
    2.42 -    private static int sleepTime = 1000;
    2.43 -    private static double size = 0.75;
    2.44 -    private static int iterations = 50;
    2.45 -    private static int MB = 1024 * 1024;
    2.46 -
    2.47 -    public static void allocate(int size, int sleepTime, int sleepFreq) throws InterruptedException {
    2.48 -        System.out.println("Will allocate objects of size: " + size
    2.49 -                + " bytes and sleep for " + sleepTime
    2.50 -                + " ms after every " + sleepFreq + "th allocation.");
    2.51 -        int count = 0;
    2.52 -        while (count < iterations) {
    2.53 -            for (int i = 0; i < sleepFreq; i++) {
    2.54 -                dummy = new byte[size - 16];
    2.55 -            }
    2.56 -            Thread.sleep(sleepTime);
    2.57 -            count++;
    2.58 -        }
    2.59 -    }
    2.60 -
    2.61 -    public static void main(String[] args) throws InterruptedException {
    2.62 -        allocate((int) (size * MB), sleepTime, sleepFreq);
    2.63 -        List<GarbageCollectorMXBean> collectors = ManagementFactory.getGarbageCollectorMXBeans();
    2.64 -        for (GarbageCollectorMXBean collector : collectors) {
    2.65 -            if (collector.getName().contains("G1 Old")) {
    2.66 -               long count = collector.getCollectionCount();
    2.67 -                if (count > 0) {
    2.68 -                    throw new RuntimeException("Failed: FullGCs should not have happened. The number of FullGC run is " + count);
    2.69 -                }
    2.70 -                else {
    2.71 -                    System.out.println("Passed.");
    2.72 -                }
    2.73 -            }
    2.74 -        }
    2.75 -    }
    2.76 -}
    2.77 -
     3.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     3.2 +++ b/test/gc/g1/TestHumongousAllocInitialMark.java	Tue Oct 15 11:38:47 2013 +0200
     3.3 @@ -0,0 +1,75 @@
     3.4 +/*
     3.5 + * Copyright (c) 2012, Oracle and/or its affiliates. All rights reserved.
     3.6 + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
     3.7 + *
     3.8 + * This code is free software; you can redistribute it and/or modify it
     3.9 + * under the terms of the GNU General Public License version 2 only, as
    3.10 + * published by the Free Software Foundation.
    3.11 + *
    3.12 + * This code is distributed in the hope that it will be useful, but WITHOUT
    3.13 + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
    3.14 + * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
    3.15 + * version 2 for more details (a copy is included in the LICENSE file that
    3.16 + * accompanied this code).
    3.17 + *
    3.18 + * You should have received a copy of the GNU General Public License version
    3.19 + * 2 along with this work; if not, write to the Free Software Foundation,
    3.20 + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
    3.21 + *
    3.22 + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
    3.23 + * or visit www.oracle.com if you need additional information or have any
    3.24 + * questions.
    3.25 + */
    3.26 +
    3.27 +/*
    3.28 + * @test TestHumongousAllocInitialMark
    3.29 + * @bug 7168848
    3.30 + * @summary G1: humongous object allocations should initiate marking cycles when necessary
    3.31 + * @library /testlibrary
    3.32 + */
    3.33 +
    3.34 +import com.oracle.java.testlibrary.*;
    3.35 +
    3.36 +public class TestHumongousAllocInitialMark {
    3.37 +    private static final int heapSize                       = 200; // MB
    3.38 +    private static final int heapRegionSize                 = 1;   // MB
    3.39 +    private static final int initiatingHeapOccupancyPercent = 50;  // %
    3.40 +
    3.41 +    public static void main(String[] args) throws Exception {
    3.42 +        ProcessBuilder pb = ProcessTools.createJavaProcessBuilder(
    3.43 +            "-XX:+UseG1GC",
    3.44 +            "-Xms" + heapSize + "m",
    3.45 +            "-Xmx" + heapSize + "m",
    3.46 +            "-XX:G1HeapRegionSize=" + heapRegionSize + "m",
    3.47 +            "-XX:InitiatingHeapOccupancyPercent=" + initiatingHeapOccupancyPercent,
    3.48 +            "-XX:+PrintGC",
    3.49 +            HumongousObjectAllocator.class.getName());
    3.50 +
    3.51 +        OutputAnalyzer output = new OutputAnalyzer(pb.start());
    3.52 +        output.shouldContain("GC pause (G1 Humongous Allocation) (young) (initial-mark)");
    3.53 +        output.shouldNotContain("Full GC");
    3.54 +        output.shouldHaveExitValue(0);
    3.55 +    }
    3.56 +
    3.57 +    static class HumongousObjectAllocator {
    3.58 +        private static byte[] dummy;
    3.59 +
    3.60 +        public static void main(String [] args) throws Exception {
    3.61 +            // Make object size 75% of region size
    3.62 +            final int humongousObjectSize =
    3.63 +                (int)(heapRegionSize * 1024 * 1024 * 0.75);
    3.64 +
    3.65 +            // Number of objects to allocate to go above IHOP
    3.66 +            final int humongousObjectAllocations =
    3.67 +                (int)((heapSize * initiatingHeapOccupancyPercent / 100.0) / heapRegionSize) + 1;
    3.68 +
    3.69 +            // Allocate
    3.70 +            for (int i = 1; i <= humongousObjectAllocations; i++) {
    3.71 +                System.out.println("Allocating humongous object " + i + "/" + humongousObjectAllocations +
    3.72 +                                   " of size " + humongousObjectSize + " bytes");
    3.73 +                dummy = new byte[humongousObjectSize];
    3.74 +            }
    3.75 +        }
    3.76 +    }
    3.77 +}
    3.78 +

mercurial