Mercurial > hg > graal-jvmci-8
annotate test/gc/g1/TestGreyReclaimedHumongousObjects.java @ 24234:ea6f94ab283b default tip
Added tag jvmci-0.36 for changeset 8128b98d4736
author | Gilles Duboscq <gilles.m.duboscq@oracle.com> |
---|---|
date | Mon, 18 Sep 2017 18:49:45 +0200 |
parents | b7c8142a9e0b |
children |
rev | line source |
---|---|
23026
b7c8142a9e0b
8069367: Eagerly reclaimed humongous objects left on mark stack
kbarrett
parents:
diff
changeset
|
1 /* |
b7c8142a9e0b
8069367: Eagerly reclaimed humongous objects left on mark stack
kbarrett
parents:
diff
changeset
|
2 * Copyright (c) 2015, Oracle and/or its affiliates. All rights reserved. |
b7c8142a9e0b
8069367: Eagerly reclaimed humongous objects left on mark stack
kbarrett
parents:
diff
changeset
|
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. |
b7c8142a9e0b
8069367: Eagerly reclaimed humongous objects left on mark stack
kbarrett
parents:
diff
changeset
|
4 * |
b7c8142a9e0b
8069367: Eagerly reclaimed humongous objects left on mark stack
kbarrett
parents:
diff
changeset
|
5 * This code is free software; you can redistribute it and/or modify it |
b7c8142a9e0b
8069367: Eagerly reclaimed humongous objects left on mark stack
kbarrett
parents:
diff
changeset
|
6 * under the terms of the GNU General Public License version 2 only, as |
b7c8142a9e0b
8069367: Eagerly reclaimed humongous objects left on mark stack
kbarrett
parents:
diff
changeset
|
7 * published by the Free Software Foundation. |
b7c8142a9e0b
8069367: Eagerly reclaimed humongous objects left on mark stack
kbarrett
parents:
diff
changeset
|
8 * |
b7c8142a9e0b
8069367: Eagerly reclaimed humongous objects left on mark stack
kbarrett
parents:
diff
changeset
|
9 * This code is distributed in the hope that it will be useful, but WITHOUT |
b7c8142a9e0b
8069367: Eagerly reclaimed humongous objects left on mark stack
kbarrett
parents:
diff
changeset
|
10 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or |
b7c8142a9e0b
8069367: Eagerly reclaimed humongous objects left on mark stack
kbarrett
parents:
diff
changeset
|
11 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License |
b7c8142a9e0b
8069367: Eagerly reclaimed humongous objects left on mark stack
kbarrett
parents:
diff
changeset
|
12 * version 2 for more details (a copy is included in the LICENSE file that |
b7c8142a9e0b
8069367: Eagerly reclaimed humongous objects left on mark stack
kbarrett
parents:
diff
changeset
|
13 * accompanied this code). |
b7c8142a9e0b
8069367: Eagerly reclaimed humongous objects left on mark stack
kbarrett
parents:
diff
changeset
|
14 * |
b7c8142a9e0b
8069367: Eagerly reclaimed humongous objects left on mark stack
kbarrett
parents:
diff
changeset
|
15 * You should have received a copy of the GNU General Public License version |
b7c8142a9e0b
8069367: Eagerly reclaimed humongous objects left on mark stack
kbarrett
parents:
diff
changeset
|
16 * 2 along with this work; if not, write to the Free Software Foundation, |
b7c8142a9e0b
8069367: Eagerly reclaimed humongous objects left on mark stack
kbarrett
parents:
diff
changeset
|
17 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. |
b7c8142a9e0b
8069367: Eagerly reclaimed humongous objects left on mark stack
kbarrett
parents:
diff
changeset
|
18 * |
b7c8142a9e0b
8069367: Eagerly reclaimed humongous objects left on mark stack
kbarrett
parents:
diff
changeset
|
19 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA |
b7c8142a9e0b
8069367: Eagerly reclaimed humongous objects left on mark stack
kbarrett
parents:
diff
changeset
|
20 * or visit www.oracle.com if you need additional information or have any |
b7c8142a9e0b
8069367: Eagerly reclaimed humongous objects left on mark stack
kbarrett
parents:
diff
changeset
|
21 * questions. |
b7c8142a9e0b
8069367: Eagerly reclaimed humongous objects left on mark stack
kbarrett
parents:
diff
changeset
|
22 */ |
b7c8142a9e0b
8069367: Eagerly reclaimed humongous objects left on mark stack
kbarrett
parents:
diff
changeset
|
23 |
b7c8142a9e0b
8069367: Eagerly reclaimed humongous objects left on mark stack
kbarrett
parents:
diff
changeset
|
24 /* |
b7c8142a9e0b
8069367: Eagerly reclaimed humongous objects left on mark stack
kbarrett
parents:
diff
changeset
|
25 * @test TestGreyReclaimedHumongousObjects.java |
b7c8142a9e0b
8069367: Eagerly reclaimed humongous objects left on mark stack
kbarrett
parents:
diff
changeset
|
26 * @bug 8069367 |
b7c8142a9e0b
8069367: Eagerly reclaimed humongous objects left on mark stack
kbarrett
parents:
diff
changeset
|
27 * @requires vm.gc == "G1" | vm.gc == "null" |
b7c8142a9e0b
8069367: Eagerly reclaimed humongous objects left on mark stack
kbarrett
parents:
diff
changeset
|
28 * @summary Test handling of marked but unscanned reclaimed humongous objects. |
b7c8142a9e0b
8069367: Eagerly reclaimed humongous objects left on mark stack
kbarrett
parents:
diff
changeset
|
29 * @key gc |
b7c8142a9e0b
8069367: Eagerly reclaimed humongous objects left on mark stack
kbarrett
parents:
diff
changeset
|
30 * @run main/othervm -XX:+UseG1GC -Xss32m -Xmx128m -XX:G1HeapRegionSize=1m |
b7c8142a9e0b
8069367: Eagerly reclaimed humongous objects left on mark stack
kbarrett
parents:
diff
changeset
|
31 * -XX:+UnlockExperimentalVMOptions |
b7c8142a9e0b
8069367: Eagerly reclaimed humongous objects left on mark stack
kbarrett
parents:
diff
changeset
|
32 * -XX:+G1EagerReclaimHumongousObjects |
b7c8142a9e0b
8069367: Eagerly reclaimed humongous objects left on mark stack
kbarrett
parents:
diff
changeset
|
33 * -XX:+G1EagerReclaimHumongousObjectsWithStaleRefs |
b7c8142a9e0b
8069367: Eagerly reclaimed humongous objects left on mark stack
kbarrett
parents:
diff
changeset
|
34 * TestGreyReclaimedHumongousObjects 1048576 90 |
b7c8142a9e0b
8069367: Eagerly reclaimed humongous objects left on mark stack
kbarrett
parents:
diff
changeset
|
35 */ |
b7c8142a9e0b
8069367: Eagerly reclaimed humongous objects left on mark stack
kbarrett
parents:
diff
changeset
|
36 |
b7c8142a9e0b
8069367: Eagerly reclaimed humongous objects left on mark stack
kbarrett
parents:
diff
changeset
|
37 // This test spawns a bunch of threads, each of them rapidly |
b7c8142a9e0b
8069367: Eagerly reclaimed humongous objects left on mark stack
kbarrett
parents:
diff
changeset
|
38 // allocating large objects and storing them into a circular buffer |
b7c8142a9e0b
8069367: Eagerly reclaimed humongous objects left on mark stack
kbarrett
parents:
diff
changeset
|
39 // associated with the thread. The circular buffer results in these |
b7c8142a9e0b
8069367: Eagerly reclaimed humongous objects left on mark stack
kbarrett
parents:
diff
changeset
|
40 // objects becoming dead in fairly short order. |
b7c8142a9e0b
8069367: Eagerly reclaimed humongous objects left on mark stack
kbarrett
parents:
diff
changeset
|
41 // |
b7c8142a9e0b
8069367: Eagerly reclaimed humongous objects left on mark stack
kbarrett
parents:
diff
changeset
|
42 // The situation we're trying to provoke is |
b7c8142a9e0b
8069367: Eagerly reclaimed humongous objects left on mark stack
kbarrett
parents:
diff
changeset
|
43 // |
b7c8142a9e0b
8069367: Eagerly reclaimed humongous objects left on mark stack
kbarrett
parents:
diff
changeset
|
44 // (1) A humongous object H is marked and added to the mark stack. |
b7c8142a9e0b
8069367: Eagerly reclaimed humongous objects left on mark stack
kbarrett
parents:
diff
changeset
|
45 // |
b7c8142a9e0b
8069367: Eagerly reclaimed humongous objects left on mark stack
kbarrett
parents:
diff
changeset
|
46 // (2) An evacuation pause determines H is no longer live, and |
b7c8142a9e0b
8069367: Eagerly reclaimed humongous objects left on mark stack
kbarrett
parents:
diff
changeset
|
47 // reclaims it. This occurs before concurrent marking has gotten |
b7c8142a9e0b
8069367: Eagerly reclaimed humongous objects left on mark stack
kbarrett
parents:
diff
changeset
|
48 // around to processing the mark stack entry for H. |
b7c8142a9e0b
8069367: Eagerly reclaimed humongous objects left on mark stack
kbarrett
parents:
diff
changeset
|
49 // |
b7c8142a9e0b
8069367: Eagerly reclaimed humongous objects left on mark stack
kbarrett
parents:
diff
changeset
|
50 // (3) Concurrent marking processes the mark stack entry for H. The |
b7c8142a9e0b
8069367: Eagerly reclaimed humongous objects left on mark stack
kbarrett
parents:
diff
changeset
|
51 // bug is that it would attempt to scan the now dead object. |
b7c8142a9e0b
8069367: Eagerly reclaimed humongous objects left on mark stack
kbarrett
parents:
diff
changeset
|
52 // |
b7c8142a9e0b
8069367: Eagerly reclaimed humongous objects left on mark stack
kbarrett
parents:
diff
changeset
|
53 // Unfortunately, this test is *very* sensitive to configuration. |
b7c8142a9e0b
8069367: Eagerly reclaimed humongous objects left on mark stack
kbarrett
parents:
diff
changeset
|
54 // Among the parameters that affect whether / how often we'll get into |
b7c8142a9e0b
8069367: Eagerly reclaimed humongous objects left on mark stack
kbarrett
parents:
diff
changeset
|
55 // the desired situation within a reasonable amount of time are: |
b7c8142a9e0b
8069367: Eagerly reclaimed humongous objects left on mark stack
kbarrett
parents:
diff
changeset
|
56 // |
b7c8142a9e0b
8069367: Eagerly reclaimed humongous objects left on mark stack
kbarrett
parents:
diff
changeset
|
57 // - THREAD_COUNT: The number of allocating threads. |
b7c8142a9e0b
8069367: Eagerly reclaimed humongous objects left on mark stack
kbarrett
parents:
diff
changeset
|
58 // |
b7c8142a9e0b
8069367: Eagerly reclaimed humongous objects left on mark stack
kbarrett
parents:
diff
changeset
|
59 // - OLD_COUNT: The number of objects each thread keeps. |
b7c8142a9e0b
8069367: Eagerly reclaimed humongous objects left on mark stack
kbarrett
parents:
diff
changeset
|
60 // |
b7c8142a9e0b
8069367: Eagerly reclaimed humongous objects left on mark stack
kbarrett
parents:
diff
changeset
|
61 // - MAX_MEMORY: The maximum heap size. |
b7c8142a9e0b
8069367: Eagerly reclaimed humongous objects left on mark stack
kbarrett
parents:
diff
changeset
|
62 // |
b7c8142a9e0b
8069367: Eagerly reclaimed humongous objects left on mark stack
kbarrett
parents:
diff
changeset
|
63 // - G1HeapRegionSize |
b7c8142a9e0b
8069367: Eagerly reclaimed humongous objects left on mark stack
kbarrett
parents:
diff
changeset
|
64 // |
b7c8142a9e0b
8069367: Eagerly reclaimed humongous objects left on mark stack
kbarrett
parents:
diff
changeset
|
65 // - The size of the objects being allocated. |
b7c8142a9e0b
8069367: Eagerly reclaimed humongous objects left on mark stack
kbarrett
parents:
diff
changeset
|
66 // |
b7c8142a9e0b
8069367: Eagerly reclaimed humongous objects left on mark stack
kbarrett
parents:
diff
changeset
|
67 // The parameter values specified here: |
b7c8142a9e0b
8069367: Eagerly reclaimed humongous objects left on mark stack
kbarrett
parents:
diff
changeset
|
68 // |
b7c8142a9e0b
8069367: Eagerly reclaimed humongous objects left on mark stack
kbarrett
parents:
diff
changeset
|
69 // - THREAD_COUNT = 12 |
b7c8142a9e0b
8069367: Eagerly reclaimed humongous objects left on mark stack
kbarrett
parents:
diff
changeset
|
70 // - OLD_COUNT == 4 |
b7c8142a9e0b
8069367: Eagerly reclaimed humongous objects left on mark stack
kbarrett
parents:
diff
changeset
|
71 // - MAX_MEMORY == 128m |
b7c8142a9e0b
8069367: Eagerly reclaimed humongous objects left on mark stack
kbarrett
parents:
diff
changeset
|
72 // - G1HeapRegionSize = 1m |
b7c8142a9e0b
8069367: Eagerly reclaimed humongous objects left on mark stack
kbarrett
parents:
diff
changeset
|
73 // - Object size = 1048576 (2 regions after header overhead and roundup) |
b7c8142a9e0b
8069367: Eagerly reclaimed humongous objects left on mark stack
kbarrett
parents:
diff
changeset
|
74 // |
b7c8142a9e0b
8069367: Eagerly reclaimed humongous objects left on mark stack
kbarrett
parents:
diff
changeset
|
75 // seems to work well at provoking the desired state fairly quickly. |
b7c8142a9e0b
8069367: Eagerly reclaimed humongous objects left on mark stack
kbarrett
parents:
diff
changeset
|
76 // Even relatively small perturbations may change that. The key |
b7c8142a9e0b
8069367: Eagerly reclaimed humongous objects left on mark stack
kbarrett
parents:
diff
changeset
|
77 // factors seem to be keeping the heap mostly full of live objects but |
b7c8142a9e0b
8069367: Eagerly reclaimed humongous objects left on mark stack
kbarrett
parents:
diff
changeset
|
78 // having them become dead fairly quickly. |
b7c8142a9e0b
8069367: Eagerly reclaimed humongous objects left on mark stack
kbarrett
parents:
diff
changeset
|
79 |
b7c8142a9e0b
8069367: Eagerly reclaimed humongous objects left on mark stack
kbarrett
parents:
diff
changeset
|
80 import java.util.Date; |
b7c8142a9e0b
8069367: Eagerly reclaimed humongous objects left on mark stack
kbarrett
parents:
diff
changeset
|
81 import java.util.concurrent.ExecutorService; |
b7c8142a9e0b
8069367: Eagerly reclaimed humongous objects left on mark stack
kbarrett
parents:
diff
changeset
|
82 import java.util.concurrent.Executors; |
b7c8142a9e0b
8069367: Eagerly reclaimed humongous objects left on mark stack
kbarrett
parents:
diff
changeset
|
83 import java.util.concurrent.ThreadFactory; |
b7c8142a9e0b
8069367: Eagerly reclaimed humongous objects left on mark stack
kbarrett
parents:
diff
changeset
|
84 import java.util.concurrent.TimeUnit; |
b7c8142a9e0b
8069367: Eagerly reclaimed humongous objects left on mark stack
kbarrett
parents:
diff
changeset
|
85 import sun.management.ManagementFactoryHelper; |
b7c8142a9e0b
8069367: Eagerly reclaimed humongous objects left on mark stack
kbarrett
parents:
diff
changeset
|
86 import com.sun.management.HotSpotDiagnosticMXBean; |
b7c8142a9e0b
8069367: Eagerly reclaimed humongous objects left on mark stack
kbarrett
parents:
diff
changeset
|
87 import com.sun.management.VMOption; |
b7c8142a9e0b
8069367: Eagerly reclaimed humongous objects left on mark stack
kbarrett
parents:
diff
changeset
|
88 |
b7c8142a9e0b
8069367: Eagerly reclaimed humongous objects left on mark stack
kbarrett
parents:
diff
changeset
|
89 public class TestGreyReclaimedHumongousObjects { |
b7c8142a9e0b
8069367: Eagerly reclaimed humongous objects left on mark stack
kbarrett
parents:
diff
changeset
|
90 |
b7c8142a9e0b
8069367: Eagerly reclaimed humongous objects left on mark stack
kbarrett
parents:
diff
changeset
|
91 static class NamedThreadFactory implements ThreadFactory { |
b7c8142a9e0b
8069367: Eagerly reclaimed humongous objects left on mark stack
kbarrett
parents:
diff
changeset
|
92 private int threadNum = 0; |
b7c8142a9e0b
8069367: Eagerly reclaimed humongous objects left on mark stack
kbarrett
parents:
diff
changeset
|
93 |
b7c8142a9e0b
8069367: Eagerly reclaimed humongous objects left on mark stack
kbarrett
parents:
diff
changeset
|
94 @Override |
b7c8142a9e0b
8069367: Eagerly reclaimed humongous objects left on mark stack
kbarrett
parents:
diff
changeset
|
95 public Thread newThread(Runnable r) { |
b7c8142a9e0b
8069367: Eagerly reclaimed humongous objects left on mark stack
kbarrett
parents:
diff
changeset
|
96 return new Thread(r, THREAD_NAME + (threadNum++)); |
b7c8142a9e0b
8069367: Eagerly reclaimed humongous objects left on mark stack
kbarrett
parents:
diff
changeset
|
97 } |
b7c8142a9e0b
8069367: Eagerly reclaimed humongous objects left on mark stack
kbarrett
parents:
diff
changeset
|
98 } |
b7c8142a9e0b
8069367: Eagerly reclaimed humongous objects left on mark stack
kbarrett
parents:
diff
changeset
|
99 |
b7c8142a9e0b
8069367: Eagerly reclaimed humongous objects left on mark stack
kbarrett
parents:
diff
changeset
|
100 static class Runner extends Thread { |
b7c8142a9e0b
8069367: Eagerly reclaimed humongous objects left on mark stack
kbarrett
parents:
diff
changeset
|
101 private final Date startDate = new Date(); |
b7c8142a9e0b
8069367: Eagerly reclaimed humongous objects left on mark stack
kbarrett
parents:
diff
changeset
|
102 private final int obj_size; |
b7c8142a9e0b
8069367: Eagerly reclaimed humongous objects left on mark stack
kbarrett
parents:
diff
changeset
|
103 private final Object[] old_garbage; |
b7c8142a9e0b
8069367: Eagerly reclaimed humongous objects left on mark stack
kbarrett
parents:
diff
changeset
|
104 private int old_index = 0; |
b7c8142a9e0b
8069367: Eagerly reclaimed humongous objects left on mark stack
kbarrett
parents:
diff
changeset
|
105 |
b7c8142a9e0b
8069367: Eagerly reclaimed humongous objects left on mark stack
kbarrett
parents:
diff
changeset
|
106 public Runner(int obj_size) { |
b7c8142a9e0b
8069367: Eagerly reclaimed humongous objects left on mark stack
kbarrett
parents:
diff
changeset
|
107 this.obj_size = obj_size; |
b7c8142a9e0b
8069367: Eagerly reclaimed humongous objects left on mark stack
kbarrett
parents:
diff
changeset
|
108 old_garbage = new Object[OLD_COUNT]; |
b7c8142a9e0b
8069367: Eagerly reclaimed humongous objects left on mark stack
kbarrett
parents:
diff
changeset
|
109 } |
b7c8142a9e0b
8069367: Eagerly reclaimed humongous objects left on mark stack
kbarrett
parents:
diff
changeset
|
110 |
b7c8142a9e0b
8069367: Eagerly reclaimed humongous objects left on mark stack
kbarrett
parents:
diff
changeset
|
111 private void allocate_garbage() { |
b7c8142a9e0b
8069367: Eagerly reclaimed humongous objects left on mark stack
kbarrett
parents:
diff
changeset
|
112 byte[] garbage = new byte[obj_size]; |
b7c8142a9e0b
8069367: Eagerly reclaimed humongous objects left on mark stack
kbarrett
parents:
diff
changeset
|
113 old_garbage[Math.abs(++old_index % OLD_COUNT)] = garbage; |
b7c8142a9e0b
8069367: Eagerly reclaimed humongous objects left on mark stack
kbarrett
parents:
diff
changeset
|
114 } |
b7c8142a9e0b
8069367: Eagerly reclaimed humongous objects left on mark stack
kbarrett
parents:
diff
changeset
|
115 |
b7c8142a9e0b
8069367: Eagerly reclaimed humongous objects left on mark stack
kbarrett
parents:
diff
changeset
|
116 @Override |
b7c8142a9e0b
8069367: Eagerly reclaimed humongous objects left on mark stack
kbarrett
parents:
diff
changeset
|
117 public void run() { |
b7c8142a9e0b
8069367: Eagerly reclaimed humongous objects left on mark stack
kbarrett
parents:
diff
changeset
|
118 try { |
b7c8142a9e0b
8069367: Eagerly reclaimed humongous objects left on mark stack
kbarrett
parents:
diff
changeset
|
119 while (!isInterrupted()) { |
b7c8142a9e0b
8069367: Eagerly reclaimed humongous objects left on mark stack
kbarrett
parents:
diff
changeset
|
120 allocate_garbage(); |
b7c8142a9e0b
8069367: Eagerly reclaimed humongous objects left on mark stack
kbarrett
parents:
diff
changeset
|
121 Thread.sleep(0); // Yield, to ensure interruptable. |
b7c8142a9e0b
8069367: Eagerly reclaimed humongous objects left on mark stack
kbarrett
parents:
diff
changeset
|
122 } |
b7c8142a9e0b
8069367: Eagerly reclaimed humongous objects left on mark stack
kbarrett
parents:
diff
changeset
|
123 } catch (InterruptedException e) { |
b7c8142a9e0b
8069367: Eagerly reclaimed humongous objects left on mark stack
kbarrett
parents:
diff
changeset
|
124 System.out.println("Aborted after " |
b7c8142a9e0b
8069367: Eagerly reclaimed humongous objects left on mark stack
kbarrett
parents:
diff
changeset
|
125 + (new Date().getTime() - startDate.getTime()) |
b7c8142a9e0b
8069367: Eagerly reclaimed humongous objects left on mark stack
kbarrett
parents:
diff
changeset
|
126 + " ms"); |
b7c8142a9e0b
8069367: Eagerly reclaimed humongous objects left on mark stack
kbarrett
parents:
diff
changeset
|
127 interrupt(); |
b7c8142a9e0b
8069367: Eagerly reclaimed humongous objects left on mark stack
kbarrett
parents:
diff
changeset
|
128 } |
b7c8142a9e0b
8069367: Eagerly reclaimed humongous objects left on mark stack
kbarrett
parents:
diff
changeset
|
129 } |
b7c8142a9e0b
8069367: Eagerly reclaimed humongous objects left on mark stack
kbarrett
parents:
diff
changeset
|
130 } |
b7c8142a9e0b
8069367: Eagerly reclaimed humongous objects left on mark stack
kbarrett
parents:
diff
changeset
|
131 |
b7c8142a9e0b
8069367: Eagerly reclaimed humongous objects left on mark stack
kbarrett
parents:
diff
changeset
|
132 public static void main(String[] args) throws Exception { |
b7c8142a9e0b
8069367: Eagerly reclaimed humongous objects left on mark stack
kbarrett
parents:
diff
changeset
|
133 HotSpotDiagnosticMXBean diagnostic = ManagementFactoryHelper.getDiagnosticMXBean(); |
b7c8142a9e0b
8069367: Eagerly reclaimed humongous objects left on mark stack
kbarrett
parents:
diff
changeset
|
134 |
b7c8142a9e0b
8069367: Eagerly reclaimed humongous objects left on mark stack
kbarrett
parents:
diff
changeset
|
135 System.out.println("Max memory= " + MAX_MEMORY + " bytes"); |
b7c8142a9e0b
8069367: Eagerly reclaimed humongous objects left on mark stack
kbarrett
parents:
diff
changeset
|
136 |
b7c8142a9e0b
8069367: Eagerly reclaimed humongous objects left on mark stack
kbarrett
parents:
diff
changeset
|
137 int obj_size = 0; |
b7c8142a9e0b
8069367: Eagerly reclaimed humongous objects left on mark stack
kbarrett
parents:
diff
changeset
|
138 long seconds_to_run = 0; |
b7c8142a9e0b
8069367: Eagerly reclaimed humongous objects left on mark stack
kbarrett
parents:
diff
changeset
|
139 if (args.length != 2) { |
b7c8142a9e0b
8069367: Eagerly reclaimed humongous objects left on mark stack
kbarrett
parents:
diff
changeset
|
140 throw new RuntimeException("Object size argument must be supplied"); |
b7c8142a9e0b
8069367: Eagerly reclaimed humongous objects left on mark stack
kbarrett
parents:
diff
changeset
|
141 } else { |
b7c8142a9e0b
8069367: Eagerly reclaimed humongous objects left on mark stack
kbarrett
parents:
diff
changeset
|
142 obj_size = Integer.parseInt(args[0]); |
b7c8142a9e0b
8069367: Eagerly reclaimed humongous objects left on mark stack
kbarrett
parents:
diff
changeset
|
143 seconds_to_run = Integer.parseInt(args[1]); |
b7c8142a9e0b
8069367: Eagerly reclaimed humongous objects left on mark stack
kbarrett
parents:
diff
changeset
|
144 } |
b7c8142a9e0b
8069367: Eagerly reclaimed humongous objects left on mark stack
kbarrett
parents:
diff
changeset
|
145 System.out.println("Objects size= " + obj_size + " bytes"); |
b7c8142a9e0b
8069367: Eagerly reclaimed humongous objects left on mark stack
kbarrett
parents:
diff
changeset
|
146 System.out.println("Seconds to run=" + seconds_to_run); |
b7c8142a9e0b
8069367: Eagerly reclaimed humongous objects left on mark stack
kbarrett
parents:
diff
changeset
|
147 |
b7c8142a9e0b
8069367: Eagerly reclaimed humongous objects left on mark stack
kbarrett
parents:
diff
changeset
|
148 int region_size = |
b7c8142a9e0b
8069367: Eagerly reclaimed humongous objects left on mark stack
kbarrett
parents:
diff
changeset
|
149 Integer.parseInt(diagnostic.getVMOption("G1HeapRegionSize").getValue()); |
b7c8142a9e0b
8069367: Eagerly reclaimed humongous objects left on mark stack
kbarrett
parents:
diff
changeset
|
150 if (obj_size < (region_size / 2)) { |
b7c8142a9e0b
8069367: Eagerly reclaimed humongous objects left on mark stack
kbarrett
parents:
diff
changeset
|
151 throw new RuntimeException("Object size " + obj_size + |
b7c8142a9e0b
8069367: Eagerly reclaimed humongous objects left on mark stack
kbarrett
parents:
diff
changeset
|
152 " is not humongous with region size " + region_size); |
b7c8142a9e0b
8069367: Eagerly reclaimed humongous objects left on mark stack
kbarrett
parents:
diff
changeset
|
153 } |
b7c8142a9e0b
8069367: Eagerly reclaimed humongous objects left on mark stack
kbarrett
parents:
diff
changeset
|
154 |
b7c8142a9e0b
8069367: Eagerly reclaimed humongous objects left on mark stack
kbarrett
parents:
diff
changeset
|
155 ExecutorService executor = |
b7c8142a9e0b
8069367: Eagerly reclaimed humongous objects left on mark stack
kbarrett
parents:
diff
changeset
|
156 Executors.newFixedThreadPool(THREAD_COUNT, new NamedThreadFactory()); |
b7c8142a9e0b
8069367: Eagerly reclaimed humongous objects left on mark stack
kbarrett
parents:
diff
changeset
|
157 System.out.println("Starting " + THREAD_COUNT + " threads"); |
b7c8142a9e0b
8069367: Eagerly reclaimed humongous objects left on mark stack
kbarrett
parents:
diff
changeset
|
158 |
b7c8142a9e0b
8069367: Eagerly reclaimed humongous objects left on mark stack
kbarrett
parents:
diff
changeset
|
159 for (int i = 0; i < THREAD_COUNT; i++) { |
b7c8142a9e0b
8069367: Eagerly reclaimed humongous objects left on mark stack
kbarrett
parents:
diff
changeset
|
160 executor.execute(new Runner(obj_size)); |
b7c8142a9e0b
8069367: Eagerly reclaimed humongous objects left on mark stack
kbarrett
parents:
diff
changeset
|
161 } |
b7c8142a9e0b
8069367: Eagerly reclaimed humongous objects left on mark stack
kbarrett
parents:
diff
changeset
|
162 |
b7c8142a9e0b
8069367: Eagerly reclaimed humongous objects left on mark stack
kbarrett
parents:
diff
changeset
|
163 Thread.sleep(seconds_to_run * 1000); |
b7c8142a9e0b
8069367: Eagerly reclaimed humongous objects left on mark stack
kbarrett
parents:
diff
changeset
|
164 executor.shutdownNow(); |
b7c8142a9e0b
8069367: Eagerly reclaimed humongous objects left on mark stack
kbarrett
parents:
diff
changeset
|
165 |
b7c8142a9e0b
8069367: Eagerly reclaimed humongous objects left on mark stack
kbarrett
parents:
diff
changeset
|
166 if (!executor.awaitTermination(10, TimeUnit.SECONDS)) { |
b7c8142a9e0b
8069367: Eagerly reclaimed humongous objects left on mark stack
kbarrett
parents:
diff
changeset
|
167 System.err.println("Thread pool did not terminate after 10 seconds after shutdown"); |
b7c8142a9e0b
8069367: Eagerly reclaimed humongous objects left on mark stack
kbarrett
parents:
diff
changeset
|
168 } |
b7c8142a9e0b
8069367: Eagerly reclaimed humongous objects left on mark stack
kbarrett
parents:
diff
changeset
|
169 } |
b7c8142a9e0b
8069367: Eagerly reclaimed humongous objects left on mark stack
kbarrett
parents:
diff
changeset
|
170 |
b7c8142a9e0b
8069367: Eagerly reclaimed humongous objects left on mark stack
kbarrett
parents:
diff
changeset
|
171 private static final long MAX_MEMORY = Runtime.getRuntime().maxMemory(); |
b7c8142a9e0b
8069367: Eagerly reclaimed humongous objects left on mark stack
kbarrett
parents:
diff
changeset
|
172 private static final int OLD_COUNT = 4; |
b7c8142a9e0b
8069367: Eagerly reclaimed humongous objects left on mark stack
kbarrett
parents:
diff
changeset
|
173 private static final int THREAD_COUNT = 12; |
b7c8142a9e0b
8069367: Eagerly reclaimed humongous objects left on mark stack
kbarrett
parents:
diff
changeset
|
174 private static final String THREAD_NAME = "TestGreyRH-"; |
b7c8142a9e0b
8069367: Eagerly reclaimed humongous objects left on mark stack
kbarrett
parents:
diff
changeset
|
175 } |
b7c8142a9e0b
8069367: Eagerly reclaimed humongous objects left on mark stack
kbarrett
parents:
diff
changeset
|
176 |