annotate test/gc/g1/TestEagerReclaimHumongousRegions2.java @ 20333:2d1534aa7131

8054362: gc/g1/TestEagerReclaimHumongousRegions2.java timeout Summary: Give the test a time limit of approximately one minute so that it exits early on slow machines. Reviewed-by: ehelin, dfazunen, brutisso
author tschatzl
date Mon, 18 Aug 2014 15:41:57 +0200
parents 83ea089a5c64
children
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
20298
83ea089a5c64 8051973: Eager reclaim leaves marks of marked but reclaimed objects on the next bitmap
tschatzl
parents:
diff changeset
1 /*
83ea089a5c64 8051973: Eager reclaim leaves marks of marked but reclaimed objects on the next bitmap
tschatzl
parents:
diff changeset
2 * Copyright (c) 2014, Oracle and/or its affiliates. All rights reserved.
83ea089a5c64 8051973: Eager reclaim leaves marks of marked but reclaimed objects on the next bitmap
tschatzl
parents:
diff changeset
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
83ea089a5c64 8051973: Eager reclaim leaves marks of marked but reclaimed objects on the next bitmap
tschatzl
parents:
diff changeset
4 *
83ea089a5c64 8051973: Eager reclaim leaves marks of marked but reclaimed objects on the next bitmap
tschatzl
parents:
diff changeset
5 * This code is free software; you can redistribute it and/or modify it
83ea089a5c64 8051973: Eager reclaim leaves marks of marked but reclaimed objects on the next bitmap
tschatzl
parents:
diff changeset
6 * under the terms of the GNU General Public License version 2 only, as
83ea089a5c64 8051973: Eager reclaim leaves marks of marked but reclaimed objects on the next bitmap
tschatzl
parents:
diff changeset
7 * published by the Free Software Foundation.
83ea089a5c64 8051973: Eager reclaim leaves marks of marked but reclaimed objects on the next bitmap
tschatzl
parents:
diff changeset
8 *
83ea089a5c64 8051973: Eager reclaim leaves marks of marked but reclaimed objects on the next bitmap
tschatzl
parents:
diff changeset
9 * This code is distributed in the hope that it will be useful, but WITHOUT
83ea089a5c64 8051973: Eager reclaim leaves marks of marked but reclaimed objects on the next bitmap
tschatzl
parents:
diff changeset
10 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
83ea089a5c64 8051973: Eager reclaim leaves marks of marked but reclaimed objects on the next bitmap
tschatzl
parents:
diff changeset
11 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
83ea089a5c64 8051973: Eager reclaim leaves marks of marked but reclaimed objects on the next bitmap
tschatzl
parents:
diff changeset
12 * version 2 for more details (a copy is included in the LICENSE file that
83ea089a5c64 8051973: Eager reclaim leaves marks of marked but reclaimed objects on the next bitmap
tschatzl
parents:
diff changeset
13 * accompanied this code).
83ea089a5c64 8051973: Eager reclaim leaves marks of marked but reclaimed objects on the next bitmap
tschatzl
parents:
diff changeset
14 *
83ea089a5c64 8051973: Eager reclaim leaves marks of marked but reclaimed objects on the next bitmap
tschatzl
parents:
diff changeset
15 * You should have received a copy of the GNU General Public License version
83ea089a5c64 8051973: Eager reclaim leaves marks of marked but reclaimed objects on the next bitmap
tschatzl
parents:
diff changeset
16 * 2 along with this work; if not, write to the Free Software Foundation,
83ea089a5c64 8051973: Eager reclaim leaves marks of marked but reclaimed objects on the next bitmap
tschatzl
parents:
diff changeset
17 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
83ea089a5c64 8051973: Eager reclaim leaves marks of marked but reclaimed objects on the next bitmap
tschatzl
parents:
diff changeset
18 *
83ea089a5c64 8051973: Eager reclaim leaves marks of marked but reclaimed objects on the next bitmap
tschatzl
parents:
diff changeset
19 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
83ea089a5c64 8051973: Eager reclaim leaves marks of marked but reclaimed objects on the next bitmap
tschatzl
parents:
diff changeset
20 * or visit www.oracle.com if you need additional information or have any
83ea089a5c64 8051973: Eager reclaim leaves marks of marked but reclaimed objects on the next bitmap
tschatzl
parents:
diff changeset
21 * questions.
83ea089a5c64 8051973: Eager reclaim leaves marks of marked but reclaimed objects on the next bitmap
tschatzl
parents:
diff changeset
22 */
83ea089a5c64 8051973: Eager reclaim leaves marks of marked but reclaimed objects on the next bitmap
tschatzl
parents:
diff changeset
23
83ea089a5c64 8051973: Eager reclaim leaves marks of marked but reclaimed objects on the next bitmap
tschatzl
parents:
diff changeset
24 /*
83ea089a5c64 8051973: Eager reclaim leaves marks of marked but reclaimed objects on the next bitmap
tschatzl
parents:
diff changeset
25 * @test TestEagerReclaimHumongousRegions2
83ea089a5c64 8051973: Eager reclaim leaves marks of marked but reclaimed objects on the next bitmap
tschatzl
parents:
diff changeset
26 * @bug 8051973
83ea089a5c64 8051973: Eager reclaim leaves marks of marked but reclaimed objects on the next bitmap
tschatzl
parents:
diff changeset
27 * @summary Test to make sure that eager reclaim of humongous objects correctly clears
83ea089a5c64 8051973: Eager reclaim leaves marks of marked but reclaimed objects on the next bitmap
tschatzl
parents:
diff changeset
28 * mark bitmaps at reclaim.
83ea089a5c64 8051973: Eager reclaim leaves marks of marked but reclaimed objects on the next bitmap
tschatzl
parents:
diff changeset
29 * @key gc
83ea089a5c64 8051973: Eager reclaim leaves marks of marked but reclaimed objects on the next bitmap
tschatzl
parents:
diff changeset
30 * @library /testlibrary
83ea089a5c64 8051973: Eager reclaim leaves marks of marked but reclaimed objects on the next bitmap
tschatzl
parents:
diff changeset
31 */
83ea089a5c64 8051973: Eager reclaim leaves marks of marked but reclaimed objects on the next bitmap
tschatzl
parents:
diff changeset
32
83ea089a5c64 8051973: Eager reclaim leaves marks of marked but reclaimed objects on the next bitmap
tschatzl
parents:
diff changeset
33 import java.util.ArrayList;
83ea089a5c64 8051973: Eager reclaim leaves marks of marked but reclaimed objects on the next bitmap
tschatzl
parents:
diff changeset
34 import java.util.LinkedList;
83ea089a5c64 8051973: Eager reclaim leaves marks of marked but reclaimed objects on the next bitmap
tschatzl
parents:
diff changeset
35 import java.util.Random;
83ea089a5c64 8051973: Eager reclaim leaves marks of marked but reclaimed objects on the next bitmap
tschatzl
parents:
diff changeset
36
83ea089a5c64 8051973: Eager reclaim leaves marks of marked but reclaimed objects on the next bitmap
tschatzl
parents:
diff changeset
37 import com.oracle.java.testlibrary.OutputAnalyzer;
83ea089a5c64 8051973: Eager reclaim leaves marks of marked but reclaimed objects on the next bitmap
tschatzl
parents:
diff changeset
38 import com.oracle.java.testlibrary.ProcessTools;
83ea089a5c64 8051973: Eager reclaim leaves marks of marked but reclaimed objects on the next bitmap
tschatzl
parents:
diff changeset
39
83ea089a5c64 8051973: Eager reclaim leaves marks of marked but reclaimed objects on the next bitmap
tschatzl
parents:
diff changeset
40 // An object that has a few references to other instances to slow down marking.
83ea089a5c64 8051973: Eager reclaim leaves marks of marked but reclaimed objects on the next bitmap
tschatzl
parents:
diff changeset
41 class ObjectWithSomeRefs {
83ea089a5c64 8051973: Eager reclaim leaves marks of marked but reclaimed objects on the next bitmap
tschatzl
parents:
diff changeset
42 public ObjectWithSomeRefs other1;
83ea089a5c64 8051973: Eager reclaim leaves marks of marked but reclaimed objects on the next bitmap
tschatzl
parents:
diff changeset
43 public ObjectWithSomeRefs other2;
83ea089a5c64 8051973: Eager reclaim leaves marks of marked but reclaimed objects on the next bitmap
tschatzl
parents:
diff changeset
44 public ObjectWithSomeRefs other3;
83ea089a5c64 8051973: Eager reclaim leaves marks of marked but reclaimed objects on the next bitmap
tschatzl
parents:
diff changeset
45 public ObjectWithSomeRefs other4;
83ea089a5c64 8051973: Eager reclaim leaves marks of marked but reclaimed objects on the next bitmap
tschatzl
parents:
diff changeset
46 }
83ea089a5c64 8051973: Eager reclaim leaves marks of marked but reclaimed objects on the next bitmap
tschatzl
parents:
diff changeset
47
83ea089a5c64 8051973: Eager reclaim leaves marks of marked but reclaimed objects on the next bitmap
tschatzl
parents:
diff changeset
48 class ReclaimRegionFast {
20333
2d1534aa7131 8054362: gc/g1/TestEagerReclaimHumongousRegions2.java timeout
tschatzl
parents: 20298
diff changeset
49 public static final long MAX_MILLIS_FOR_RUN = 50 * 1000; // The maximum runtime for the actual test.
2d1534aa7131 8054362: gc/g1/TestEagerReclaimHumongousRegions2.java timeout
tschatzl
parents: 20298
diff changeset
50
20298
83ea089a5c64 8051973: Eager reclaim leaves marks of marked but reclaimed objects on the next bitmap
tschatzl
parents:
diff changeset
51 public static final int M = 1024*1024;
83ea089a5c64 8051973: Eager reclaim leaves marks of marked but reclaimed objects on the next bitmap
tschatzl
parents:
diff changeset
52
83ea089a5c64 8051973: Eager reclaim leaves marks of marked but reclaimed objects on the next bitmap
tschatzl
parents:
diff changeset
53 public static LinkedList<Object> garbageList = new LinkedList<Object>();
83ea089a5c64 8051973: Eager reclaim leaves marks of marked but reclaimed objects on the next bitmap
tschatzl
parents:
diff changeset
54
83ea089a5c64 8051973: Eager reclaim leaves marks of marked but reclaimed objects on the next bitmap
tschatzl
parents:
diff changeset
55 public static void genGarbage(Object large) {
83ea089a5c64 8051973: Eager reclaim leaves marks of marked but reclaimed objects on the next bitmap
tschatzl
parents:
diff changeset
56 for (int i = 0; i < 64*1024; i++) {
83ea089a5c64 8051973: Eager reclaim leaves marks of marked but reclaimed objects on the next bitmap
tschatzl
parents:
diff changeset
57 Object[] garbage = new Object[50];
83ea089a5c64 8051973: Eager reclaim leaves marks of marked but reclaimed objects on the next bitmap
tschatzl
parents:
diff changeset
58 garbage[0] = large;
83ea089a5c64 8051973: Eager reclaim leaves marks of marked but reclaimed objects on the next bitmap
tschatzl
parents:
diff changeset
59 garbageList.add(garbage);
83ea089a5c64 8051973: Eager reclaim leaves marks of marked but reclaimed objects on the next bitmap
tschatzl
parents:
diff changeset
60 }
83ea089a5c64 8051973: Eager reclaim leaves marks of marked but reclaimed objects on the next bitmap
tschatzl
parents:
diff changeset
61 garbageList.clear();
83ea089a5c64 8051973: Eager reclaim leaves marks of marked but reclaimed objects on the next bitmap
tschatzl
parents:
diff changeset
62 }
83ea089a5c64 8051973: Eager reclaim leaves marks of marked but reclaimed objects on the next bitmap
tschatzl
parents:
diff changeset
63
83ea089a5c64 8051973: Eager reclaim leaves marks of marked but reclaimed objects on the next bitmap
tschatzl
parents:
diff changeset
64 public static ArrayList<ObjectWithSomeRefs> longList = new ArrayList<ObjectWithSomeRefs>();
83ea089a5c64 8051973: Eager reclaim leaves marks of marked but reclaimed objects on the next bitmap
tschatzl
parents:
diff changeset
65
83ea089a5c64 8051973: Eager reclaim leaves marks of marked but reclaimed objects on the next bitmap
tschatzl
parents:
diff changeset
66 public static void main(String[] args) {
83ea089a5c64 8051973: Eager reclaim leaves marks of marked but reclaimed objects on the next bitmap
tschatzl
parents:
diff changeset
67
83ea089a5c64 8051973: Eager reclaim leaves marks of marked but reclaimed objects on the next bitmap
tschatzl
parents:
diff changeset
68 for (int i = 0; i < 16*1024; i++) {
83ea089a5c64 8051973: Eager reclaim leaves marks of marked but reclaimed objects on the next bitmap
tschatzl
parents:
diff changeset
69 longList.add(new ObjectWithSomeRefs());
83ea089a5c64 8051973: Eager reclaim leaves marks of marked but reclaimed objects on the next bitmap
tschatzl
parents:
diff changeset
70 }
83ea089a5c64 8051973: Eager reclaim leaves marks of marked but reclaimed objects on the next bitmap
tschatzl
parents:
diff changeset
71
83ea089a5c64 8051973: Eager reclaim leaves marks of marked but reclaimed objects on the next bitmap
tschatzl
parents:
diff changeset
72 Random rnd = new Random();
83ea089a5c64 8051973: Eager reclaim leaves marks of marked but reclaimed objects on the next bitmap
tschatzl
parents:
diff changeset
73 for (int i = 0; i < longList.size(); i++) {
83ea089a5c64 8051973: Eager reclaim leaves marks of marked but reclaimed objects on the next bitmap
tschatzl
parents:
diff changeset
74 int len = longList.size();
83ea089a5c64 8051973: Eager reclaim leaves marks of marked but reclaimed objects on the next bitmap
tschatzl
parents:
diff changeset
75 longList.get(i).other1 = longList.get(rnd.nextInt(len));
83ea089a5c64 8051973: Eager reclaim leaves marks of marked but reclaimed objects on the next bitmap
tschatzl
parents:
diff changeset
76 longList.get(i).other2 = longList.get(rnd.nextInt(len));
83ea089a5c64 8051973: Eager reclaim leaves marks of marked but reclaimed objects on the next bitmap
tschatzl
parents:
diff changeset
77 longList.get(i).other3 = longList.get(rnd.nextInt(len));
83ea089a5c64 8051973: Eager reclaim leaves marks of marked but reclaimed objects on the next bitmap
tschatzl
parents:
diff changeset
78 longList.get(i).other4 = longList.get(rnd.nextInt(len));
83ea089a5c64 8051973: Eager reclaim leaves marks of marked but reclaimed objects on the next bitmap
tschatzl
parents:
diff changeset
79 }
83ea089a5c64 8051973: Eager reclaim leaves marks of marked but reclaimed objects on the next bitmap
tschatzl
parents:
diff changeset
80
83ea089a5c64 8051973: Eager reclaim leaves marks of marked but reclaimed objects on the next bitmap
tschatzl
parents:
diff changeset
81 int[] large1 = new int[M];
83ea089a5c64 8051973: Eager reclaim leaves marks of marked but reclaimed objects on the next bitmap
tschatzl
parents:
diff changeset
82 int[] large2 = null;
83ea089a5c64 8051973: Eager reclaim leaves marks of marked but reclaimed objects on the next bitmap
tschatzl
parents:
diff changeset
83 int[] large3 = null;
83ea089a5c64 8051973: Eager reclaim leaves marks of marked but reclaimed objects on the next bitmap
tschatzl
parents:
diff changeset
84 int[] large4 = null;
83ea089a5c64 8051973: Eager reclaim leaves marks of marked but reclaimed objects on the next bitmap
tschatzl
parents:
diff changeset
85
83ea089a5c64 8051973: Eager reclaim leaves marks of marked but reclaimed objects on the next bitmap
tschatzl
parents:
diff changeset
86 Object ref_from_stack = large1;
83ea089a5c64 8051973: Eager reclaim leaves marks of marked but reclaimed objects on the next bitmap
tschatzl
parents:
diff changeset
87
20333
2d1534aa7131 8054362: gc/g1/TestEagerReclaimHumongousRegions2.java timeout
tschatzl
parents: 20298
diff changeset
88 long start_millis = System.currentTimeMillis();
2d1534aa7131 8054362: gc/g1/TestEagerReclaimHumongousRegions2.java timeout
tschatzl
parents: 20298
diff changeset
89
20298
83ea089a5c64 8051973: Eager reclaim leaves marks of marked but reclaimed objects on the next bitmap
tschatzl
parents:
diff changeset
90 for (int i = 0; i < 20; i++) {
20333
2d1534aa7131 8054362: gc/g1/TestEagerReclaimHumongousRegions2.java timeout
tschatzl
parents: 20298
diff changeset
91 long current_millis = System.currentTimeMillis();
2d1534aa7131 8054362: gc/g1/TestEagerReclaimHumongousRegions2.java timeout
tschatzl
parents: 20298
diff changeset
92 if ((current_millis - start_millis) > MAX_MILLIS_FOR_RUN) {
2d1534aa7131 8054362: gc/g1/TestEagerReclaimHumongousRegions2.java timeout
tschatzl
parents: 20298
diff changeset
93 System.out.println("Finishing test because maximum runtime exceeded");
2d1534aa7131 8054362: gc/g1/TestEagerReclaimHumongousRegions2.java timeout
tschatzl
parents: 20298
diff changeset
94 break;
2d1534aa7131 8054362: gc/g1/TestEagerReclaimHumongousRegions2.java timeout
tschatzl
parents: 20298
diff changeset
95 }
20298
83ea089a5c64 8051973: Eager reclaim leaves marks of marked but reclaimed objects on the next bitmap
tschatzl
parents:
diff changeset
96 // A set of large objects that will be reclaimed eagerly - and hopefully marked.
83ea089a5c64 8051973: Eager reclaim leaves marks of marked but reclaimed objects on the next bitmap
tschatzl
parents:
diff changeset
97 large1 = new int[M - 20];
83ea089a5c64 8051973: Eager reclaim leaves marks of marked but reclaimed objects on the next bitmap
tschatzl
parents:
diff changeset
98 large2 = new int[M - 20];
83ea089a5c64 8051973: Eager reclaim leaves marks of marked but reclaimed objects on the next bitmap
tschatzl
parents:
diff changeset
99 large3 = new int[M - 20];
83ea089a5c64 8051973: Eager reclaim leaves marks of marked but reclaimed objects on the next bitmap
tschatzl
parents:
diff changeset
100 large4 = new int[M - 20];
83ea089a5c64 8051973: Eager reclaim leaves marks of marked but reclaimed objects on the next bitmap
tschatzl
parents:
diff changeset
101 genGarbage(large1);
83ea089a5c64 8051973: Eager reclaim leaves marks of marked but reclaimed objects on the next bitmap
tschatzl
parents:
diff changeset
102 // Make sure that the compiler cannot completely remove
83ea089a5c64 8051973: Eager reclaim leaves marks of marked but reclaimed objects on the next bitmap
tschatzl
parents:
diff changeset
103 // the allocation of the large object until here.
83ea089a5c64 8051973: Eager reclaim leaves marks of marked but reclaimed objects on the next bitmap
tschatzl
parents:
diff changeset
104 System.out.println(large1 + " " + large2 + " " + large3 + " " + large4);
83ea089a5c64 8051973: Eager reclaim leaves marks of marked but reclaimed objects on the next bitmap
tschatzl
parents:
diff changeset
105 }
83ea089a5c64 8051973: Eager reclaim leaves marks of marked but reclaimed objects on the next bitmap
tschatzl
parents:
diff changeset
106
83ea089a5c64 8051973: Eager reclaim leaves marks of marked but reclaimed objects on the next bitmap
tschatzl
parents:
diff changeset
107 // Keep the reference to the first object alive.
83ea089a5c64 8051973: Eager reclaim leaves marks of marked but reclaimed objects on the next bitmap
tschatzl
parents:
diff changeset
108 System.out.println(ref_from_stack);
83ea089a5c64 8051973: Eager reclaim leaves marks of marked but reclaimed objects on the next bitmap
tschatzl
parents:
diff changeset
109 }
83ea089a5c64 8051973: Eager reclaim leaves marks of marked but reclaimed objects on the next bitmap
tschatzl
parents:
diff changeset
110 }
83ea089a5c64 8051973: Eager reclaim leaves marks of marked but reclaimed objects on the next bitmap
tschatzl
parents:
diff changeset
111
83ea089a5c64 8051973: Eager reclaim leaves marks of marked but reclaimed objects on the next bitmap
tschatzl
parents:
diff changeset
112 public class TestEagerReclaimHumongousRegions2 {
83ea089a5c64 8051973: Eager reclaim leaves marks of marked but reclaimed objects on the next bitmap
tschatzl
parents:
diff changeset
113 public static void main(String[] args) throws Exception {
83ea089a5c64 8051973: Eager reclaim leaves marks of marked but reclaimed objects on the next bitmap
tschatzl
parents:
diff changeset
114 ProcessBuilder pb = ProcessTools.createJavaProcessBuilder(
83ea089a5c64 8051973: Eager reclaim leaves marks of marked but reclaimed objects on the next bitmap
tschatzl
parents:
diff changeset
115 "-XX:+UseG1GC",
83ea089a5c64 8051973: Eager reclaim leaves marks of marked but reclaimed objects on the next bitmap
tschatzl
parents:
diff changeset
116 "-Xms128M",
83ea089a5c64 8051973: Eager reclaim leaves marks of marked but reclaimed objects on the next bitmap
tschatzl
parents:
diff changeset
117 "-Xmx128M",
83ea089a5c64 8051973: Eager reclaim leaves marks of marked but reclaimed objects on the next bitmap
tschatzl
parents:
diff changeset
118 "-Xmn2M",
83ea089a5c64 8051973: Eager reclaim leaves marks of marked but reclaimed objects on the next bitmap
tschatzl
parents:
diff changeset
119 "-XX:G1HeapRegionSize=1M",
83ea089a5c64 8051973: Eager reclaim leaves marks of marked but reclaimed objects on the next bitmap
tschatzl
parents:
diff changeset
120 "-XX:InitiatingHeapOccupancyPercent=0", // Want to have as much as possible initial marks.
83ea089a5c64 8051973: Eager reclaim leaves marks of marked but reclaimed objects on the next bitmap
tschatzl
parents:
diff changeset
121 "-XX:+PrintGC",
83ea089a5c64 8051973: Eager reclaim leaves marks of marked but reclaimed objects on the next bitmap
tschatzl
parents:
diff changeset
122 "-XX:+VerifyAfterGC",
83ea089a5c64 8051973: Eager reclaim leaves marks of marked but reclaimed objects on the next bitmap
tschatzl
parents:
diff changeset
123 "-XX:ConcGCThreads=1", // Want to make marking as slow as possible.
83ea089a5c64 8051973: Eager reclaim leaves marks of marked but reclaimed objects on the next bitmap
tschatzl
parents:
diff changeset
124 "-XX:+IgnoreUnrecognizedVMOptions", // G1VerifyBitmaps is develop only.
83ea089a5c64 8051973: Eager reclaim leaves marks of marked but reclaimed objects on the next bitmap
tschatzl
parents:
diff changeset
125 "-XX:+G1VerifyBitmaps",
83ea089a5c64 8051973: Eager reclaim leaves marks of marked but reclaimed objects on the next bitmap
tschatzl
parents:
diff changeset
126 ReclaimRegionFast.class.getName());
83ea089a5c64 8051973: Eager reclaim leaves marks of marked but reclaimed objects on the next bitmap
tschatzl
parents:
diff changeset
127 OutputAnalyzer output = new OutputAnalyzer(pb.start());
83ea089a5c64 8051973: Eager reclaim leaves marks of marked but reclaimed objects on the next bitmap
tschatzl
parents:
diff changeset
128 output.shouldHaveExitValue(0);
83ea089a5c64 8051973: Eager reclaim leaves marks of marked but reclaimed objects on the next bitmap
tschatzl
parents:
diff changeset
129 }
83ea089a5c64 8051973: Eager reclaim leaves marks of marked but reclaimed objects on the next bitmap
tschatzl
parents:
diff changeset
130 }
83ea089a5c64 8051973: Eager reclaim leaves marks of marked but reclaimed objects on the next bitmap
tschatzl
parents:
diff changeset
131