author | brutisso |
Thu, 10 Dec 2015 14:57:55 +0100 | |
changeset 35061 | be6025ebffea |
parent 30604 | b8d532cb6420 |
child 36851 | 03e2f4d0a421 |
permissions | -rw-r--r-- |
12777
57370da2f61d
7168848: Add test to check that humongous object allocation path also checks the heap occupancy.
mnunez
parents:
diff
changeset
|
1 |
/* |
29678
dd2f3932c21e
8075586: Add @modules as needed to the open hotspot tests
ykantser
parents:
28497
diff
changeset
|
2 |
* Copyright (c) 2012, 2015, 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 |
29678
dd2f3932c21e
8075586: Add @modules as needed to the open hotspot tests
ykantser
parents:
28497
diff
changeset
|
29 |
* @modules java.base/sun.misc |
dd2f3932c21e
8075586: Add @modules as needed to the open hotspot tests
ykantser
parents:
28497
diff
changeset
|
30 |
* java.management |
12777
57370da2f61d
7168848: Add test to check that humongous object allocation path also checks the heap occupancy.
mnunez
parents:
diff
changeset
|
31 |
*/ |
20725
bac04ff7a443
8023158: hotspot/test/gc/7168848/HumongousAlloc.java fails 14 full gcs, expect 0 full gcs
pliden
parents:
12777
diff
changeset
|
32 |
|
30604
b8d532cb6420
8067013: Rename the com.oracle.java.testlibary package
ykantser
parents:
29678
diff
changeset
|
33 |
import jdk.test.lib.*; |
12777
57370da2f61d
7168848: Add test to check that humongous object allocation path also checks the heap occupancy.
mnunez
parents:
diff
changeset
|
34 |
|
20725
bac04ff7a443
8023158: hotspot/test/gc/7168848/HumongousAlloc.java fails 14 full gcs, expect 0 full gcs
pliden
parents:
12777
diff
changeset
|
35 |
public class TestHumongousAllocInitialMark { |
28497
a7aecf0ffb6b
8067941: [TESTBUG] Fix tests for OS with 64K page size.
goetz
parents:
22234
diff
changeset
|
36 |
// 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
|
37 |
// fulfill alignment constraints. |
a7aecf0ffb6b
8067941: [TESTBUG] Fix tests for OS with 64K page size.
goetz
parents:
22234
diff
changeset
|
38 |
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
|
39 |
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
|
40 |
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
|
41 |
|
20725
bac04ff7a443
8023158: hotspot/test/gc/7168848/HumongousAlloc.java fails 14 full gcs, expect 0 full gcs
pliden
parents:
12777
diff
changeset
|
42 |
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
|
43 |
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
|
44 |
"-XX:+UseG1GC", |
bac04ff7a443
8023158: hotspot/test/gc/7168848/HumongousAlloc.java fails 14 full gcs, expect 0 full gcs
pliden
parents:
12777
diff
changeset
|
45 |
"-Xms" + heapSize + "m", |
bac04ff7a443
8023158: hotspot/test/gc/7168848/HumongousAlloc.java fails 14 full gcs, expect 0 full gcs
pliden
parents:
12777
diff
changeset
|
46 |
"-Xmx" + heapSize + "m", |
bac04ff7a443
8023158: hotspot/test/gc/7168848/HumongousAlloc.java fails 14 full gcs, expect 0 full gcs
pliden
parents:
12777
diff
changeset
|
47 |
"-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
|
48 |
"-XX:InitiatingHeapOccupancyPercent=" + initiatingHeapOccupancyPercent, |
35061 | 49 |
"-Xlog:gc", |
20725
bac04ff7a443
8023158: hotspot/test/gc/7168848/HumongousAlloc.java fails 14 full gcs, expect 0 full gcs
pliden
parents:
12777
diff
changeset
|
50 |
HumongousObjectAllocator.class.getName()); |
12777
57370da2f61d
7168848: Add test to check that humongous object allocation path also checks the heap occupancy.
mnunez
parents:
diff
changeset
|
51 |
|
20725
bac04ff7a443
8023158: hotspot/test/gc/7168848/HumongousAlloc.java fails 14 full gcs, expect 0 full gcs
pliden
parents:
12777
diff
changeset
|
52 |
OutputAnalyzer output = new OutputAnalyzer(pb.start()); |
35061 | 53 |
output.shouldContain("Pause Initial Mark (G1 Humongous Allocation)"); |
20725
bac04ff7a443
8023158: hotspot/test/gc/7168848/HumongousAlloc.java fails 14 full gcs, expect 0 full gcs
pliden
parents:
12777
diff
changeset
|
54 |
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
|
55 |
output.shouldHaveExitValue(0); |
12777
57370da2f61d
7168848: Add test to check that humongous object allocation path also checks the heap occupancy.
mnunez
parents:
diff
changeset
|
56 |
} |
57370da2f61d
7168848: Add test to check that humongous object allocation path also checks the heap occupancy.
mnunez
parents:
diff
changeset
|
57 |
|
20725
bac04ff7a443
8023158: hotspot/test/gc/7168848/HumongousAlloc.java fails 14 full gcs, expect 0 full gcs
pliden
parents:
12777
diff
changeset
|
58 |
static class HumongousObjectAllocator { |
bac04ff7a443
8023158: hotspot/test/gc/7168848/HumongousAlloc.java fails 14 full gcs, expect 0 full gcs
pliden
parents:
12777
diff
changeset
|
59 |
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
|
60 |
|
bac04ff7a443
8023158: hotspot/test/gc/7168848/HumongousAlloc.java fails 14 full gcs, expect 0 full gcs
pliden
parents:
12777
diff
changeset
|
61 |
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
|
62 |
// 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
|
63 |
final int humongousObjectSize = |
bac04ff7a443
8023158: hotspot/test/gc/7168848/HumongousAlloc.java fails 14 full gcs, expect 0 full gcs
pliden
parents:
12777
diff
changeset
|
64 |
(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
|
65 |
|
bac04ff7a443
8023158: hotspot/test/gc/7168848/HumongousAlloc.java fails 14 full gcs, expect 0 full gcs
pliden
parents:
12777
diff
changeset
|
66 |
// 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
|
67 |
final int humongousObjectAllocations = |
bac04ff7a443
8023158: hotspot/test/gc/7168848/HumongousAlloc.java fails 14 full gcs, expect 0 full gcs
pliden
parents:
12777
diff
changeset
|
68 |
(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
|
69 |
|
bac04ff7a443
8023158: hotspot/test/gc/7168848/HumongousAlloc.java fails 14 full gcs, expect 0 full gcs
pliden
parents:
12777
diff
changeset
|
70 |
// Allocate |
bac04ff7a443
8023158: hotspot/test/gc/7168848/HumongousAlloc.java fails 14 full gcs, expect 0 full gcs
pliden
parents:
12777
diff
changeset
|
71 |
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
|
72 |
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
|
73 |
" 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
|
74 |
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
|
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 |
} |
57370da2f61d
7168848: Add test to check that humongous object allocation path also checks the heap occupancy.
mnunez
parents:
diff
changeset
|
78 |
} |
57370da2f61d
7168848: Add test to check that humongous object allocation path also checks the heap occupancy.
mnunez
parents:
diff
changeset
|
79 |