Mercurial > hg > graal-jvmci-8
annotate test/stress/gc/TestStressRSetCoarsening.java @ 24198:678f11cc769e jdk8u141-b03
8173207: Upgrade compression library
Reviewed-by: sherman, jeff
author | coffeys |
---|---|
date | Thu, 16 Mar 2017 17:38:32 +0000 |
parents | 89c75331f9b6 |
children |
rev | line source |
---|---|
23625
89c75331f9b6
8134963: [Newtest] New stress test for changing the coarseness level of G1 remembered set
dfazunen
parents:
diff
changeset
|
1 /* |
89c75331f9b6
8134963: [Newtest] New stress test for changing the coarseness level of G1 remembered set
dfazunen
parents:
diff
changeset
|
2 * Copyright (c) 2016, Oracle and/or its affiliates. All rights reserved. |
89c75331f9b6
8134963: [Newtest] New stress test for changing the coarseness level of G1 remembered set
dfazunen
parents:
diff
changeset
|
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. |
89c75331f9b6
8134963: [Newtest] New stress test for changing the coarseness level of G1 remembered set
dfazunen
parents:
diff
changeset
|
4 * |
89c75331f9b6
8134963: [Newtest] New stress test for changing the coarseness level of G1 remembered set
dfazunen
parents:
diff
changeset
|
5 * This code is free software; you can redistribute it and/or modify it |
89c75331f9b6
8134963: [Newtest] New stress test for changing the coarseness level of G1 remembered set
dfazunen
parents:
diff
changeset
|
6 * under the terms of the GNU General Public License version 2 only, as |
89c75331f9b6
8134963: [Newtest] New stress test for changing the coarseness level of G1 remembered set
dfazunen
parents:
diff
changeset
|
7 * published by the Free Software Foundation. |
89c75331f9b6
8134963: [Newtest] New stress test for changing the coarseness level of G1 remembered set
dfazunen
parents:
diff
changeset
|
8 * |
89c75331f9b6
8134963: [Newtest] New stress test for changing the coarseness level of G1 remembered set
dfazunen
parents:
diff
changeset
|
9 * This code is distributed in the hope that it will be useful, but WITHOUT |
89c75331f9b6
8134963: [Newtest] New stress test for changing the coarseness level of G1 remembered set
dfazunen
parents:
diff
changeset
|
10 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or |
89c75331f9b6
8134963: [Newtest] New stress test for changing the coarseness level of G1 remembered set
dfazunen
parents:
diff
changeset
|
11 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License |
89c75331f9b6
8134963: [Newtest] New stress test for changing the coarseness level of G1 remembered set
dfazunen
parents:
diff
changeset
|
12 * version 2 for more details (a copy is included in the LICENSE file that |
89c75331f9b6
8134963: [Newtest] New stress test for changing the coarseness level of G1 remembered set
dfazunen
parents:
diff
changeset
|
13 * accompanied this code). |
89c75331f9b6
8134963: [Newtest] New stress test for changing the coarseness level of G1 remembered set
dfazunen
parents:
diff
changeset
|
14 * |
89c75331f9b6
8134963: [Newtest] New stress test for changing the coarseness level of G1 remembered set
dfazunen
parents:
diff
changeset
|
15 * You should have received a copy of the GNU General Public License version |
89c75331f9b6
8134963: [Newtest] New stress test for changing the coarseness level of G1 remembered set
dfazunen
parents:
diff
changeset
|
16 * 2 along with this work; if not, write to the Free Software Foundation, |
89c75331f9b6
8134963: [Newtest] New stress test for changing the coarseness level of G1 remembered set
dfazunen
parents:
diff
changeset
|
17 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. |
89c75331f9b6
8134963: [Newtest] New stress test for changing the coarseness level of G1 remembered set
dfazunen
parents:
diff
changeset
|
18 * |
89c75331f9b6
8134963: [Newtest] New stress test for changing the coarseness level of G1 remembered set
dfazunen
parents:
diff
changeset
|
19 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA |
89c75331f9b6
8134963: [Newtest] New stress test for changing the coarseness level of G1 remembered set
dfazunen
parents:
diff
changeset
|
20 * or visit www.oracle.com if you need additional information or have any |
89c75331f9b6
8134963: [Newtest] New stress test for changing the coarseness level of G1 remembered set
dfazunen
parents:
diff
changeset
|
21 * questions. |
89c75331f9b6
8134963: [Newtest] New stress test for changing the coarseness level of G1 remembered set
dfazunen
parents:
diff
changeset
|
22 */ |
89c75331f9b6
8134963: [Newtest] New stress test for changing the coarseness level of G1 remembered set
dfazunen
parents:
diff
changeset
|
23 |
89c75331f9b6
8134963: [Newtest] New stress test for changing the coarseness level of G1 remembered set
dfazunen
parents:
diff
changeset
|
24 import java.util.concurrent.TimeoutException; |
89c75331f9b6
8134963: [Newtest] New stress test for changing the coarseness level of G1 remembered set
dfazunen
parents:
diff
changeset
|
25 import sun.hotspot.WhiteBox; |
89c75331f9b6
8134963: [Newtest] New stress test for changing the coarseness level of G1 remembered set
dfazunen
parents:
diff
changeset
|
26 |
89c75331f9b6
8134963: [Newtest] New stress test for changing the coarseness level of G1 remembered set
dfazunen
parents:
diff
changeset
|
27 /* |
89c75331f9b6
8134963: [Newtest] New stress test for changing the coarseness level of G1 remembered set
dfazunen
parents:
diff
changeset
|
28 * @test TestStressRSetCoarsening.java |
89c75331f9b6
8134963: [Newtest] New stress test for changing the coarseness level of G1 remembered set
dfazunen
parents:
diff
changeset
|
29 * @key stress |
89c75331f9b6
8134963: [Newtest] New stress test for changing the coarseness level of G1 remembered set
dfazunen
parents:
diff
changeset
|
30 * @bug 8146984 8147087 |
89c75331f9b6
8134963: [Newtest] New stress test for changing the coarseness level of G1 remembered set
dfazunen
parents:
diff
changeset
|
31 * @requires vm.gc=="G1" | vm.gc=="null" |
89c75331f9b6
8134963: [Newtest] New stress test for changing the coarseness level of G1 remembered set
dfazunen
parents:
diff
changeset
|
32 * @requires os.maxMemory > 3G |
89c75331f9b6
8134963: [Newtest] New stress test for changing the coarseness level of G1 remembered set
dfazunen
parents:
diff
changeset
|
33 * |
89c75331f9b6
8134963: [Newtest] New stress test for changing the coarseness level of G1 remembered set
dfazunen
parents:
diff
changeset
|
34 * @summary Stress G1 Remembered Set by creating a lot of cross region links |
89c75331f9b6
8134963: [Newtest] New stress test for changing the coarseness level of G1 remembered set
dfazunen
parents:
diff
changeset
|
35 * @library /testlibrary /testlibrary/whitebox |
89c75331f9b6
8134963: [Newtest] New stress test for changing the coarseness level of G1 remembered set
dfazunen
parents:
diff
changeset
|
36 * @build sun.hotspot.WhiteBox |
89c75331f9b6
8134963: [Newtest] New stress test for changing the coarseness level of G1 remembered set
dfazunen
parents:
diff
changeset
|
37 * @run main ClassFileInstaller sun.hotspot.WhiteBox |
89c75331f9b6
8134963: [Newtest] New stress test for changing the coarseness level of G1 remembered set
dfazunen
parents:
diff
changeset
|
38 * sun.hotspot.WhiteBox$WhiteBoxPermission |
89c75331f9b6
8134963: [Newtest] New stress test for changing the coarseness level of G1 remembered set
dfazunen
parents:
diff
changeset
|
39 * @run main/othervm/timeout=300 |
89c75331f9b6
8134963: [Newtest] New stress test for changing the coarseness level of G1 remembered set
dfazunen
parents:
diff
changeset
|
40 * -Xbootclasspath/a:. -XX:+UnlockDiagnosticVMOptions -XX:+WhiteBoxAPI -XX:+UseG1GC |
89c75331f9b6
8134963: [Newtest] New stress test for changing the coarseness level of G1 remembered set
dfazunen
parents:
diff
changeset
|
41 * -XX:+IgnoreUnrecognizedVMOptions -XX:+PrintGC -XX:+PrintGCTimeStamps -Xlog:gc |
89c75331f9b6
8134963: [Newtest] New stress test for changing the coarseness level of G1 remembered set
dfazunen
parents:
diff
changeset
|
42 * -Xmx500m -XX:G1HeapRegionSize=1m -XX:MaxGCPauseMillis=1000 TestStressRSetCoarsening 1 0 300 |
89c75331f9b6
8134963: [Newtest] New stress test for changing the coarseness level of G1 remembered set
dfazunen
parents:
diff
changeset
|
43 * @run main/othervm/timeout=300 |
89c75331f9b6
8134963: [Newtest] New stress test for changing the coarseness level of G1 remembered set
dfazunen
parents:
diff
changeset
|
44 * -Xbootclasspath/a:. -XX:+UnlockDiagnosticVMOptions -XX:+WhiteBoxAPI -XX:+UseG1GC |
89c75331f9b6
8134963: [Newtest] New stress test for changing the coarseness level of G1 remembered set
dfazunen
parents:
diff
changeset
|
45 * -XX:+IgnoreUnrecognizedVMOptions -XX:+PrintGC -XX:+PrintGCTimeStamps -Xlog:gc |
89c75331f9b6
8134963: [Newtest] New stress test for changing the coarseness level of G1 remembered set
dfazunen
parents:
diff
changeset
|
46 * -Xmx500m -XX:G1HeapRegionSize=8m -XX:MaxGCPauseMillis=1000 TestStressRSetCoarsening 1 10 300 |
89c75331f9b6
8134963: [Newtest] New stress test for changing the coarseness level of G1 remembered set
dfazunen
parents:
diff
changeset
|
47 * @run main/othervm/timeout=300 |
89c75331f9b6
8134963: [Newtest] New stress test for changing the coarseness level of G1 remembered set
dfazunen
parents:
diff
changeset
|
48 * -Xbootclasspath/a:. -XX:+UnlockDiagnosticVMOptions -XX:+WhiteBoxAPI -XX:+UseG1GC |
89c75331f9b6
8134963: [Newtest] New stress test for changing the coarseness level of G1 remembered set
dfazunen
parents:
diff
changeset
|
49 * -XX:+IgnoreUnrecognizedVMOptions -XX:+PrintGC -XX:+PrintGCTimeStamps -Xlog:gc |
89c75331f9b6
8134963: [Newtest] New stress test for changing the coarseness level of G1 remembered set
dfazunen
parents:
diff
changeset
|
50 * -Xmx500m -XX:G1HeapRegionSize=32m -XX:MaxGCPauseMillis=1000 TestStressRSetCoarsening 42 10 300 |
89c75331f9b6
8134963: [Newtest] New stress test for changing the coarseness level of G1 remembered set
dfazunen
parents:
diff
changeset
|
51 * @run main/othervm/timeout=300 |
89c75331f9b6
8134963: [Newtest] New stress test for changing the coarseness level of G1 remembered set
dfazunen
parents:
diff
changeset
|
52 * -Xbootclasspath/a:. -XX:+UnlockDiagnosticVMOptions -XX:+WhiteBoxAPI -XX:+UseG1GC |
89c75331f9b6
8134963: [Newtest] New stress test for changing the coarseness level of G1 remembered set
dfazunen
parents:
diff
changeset
|
53 * -XX:+IgnoreUnrecognizedVMOptions -XX:+PrintGC -XX:+PrintGCTimeStamps -Xlog:gc |
89c75331f9b6
8134963: [Newtest] New stress test for changing the coarseness level of G1 remembered set
dfazunen
parents:
diff
changeset
|
54 * -Xmx500m -XX:G1HeapRegionSize=1m -XX:MaxGCPauseMillis=1000 TestStressRSetCoarsening 2 0 300 |
89c75331f9b6
8134963: [Newtest] New stress test for changing the coarseness level of G1 remembered set
dfazunen
parents:
diff
changeset
|
55 * @run main/othervm/timeout=1800 |
89c75331f9b6
8134963: [Newtest] New stress test for changing the coarseness level of G1 remembered set
dfazunen
parents:
diff
changeset
|
56 * -Xbootclasspath/a:. -XX:+UnlockDiagnosticVMOptions -XX:+WhiteBoxAPI -XX:+UseG1GC |
89c75331f9b6
8134963: [Newtest] New stress test for changing the coarseness level of G1 remembered set
dfazunen
parents:
diff
changeset
|
57 * -XX:+IgnoreUnrecognizedVMOptions -XX:+PrintGC -XX:+PrintGCTimeStamps -Xlog:gc |
89c75331f9b6
8134963: [Newtest] New stress test for changing the coarseness level of G1 remembered set
dfazunen
parents:
diff
changeset
|
58 * -Xmx1G -XX:G1HeapRegionSize=1m -XX:MaxGCPauseMillis=1000 TestStressRSetCoarsening 500 0 1800 |
89c75331f9b6
8134963: [Newtest] New stress test for changing the coarseness level of G1 remembered set
dfazunen
parents:
diff
changeset
|
59 * @run main/othervm/timeout=1800 |
89c75331f9b6
8134963: [Newtest] New stress test for changing the coarseness level of G1 remembered set
dfazunen
parents:
diff
changeset
|
60 * -Xbootclasspath/a:. -XX:+UnlockDiagnosticVMOptions -XX:+WhiteBoxAPI -XX:+UseG1GC |
89c75331f9b6
8134963: [Newtest] New stress test for changing the coarseness level of G1 remembered set
dfazunen
parents:
diff
changeset
|
61 * -XX:+IgnoreUnrecognizedVMOptions -XX:+PrintGC -XX:+PrintGCTimeStamps -Xlog:gc |
89c75331f9b6
8134963: [Newtest] New stress test for changing the coarseness level of G1 remembered set
dfazunen
parents:
diff
changeset
|
62 * -Xmx1G -XX:G1HeapRegionSize=1m -XX:MaxGCPauseMillis=1000 TestStressRSetCoarsening 10 10 1800 |
89c75331f9b6
8134963: [Newtest] New stress test for changing the coarseness level of G1 remembered set
dfazunen
parents:
diff
changeset
|
63 */ |
89c75331f9b6
8134963: [Newtest] New stress test for changing the coarseness level of G1 remembered set
dfazunen
parents:
diff
changeset
|
64 |
89c75331f9b6
8134963: [Newtest] New stress test for changing the coarseness level of G1 remembered set
dfazunen
parents:
diff
changeset
|
65 /** |
89c75331f9b6
8134963: [Newtest] New stress test for changing the coarseness level of G1 remembered set
dfazunen
parents:
diff
changeset
|
66 * What the test does. |
89c75331f9b6
8134963: [Newtest] New stress test for changing the coarseness level of G1 remembered set
dfazunen
parents:
diff
changeset
|
67 * Preparation stage: |
89c75331f9b6
8134963: [Newtest] New stress test for changing the coarseness level of G1 remembered set
dfazunen
parents:
diff
changeset
|
68 * Fill out ~90% of the heap with objects, each object is an object array. |
89c75331f9b6
8134963: [Newtest] New stress test for changing the coarseness level of G1 remembered set
dfazunen
parents:
diff
changeset
|
69 * If we want to allocate K objects per region, we calculate N to meet: |
89c75331f9b6
8134963: [Newtest] New stress test for changing the coarseness level of G1 remembered set
dfazunen
parents:
diff
changeset
|
70 * sizeOf(Object[N]) ~= regionSize / K |
89c75331f9b6
8134963: [Newtest] New stress test for changing the coarseness level of G1 remembered set
dfazunen
parents:
diff
changeset
|
71 * Stress stage: |
89c75331f9b6
8134963: [Newtest] New stress test for changing the coarseness level of G1 remembered set
dfazunen
parents:
diff
changeset
|
72 * No more allocation, so no more GC. |
89c75331f9b6
8134963: [Newtest] New stress test for changing the coarseness level of G1 remembered set
dfazunen
parents:
diff
changeset
|
73 * We will perform a number of iterations. On each iteration i, |
89c75331f9b6
8134963: [Newtest] New stress test for changing the coarseness level of G1 remembered set
dfazunen
parents:
diff
changeset
|
74 * for each pair of regions Rx and Ry we will set c[i] references |
89c75331f9b6
8134963: [Newtest] New stress test for changing the coarseness level of G1 remembered set
dfazunen
parents:
diff
changeset
|
75 * from Rx to Ry. If c[i] less than c[i-1] at the end of iteration |
89c75331f9b6
8134963: [Newtest] New stress test for changing the coarseness level of G1 remembered set
dfazunen
parents:
diff
changeset
|
76 * concurrent mark cycle will be initiated (to recalculate remembered sets). |
89c75331f9b6
8134963: [Newtest] New stress test for changing the coarseness level of G1 remembered set
dfazunen
parents:
diff
changeset
|
77 * As the result RSet will be growing up and down, up and down many times. |
89c75331f9b6
8134963: [Newtest] New stress test for changing the coarseness level of G1 remembered set
dfazunen
parents:
diff
changeset
|
78 * |
89c75331f9b6
8134963: [Newtest] New stress test for changing the coarseness level of G1 remembered set
dfazunen
parents:
diff
changeset
|
79 * The test expects: no crash and no timeouts. |
89c75331f9b6
8134963: [Newtest] New stress test for changing the coarseness level of G1 remembered set
dfazunen
parents:
diff
changeset
|
80 * |
89c75331f9b6
8134963: [Newtest] New stress test for changing the coarseness level of G1 remembered set
dfazunen
parents:
diff
changeset
|
81 * Test Parameters: |
89c75331f9b6
8134963: [Newtest] New stress test for changing the coarseness level of G1 remembered set
dfazunen
parents:
diff
changeset
|
82 * args[0] - number of objects per Heap Region (1 - means humongous) |
89c75331f9b6
8134963: [Newtest] New stress test for changing the coarseness level of G1 remembered set
dfazunen
parents:
diff
changeset
|
83 * args[1] - number of regions to refresh to provoke GC at the end of cycle. |
89c75331f9b6
8134963: [Newtest] New stress test for changing the coarseness level of G1 remembered set
dfazunen
parents:
diff
changeset
|
84 * (0 - means no GC, i.e. no reading from RSet) |
89c75331f9b6
8134963: [Newtest] New stress test for changing the coarseness level of G1 remembered set
dfazunen
parents:
diff
changeset
|
85 * args[2] - timeout in seconds (to stop execution to avoid jtreg timeout) |
89c75331f9b6
8134963: [Newtest] New stress test for changing the coarseness level of G1 remembered set
dfazunen
parents:
diff
changeset
|
86 */ |
89c75331f9b6
8134963: [Newtest] New stress test for changing the coarseness level of G1 remembered set
dfazunen
parents:
diff
changeset
|
87 public class TestStressRSetCoarsening { |
89c75331f9b6
8134963: [Newtest] New stress test for changing the coarseness level of G1 remembered set
dfazunen
parents:
diff
changeset
|
88 |
89c75331f9b6
8134963: [Newtest] New stress test for changing the coarseness level of G1 remembered set
dfazunen
parents:
diff
changeset
|
89 public static void main(String... args) throws InterruptedException { |
89c75331f9b6
8134963: [Newtest] New stress test for changing the coarseness level of G1 remembered set
dfazunen
parents:
diff
changeset
|
90 if (args.length != 3) { |
89c75331f9b6
8134963: [Newtest] New stress test for changing the coarseness level of G1 remembered set
dfazunen
parents:
diff
changeset
|
91 throw new IllegalArgumentException("Wrong number of arguments " + args.length); |
89c75331f9b6
8134963: [Newtest] New stress test for changing the coarseness level of G1 remembered set
dfazunen
parents:
diff
changeset
|
92 } |
89c75331f9b6
8134963: [Newtest] New stress test for changing the coarseness level of G1 remembered set
dfazunen
parents:
diff
changeset
|
93 int objectsPerRegion = Integer.parseInt(args[0]); // 1 means humongous |
89c75331f9b6
8134963: [Newtest] New stress test for changing the coarseness level of G1 remembered set
dfazunen
parents:
diff
changeset
|
94 int regsToRefresh = Integer.parseInt(args[1]); // 0 means no regions to refresh at the end of cycle |
89c75331f9b6
8134963: [Newtest] New stress test for changing the coarseness level of G1 remembered set
dfazunen
parents:
diff
changeset
|
95 int timeout = Integer.parseInt(args[2]); // in seconds, test should stop working eariler |
89c75331f9b6
8134963: [Newtest] New stress test for changing the coarseness level of G1 remembered set
dfazunen
parents:
diff
changeset
|
96 new TestStressRSetCoarsening(objectsPerRegion, regsToRefresh, timeout).go(); |
89c75331f9b6
8134963: [Newtest] New stress test for changing the coarseness level of G1 remembered set
dfazunen
parents:
diff
changeset
|
97 } |
89c75331f9b6
8134963: [Newtest] New stress test for changing the coarseness level of G1 remembered set
dfazunen
parents:
diff
changeset
|
98 |
89c75331f9b6
8134963: [Newtest] New stress test for changing the coarseness level of G1 remembered set
dfazunen
parents:
diff
changeset
|
99 private static final long KB = 1024; |
89c75331f9b6
8134963: [Newtest] New stress test for changing the coarseness level of G1 remembered set
dfazunen
parents:
diff
changeset
|
100 private static final long MB = 1024 * KB; |
89c75331f9b6
8134963: [Newtest] New stress test for changing the coarseness level of G1 remembered set
dfazunen
parents:
diff
changeset
|
101 |
89c75331f9b6
8134963: [Newtest] New stress test for changing the coarseness level of G1 remembered set
dfazunen
parents:
diff
changeset
|
102 private static final WhiteBox WB = WhiteBox.getWhiteBox(); |
89c75331f9b6
8134963: [Newtest] New stress test for changing the coarseness level of G1 remembered set
dfazunen
parents:
diff
changeset
|
103 |
89c75331f9b6
8134963: [Newtest] New stress test for changing the coarseness level of G1 remembered set
dfazunen
parents:
diff
changeset
|
104 public final Object[][] storage; |
89c75331f9b6
8134963: [Newtest] New stress test for changing the coarseness level of G1 remembered set
dfazunen
parents:
diff
changeset
|
105 |
89c75331f9b6
8134963: [Newtest] New stress test for changing the coarseness level of G1 remembered set
dfazunen
parents:
diff
changeset
|
106 /** |
89c75331f9b6
8134963: [Newtest] New stress test for changing the coarseness level of G1 remembered set
dfazunen
parents:
diff
changeset
|
107 * Number of objects per region. This is a test parameter. |
89c75331f9b6
8134963: [Newtest] New stress test for changing the coarseness level of G1 remembered set
dfazunen
parents:
diff
changeset
|
108 */ |
89c75331f9b6
8134963: [Newtest] New stress test for changing the coarseness level of G1 remembered set
dfazunen
parents:
diff
changeset
|
109 public final int K; |
89c75331f9b6
8134963: [Newtest] New stress test for changing the coarseness level of G1 remembered set
dfazunen
parents:
diff
changeset
|
110 |
89c75331f9b6
8134963: [Newtest] New stress test for changing the coarseness level of G1 remembered set
dfazunen
parents:
diff
changeset
|
111 /** |
89c75331f9b6
8134963: [Newtest] New stress test for changing the coarseness level of G1 remembered set
dfazunen
parents:
diff
changeset
|
112 * Length of object array: sizeOf(Object[N]) ~= regionSize / K |
89c75331f9b6
8134963: [Newtest] New stress test for changing the coarseness level of G1 remembered set
dfazunen
parents:
diff
changeset
|
113 * N will be calculated as function of K. |
89c75331f9b6
8134963: [Newtest] New stress test for changing the coarseness level of G1 remembered set
dfazunen
parents:
diff
changeset
|
114 */ |
89c75331f9b6
8134963: [Newtest] New stress test for changing the coarseness level of G1 remembered set
dfazunen
parents:
diff
changeset
|
115 public final int N; |
89c75331f9b6
8134963: [Newtest] New stress test for changing the coarseness level of G1 remembered set
dfazunen
parents:
diff
changeset
|
116 |
89c75331f9b6
8134963: [Newtest] New stress test for changing the coarseness level of G1 remembered set
dfazunen
parents:
diff
changeset
|
117 /** |
89c75331f9b6
8134963: [Newtest] New stress test for changing the coarseness level of G1 remembered set
dfazunen
parents:
diff
changeset
|
118 * How many regions involved into testing. |
89c75331f9b6
8134963: [Newtest] New stress test for changing the coarseness level of G1 remembered set
dfazunen
parents:
diff
changeset
|
119 * Will be calculated as heapFractionToAllocate * freeRegionCount. |
89c75331f9b6
8134963: [Newtest] New stress test for changing the coarseness level of G1 remembered set
dfazunen
parents:
diff
changeset
|
120 */ |
89c75331f9b6
8134963: [Newtest] New stress test for changing the coarseness level of G1 remembered set
dfazunen
parents:
diff
changeset
|
121 public final int regionCount; |
89c75331f9b6
8134963: [Newtest] New stress test for changing the coarseness level of G1 remembered set
dfazunen
parents:
diff
changeset
|
122 |
89c75331f9b6
8134963: [Newtest] New stress test for changing the coarseness level of G1 remembered set
dfazunen
parents:
diff
changeset
|
123 /** |
89c75331f9b6
8134963: [Newtest] New stress test for changing the coarseness level of G1 remembered set
dfazunen
parents:
diff
changeset
|
124 * How much heap to use. |
89c75331f9b6
8134963: [Newtest] New stress test for changing the coarseness level of G1 remembered set
dfazunen
parents:
diff
changeset
|
125 */ |
89c75331f9b6
8134963: [Newtest] New stress test for changing the coarseness level of G1 remembered set
dfazunen
parents:
diff
changeset
|
126 public final float heapFractionToAllocate = 0.9f; |
89c75331f9b6
8134963: [Newtest] New stress test for changing the coarseness level of G1 remembered set
dfazunen
parents:
diff
changeset
|
127 |
89c75331f9b6
8134963: [Newtest] New stress test for changing the coarseness level of G1 remembered set
dfazunen
parents:
diff
changeset
|
128 /** |
89c75331f9b6
8134963: [Newtest] New stress test for changing the coarseness level of G1 remembered set
dfazunen
parents:
diff
changeset
|
129 * How many regions to be refreshed at the end of cycle. |
89c75331f9b6
8134963: [Newtest] New stress test for changing the coarseness level of G1 remembered set
dfazunen
parents:
diff
changeset
|
130 * This is a test parameter. |
89c75331f9b6
8134963: [Newtest] New stress test for changing the coarseness level of G1 remembered set
dfazunen
parents:
diff
changeset
|
131 */ |
89c75331f9b6
8134963: [Newtest] New stress test for changing the coarseness level of G1 remembered set
dfazunen
parents:
diff
changeset
|
132 public final int regsToRefresh; |
89c75331f9b6
8134963: [Newtest] New stress test for changing the coarseness level of G1 remembered set
dfazunen
parents:
diff
changeset
|
133 |
89c75331f9b6
8134963: [Newtest] New stress test for changing the coarseness level of G1 remembered set
dfazunen
parents:
diff
changeset
|
134 /** |
89c75331f9b6
8134963: [Newtest] New stress test for changing the coarseness level of G1 remembered set
dfazunen
parents:
diff
changeset
|
135 * Initial time. |
89c75331f9b6
8134963: [Newtest] New stress test for changing the coarseness level of G1 remembered set
dfazunen
parents:
diff
changeset
|
136 */ |
89c75331f9b6
8134963: [Newtest] New stress test for changing the coarseness level of G1 remembered set
dfazunen
parents:
diff
changeset
|
137 public final long start; |
89c75331f9b6
8134963: [Newtest] New stress test for changing the coarseness level of G1 remembered set
dfazunen
parents:
diff
changeset
|
138 |
89c75331f9b6
8134963: [Newtest] New stress test for changing the coarseness level of G1 remembered set
dfazunen
parents:
diff
changeset
|
139 /** |
89c75331f9b6
8134963: [Newtest] New stress test for changing the coarseness level of G1 remembered set
dfazunen
parents:
diff
changeset
|
140 * Time when the test should stop working. |
89c75331f9b6
8134963: [Newtest] New stress test for changing the coarseness level of G1 remembered set
dfazunen
parents:
diff
changeset
|
141 */ |
89c75331f9b6
8134963: [Newtest] New stress test for changing the coarseness level of G1 remembered set
dfazunen
parents:
diff
changeset
|
142 public final long finishAt; |
89c75331f9b6
8134963: [Newtest] New stress test for changing the coarseness level of G1 remembered set
dfazunen
parents:
diff
changeset
|
143 |
89c75331f9b6
8134963: [Newtest] New stress test for changing the coarseness level of G1 remembered set
dfazunen
parents:
diff
changeset
|
144 /** |
89c75331f9b6
8134963: [Newtest] New stress test for changing the coarseness level of G1 remembered set
dfazunen
parents:
diff
changeset
|
145 * Does pre-calculation and allocate necessary objects. |
89c75331f9b6
8134963: [Newtest] New stress test for changing the coarseness level of G1 remembered set
dfazunen
parents:
diff
changeset
|
146 * |
89c75331f9b6
8134963: [Newtest] New stress test for changing the coarseness level of G1 remembered set
dfazunen
parents:
diff
changeset
|
147 * @param objPerRegions how many objects per G1 heap region |
89c75331f9b6
8134963: [Newtest] New stress test for changing the coarseness level of G1 remembered set
dfazunen
parents:
diff
changeset
|
148 */ |
89c75331f9b6
8134963: [Newtest] New stress test for changing the coarseness level of G1 remembered set
dfazunen
parents:
diff
changeset
|
149 TestStressRSetCoarsening(int objPerRegions, int regsToRefresh, int timeout) { |
89c75331f9b6
8134963: [Newtest] New stress test for changing the coarseness level of G1 remembered set
dfazunen
parents:
diff
changeset
|
150 this.K = objPerRegions; |
89c75331f9b6
8134963: [Newtest] New stress test for changing the coarseness level of G1 remembered set
dfazunen
parents:
diff
changeset
|
151 this.regsToRefresh = regsToRefresh; |
89c75331f9b6
8134963: [Newtest] New stress test for changing the coarseness level of G1 remembered set
dfazunen
parents:
diff
changeset
|
152 this.start = System.currentTimeMillis(); |
89c75331f9b6
8134963: [Newtest] New stress test for changing the coarseness level of G1 remembered set
dfazunen
parents:
diff
changeset
|
153 this.finishAt = start + timeout * 900; // 10% ahead of jtreg timeout |
89c75331f9b6
8134963: [Newtest] New stress test for changing the coarseness level of G1 remembered set
dfazunen
parents:
diff
changeset
|
154 |
89c75331f9b6
8134963: [Newtest] New stress test for changing the coarseness level of G1 remembered set
dfazunen
parents:
diff
changeset
|
155 long regionSize = WB.g1RegionSize(); |
89c75331f9b6
8134963: [Newtest] New stress test for changing the coarseness level of G1 remembered set
dfazunen
parents:
diff
changeset
|
156 |
89c75331f9b6
8134963: [Newtest] New stress test for changing the coarseness level of G1 remembered set
dfazunen
parents:
diff
changeset
|
157 // How many free regions |
89c75331f9b6
8134963: [Newtest] New stress test for changing the coarseness level of G1 remembered set
dfazunen
parents:
diff
changeset
|
158 Runtime rt = Runtime.getRuntime(); |
89c75331f9b6
8134963: [Newtest] New stress test for changing the coarseness level of G1 remembered set
dfazunen
parents:
diff
changeset
|
159 long used = rt.totalMemory() - rt.freeMemory(); |
89c75331f9b6
8134963: [Newtest] New stress test for changing the coarseness level of G1 remembered set
dfazunen
parents:
diff
changeset
|
160 long totalFree = rt.maxMemory() - used; |
89c75331f9b6
8134963: [Newtest] New stress test for changing the coarseness level of G1 remembered set
dfazunen
parents:
diff
changeset
|
161 regionCount = (int) ((totalFree / regionSize) * heapFractionToAllocate); |
89c75331f9b6
8134963: [Newtest] New stress test for changing the coarseness level of G1 remembered set
dfazunen
parents:
diff
changeset
|
162 long toAllocate = regionCount * regionSize; |
89c75331f9b6
8134963: [Newtest] New stress test for changing the coarseness level of G1 remembered set
dfazunen
parents:
diff
changeset
|
163 System.out.println("%% Test parameters"); |
89c75331f9b6
8134963: [Newtest] New stress test for changing the coarseness level of G1 remembered set
dfazunen
parents:
diff
changeset
|
164 System.out.println("%% Objects per region : " + K); |
89c75331f9b6
8134963: [Newtest] New stress test for changing the coarseness level of G1 remembered set
dfazunen
parents:
diff
changeset
|
165 System.out.println("%% Heap fraction to allocate : " + (int) (heapFractionToAllocate * 100) + "%"); |
89c75331f9b6
8134963: [Newtest] New stress test for changing the coarseness level of G1 remembered set
dfazunen
parents:
diff
changeset
|
166 System.out.println("%% Regions to refresh to provoke GC: " + regsToRefresh); |
89c75331f9b6
8134963: [Newtest] New stress test for changing the coarseness level of G1 remembered set
dfazunen
parents:
diff
changeset
|
167 |
89c75331f9b6
8134963: [Newtest] New stress test for changing the coarseness level of G1 remembered set
dfazunen
parents:
diff
changeset
|
168 System.out.println("%% Memory"); |
89c75331f9b6
8134963: [Newtest] New stress test for changing the coarseness level of G1 remembered set
dfazunen
parents:
diff
changeset
|
169 System.out.println("%% used : " + used / MB + "M"); |
89c75331f9b6
8134963: [Newtest] New stress test for changing the coarseness level of G1 remembered set
dfazunen
parents:
diff
changeset
|
170 System.out.println("%% available : " + totalFree / MB + "M"); |
89c75331f9b6
8134963: [Newtest] New stress test for changing the coarseness level of G1 remembered set
dfazunen
parents:
diff
changeset
|
171 System.out.println("%% to allocate : " + toAllocate / MB + "M"); |
89c75331f9b6
8134963: [Newtest] New stress test for changing the coarseness level of G1 remembered set
dfazunen
parents:
diff
changeset
|
172 System.out.println("%% (in regs) : " + regionCount); |
89c75331f9b6
8134963: [Newtest] New stress test for changing the coarseness level of G1 remembered set
dfazunen
parents:
diff
changeset
|
173 System.out.println("%% G1 Region Size: " + regionSize / MB + "M"); |
89c75331f9b6
8134963: [Newtest] New stress test for changing the coarseness level of G1 remembered set
dfazunen
parents:
diff
changeset
|
174 |
89c75331f9b6
8134963: [Newtest] New stress test for changing the coarseness level of G1 remembered set
dfazunen
parents:
diff
changeset
|
175 int refSize = WB.getHeapOopSize(); |
89c75331f9b6
8134963: [Newtest] New stress test for changing the coarseness level of G1 remembered set
dfazunen
parents:
diff
changeset
|
176 |
89c75331f9b6
8134963: [Newtest] New stress test for changing the coarseness level of G1 remembered set
dfazunen
parents:
diff
changeset
|
177 // Calculate N: K*sizeOf(Object[N]) ~= regionSize |
89c75331f9b6
8134963: [Newtest] New stress test for changing the coarseness level of G1 remembered set
dfazunen
parents:
diff
changeset
|
178 // sizeOf(Object[N]) ~= (N+4)*refSize |
89c75331f9b6
8134963: [Newtest] New stress test for changing the coarseness level of G1 remembered set
dfazunen
parents:
diff
changeset
|
179 // ==> |
89c75331f9b6
8134963: [Newtest] New stress test for changing the coarseness level of G1 remembered set
dfazunen
parents:
diff
changeset
|
180 // N = regionSize / K / refSize - 4; |
89c75331f9b6
8134963: [Newtest] New stress test for changing the coarseness level of G1 remembered set
dfazunen
parents:
diff
changeset
|
181 N = (int) ((regionSize / K) / refSize) - 5; |
89c75331f9b6
8134963: [Newtest] New stress test for changing the coarseness level of G1 remembered set
dfazunen
parents:
diff
changeset
|
182 |
89c75331f9b6
8134963: [Newtest] New stress test for changing the coarseness level of G1 remembered set
dfazunen
parents:
diff
changeset
|
183 /* |
89c75331f9b6
8134963: [Newtest] New stress test for changing the coarseness level of G1 remembered set
dfazunen
parents:
diff
changeset
|
184 * -------------- |
89c75331f9b6
8134963: [Newtest] New stress test for changing the coarseness level of G1 remembered set
dfazunen
parents:
diff
changeset
|
185 * region0 storage[0] = new Object[N] |
89c75331f9b6
8134963: [Newtest] New stress test for changing the coarseness level of G1 remembered set
dfazunen
parents:
diff
changeset
|
186 * ... |
89c75331f9b6
8134963: [Newtest] New stress test for changing the coarseness level of G1 remembered set
dfazunen
parents:
diff
changeset
|
187 * storage[K-1] = new Object[N] |
89c75331f9b6
8134963: [Newtest] New stress test for changing the coarseness level of G1 remembered set
dfazunen
parents:
diff
changeset
|
188 * --------------- |
89c75331f9b6
8134963: [Newtest] New stress test for changing the coarseness level of G1 remembered set
dfazunen
parents:
diff
changeset
|
189 * region1 storage[K] = new Object[N] |
89c75331f9b6
8134963: [Newtest] New stress test for changing the coarseness level of G1 remembered set
dfazunen
parents:
diff
changeset
|
190 * ... |
89c75331f9b6
8134963: [Newtest] New stress test for changing the coarseness level of G1 remembered set
dfazunen
parents:
diff
changeset
|
191 * storage[2*K - 1] = new Object[N] |
89c75331f9b6
8134963: [Newtest] New stress test for changing the coarseness level of G1 remembered set
dfazunen
parents:
diff
changeset
|
192 * -------------- |
89c75331f9b6
8134963: [Newtest] New stress test for changing the coarseness level of G1 remembered set
dfazunen
parents:
diff
changeset
|
193 * ... |
89c75331f9b6
8134963: [Newtest] New stress test for changing the coarseness level of G1 remembered set
dfazunen
parents:
diff
changeset
|
194 * -------------- |
89c75331f9b6
8134963: [Newtest] New stress test for changing the coarseness level of G1 remembered set
dfazunen
parents:
diff
changeset
|
195 * regionX storage[X*K] = new Object[N] |
89c75331f9b6
8134963: [Newtest] New stress test for changing the coarseness level of G1 remembered set
dfazunen
parents:
diff
changeset
|
196 * ... |
89c75331f9b6
8134963: [Newtest] New stress test for changing the coarseness level of G1 remembered set
dfazunen
parents:
diff
changeset
|
197 * storage[(X+1)*K -1] = new Object[N] |
89c75331f9b6
8134963: [Newtest] New stress test for changing the coarseness level of G1 remembered set
dfazunen
parents:
diff
changeset
|
198 * where X = HeapFraction * TotalRegions |
89c75331f9b6
8134963: [Newtest] New stress test for changing the coarseness level of G1 remembered set
dfazunen
parents:
diff
changeset
|
199 * ------------- |
89c75331f9b6
8134963: [Newtest] New stress test for changing the coarseness level of G1 remembered set
dfazunen
parents:
diff
changeset
|
200 */ |
89c75331f9b6
8134963: [Newtest] New stress test for changing the coarseness level of G1 remembered set
dfazunen
parents:
diff
changeset
|
201 System.out.println("%% Objects"); |
89c75331f9b6
8134963: [Newtest] New stress test for changing the coarseness level of G1 remembered set
dfazunen
parents:
diff
changeset
|
202 System.out.println("%% N (array length) : " + N); |
89c75331f9b6
8134963: [Newtest] New stress test for changing the coarseness level of G1 remembered set
dfazunen
parents:
diff
changeset
|
203 System.out.println("%% K (objects in regions): " + K); |
89c75331f9b6
8134963: [Newtest] New stress test for changing the coarseness level of G1 remembered set
dfazunen
parents:
diff
changeset
|
204 System.out.println("%% Reference size : " + refSize); |
89c75331f9b6
8134963: [Newtest] New stress test for changing the coarseness level of G1 remembered set
dfazunen
parents:
diff
changeset
|
205 System.out.println("%% Approximate obj size : " + (N + 2) * refSize / KB + "K)"); |
89c75331f9b6
8134963: [Newtest] New stress test for changing the coarseness level of G1 remembered set
dfazunen
parents:
diff
changeset
|
206 |
89c75331f9b6
8134963: [Newtest] New stress test for changing the coarseness level of G1 remembered set
dfazunen
parents:
diff
changeset
|
207 storage = new Object[regionCount * K][]; |
89c75331f9b6
8134963: [Newtest] New stress test for changing the coarseness level of G1 remembered set
dfazunen
parents:
diff
changeset
|
208 for (int i = 0; i < storage.length; i++) { |
89c75331f9b6
8134963: [Newtest] New stress test for changing the coarseness level of G1 remembered set
dfazunen
parents:
diff
changeset
|
209 storage[i] = new Object[N]; |
89c75331f9b6
8134963: [Newtest] New stress test for changing the coarseness level of G1 remembered set
dfazunen
parents:
diff
changeset
|
210 } |
89c75331f9b6
8134963: [Newtest] New stress test for changing the coarseness level of G1 remembered set
dfazunen
parents:
diff
changeset
|
211 } |
89c75331f9b6
8134963: [Newtest] New stress test for changing the coarseness level of G1 remembered set
dfazunen
parents:
diff
changeset
|
212 |
89c75331f9b6
8134963: [Newtest] New stress test for changing the coarseness level of G1 remembered set
dfazunen
parents:
diff
changeset
|
213 public void go() throws InterruptedException { |
89c75331f9b6
8134963: [Newtest] New stress test for changing the coarseness level of G1 remembered set
dfazunen
parents:
diff
changeset
|
214 // threshold for sparce -> fine |
89c75331f9b6
8134963: [Newtest] New stress test for changing the coarseness level of G1 remembered set
dfazunen
parents:
diff
changeset
|
215 final int FINE = WB.getIntxVMFlag("G1RSetSparseRegionEntries").intValue(); |
89c75331f9b6
8134963: [Newtest] New stress test for changing the coarseness level of G1 remembered set
dfazunen
parents:
diff
changeset
|
216 |
89c75331f9b6
8134963: [Newtest] New stress test for changing the coarseness level of G1 remembered set
dfazunen
parents:
diff
changeset
|
217 // threshold for fine -> coarse |
89c75331f9b6
8134963: [Newtest] New stress test for changing the coarseness level of G1 remembered set
dfazunen
parents:
diff
changeset
|
218 final int COARSE = WB.getIntxVMFlag("G1RSetRegionEntries").intValue(); |
89c75331f9b6
8134963: [Newtest] New stress test for changing the coarseness level of G1 remembered set
dfazunen
parents:
diff
changeset
|
219 |
89c75331f9b6
8134963: [Newtest] New stress test for changing the coarseness level of G1 remembered set
dfazunen
parents:
diff
changeset
|
220 // regToRegRefCounts - array of reference counts from region to region |
89c75331f9b6
8134963: [Newtest] New stress test for changing the coarseness level of G1 remembered set
dfazunen
parents:
diff
changeset
|
221 // at the the end of iteration. |
89c75331f9b6
8134963: [Newtest] New stress test for changing the coarseness level of G1 remembered set
dfazunen
parents:
diff
changeset
|
222 // The number of test iterations is array length - 1. |
89c75331f9b6
8134963: [Newtest] New stress test for changing the coarseness level of G1 remembered set
dfazunen
parents:
diff
changeset
|
223 // If c[i] > c[i-1] then during the iteration i more references will |
89c75331f9b6
8134963: [Newtest] New stress test for changing the coarseness level of G1 remembered set
dfazunen
parents:
diff
changeset
|
224 // be created. |
89c75331f9b6
8134963: [Newtest] New stress test for changing the coarseness level of G1 remembered set
dfazunen
parents:
diff
changeset
|
225 // If c[i] < c[i-1] then some referenes will be cleaned. |
89c75331f9b6
8134963: [Newtest] New stress test for changing the coarseness level of G1 remembered set
dfazunen
parents:
diff
changeset
|
226 int[] regToRegRefCounts = {0, FINE / 2, 0, FINE, (FINE + COARSE) / 2, 0, |
89c75331f9b6
8134963: [Newtest] New stress test for changing the coarseness level of G1 remembered set
dfazunen
parents:
diff
changeset
|
227 COARSE, COARSE + 10, FINE + 1, FINE / 2, 0}; |
89c75331f9b6
8134963: [Newtest] New stress test for changing the coarseness level of G1 remembered set
dfazunen
parents:
diff
changeset
|
228 |
89c75331f9b6
8134963: [Newtest] New stress test for changing the coarseness level of G1 remembered set
dfazunen
parents:
diff
changeset
|
229 // For progress tracking |
89c75331f9b6
8134963: [Newtest] New stress test for changing the coarseness level of G1 remembered set
dfazunen
parents:
diff
changeset
|
230 int[] progress = new int[regToRegRefCounts.length]; |
89c75331f9b6
8134963: [Newtest] New stress test for changing the coarseness level of G1 remembered set
dfazunen
parents:
diff
changeset
|
231 progress[0] = 0; |
89c75331f9b6
8134963: [Newtest] New stress test for changing the coarseness level of G1 remembered set
dfazunen
parents:
diff
changeset
|
232 for (int i = 1; i < regToRegRefCounts.length; i++) { |
89c75331f9b6
8134963: [Newtest] New stress test for changing the coarseness level of G1 remembered set
dfazunen
parents:
diff
changeset
|
233 progress[i] = progress[i - 1] + Math.abs(regToRegRefCounts[i] - regToRegRefCounts[i - 1]); |
89c75331f9b6
8134963: [Newtest] New stress test for changing the coarseness level of G1 remembered set
dfazunen
parents:
diff
changeset
|
234 } |
89c75331f9b6
8134963: [Newtest] New stress test for changing the coarseness level of G1 remembered set
dfazunen
parents:
diff
changeset
|
235 try { |
89c75331f9b6
8134963: [Newtest] New stress test for changing the coarseness level of G1 remembered set
dfazunen
parents:
diff
changeset
|
236 for (int i = 1; i < regToRegRefCounts.length; i++) { |
89c75331f9b6
8134963: [Newtest] New stress test for changing the coarseness level of G1 remembered set
dfazunen
parents:
diff
changeset
|
237 int pre = regToRegRefCounts[i - 1]; |
89c75331f9b6
8134963: [Newtest] New stress test for changing the coarseness level of G1 remembered set
dfazunen
parents:
diff
changeset
|
238 int cur = regToRegRefCounts[i]; |
89c75331f9b6
8134963: [Newtest] New stress test for changing the coarseness level of G1 remembered set
dfazunen
parents:
diff
changeset
|
239 float prog = ((float) progress[i - 1] / progress[progress.length - 1]); |
89c75331f9b6
8134963: [Newtest] New stress test for changing the coarseness level of G1 remembered set
dfazunen
parents:
diff
changeset
|
240 |
89c75331f9b6
8134963: [Newtest] New stress test for changing the coarseness level of G1 remembered set
dfazunen
parents:
diff
changeset
|
241 System.out.println("%% step " + i |
89c75331f9b6
8134963: [Newtest] New stress test for changing the coarseness level of G1 remembered set
dfazunen
parents:
diff
changeset
|
242 + " out of " + (regToRegRefCounts.length - 1) |
89c75331f9b6
8134963: [Newtest] New stress test for changing the coarseness level of G1 remembered set
dfazunen
parents:
diff
changeset
|
243 + " (~" + (int) (100 * prog) + "% done)"); |
89c75331f9b6
8134963: [Newtest] New stress test for changing the coarseness level of G1 remembered set
dfazunen
parents:
diff
changeset
|
244 System.out.println("%% " + pre + " --> " + cur); |
89c75331f9b6
8134963: [Newtest] New stress test for changing the coarseness level of G1 remembered set
dfazunen
parents:
diff
changeset
|
245 for (int to = 0; to < regionCount; to++) { |
89c75331f9b6
8134963: [Newtest] New stress test for changing the coarseness level of G1 remembered set
dfazunen
parents:
diff
changeset
|
246 // Select a celebrity object that we will install references to. |
89c75331f9b6
8134963: [Newtest] New stress test for changing the coarseness level of G1 remembered set
dfazunen
parents:
diff
changeset
|
247 // The celebrity will be referred from all other regions. |
89c75331f9b6
8134963: [Newtest] New stress test for changing the coarseness level of G1 remembered set
dfazunen
parents:
diff
changeset
|
248 // If the number of references after should be less than they |
89c75331f9b6
8134963: [Newtest] New stress test for changing the coarseness level of G1 remembered set
dfazunen
parents:
diff
changeset
|
249 // were before, select NULL. |
89c75331f9b6
8134963: [Newtest] New stress test for changing the coarseness level of G1 remembered set
dfazunen
parents:
diff
changeset
|
250 Object celebrity = cur > pre ? storage[to * K] : null; |
89c75331f9b6
8134963: [Newtest] New stress test for changing the coarseness level of G1 remembered set
dfazunen
parents:
diff
changeset
|
251 for (int from = 0; from < regionCount; from++) { |
89c75331f9b6
8134963: [Newtest] New stress test for changing the coarseness level of G1 remembered set
dfazunen
parents:
diff
changeset
|
252 if (to == from) { |
89c75331f9b6
8134963: [Newtest] New stress test for changing the coarseness level of G1 remembered set
dfazunen
parents:
diff
changeset
|
253 continue; // no need to refer to itself |
89c75331f9b6
8134963: [Newtest] New stress test for changing the coarseness level of G1 remembered set
dfazunen
parents:
diff
changeset
|
254 } |
89c75331f9b6
8134963: [Newtest] New stress test for changing the coarseness level of G1 remembered set
dfazunen
parents:
diff
changeset
|
255 |
89c75331f9b6
8134963: [Newtest] New stress test for changing the coarseness level of G1 remembered set
dfazunen
parents:
diff
changeset
|
256 int step = cur > pre ? +1 : -1; |
89c75331f9b6
8134963: [Newtest] New stress test for changing the coarseness level of G1 remembered set
dfazunen
parents:
diff
changeset
|
257 for (int rn = pre; rn != cur; rn += step) { |
89c75331f9b6
8134963: [Newtest] New stress test for changing the coarseness level of G1 remembered set
dfazunen
parents:
diff
changeset
|
258 storage[getY(to, from, rn)][getX(to, from, rn)] = celebrity; |
89c75331f9b6
8134963: [Newtest] New stress test for changing the coarseness level of G1 remembered set
dfazunen
parents:
diff
changeset
|
259 if (System.currentTimeMillis() > finishAt) { |
89c75331f9b6
8134963: [Newtest] New stress test for changing the coarseness level of G1 remembered set
dfazunen
parents:
diff
changeset
|
260 throw new TimeoutException(); |
89c75331f9b6
8134963: [Newtest] New stress test for changing the coarseness level of G1 remembered set
dfazunen
parents:
diff
changeset
|
261 } |
89c75331f9b6
8134963: [Newtest] New stress test for changing the coarseness level of G1 remembered set
dfazunen
parents:
diff
changeset
|
262 } |
89c75331f9b6
8134963: [Newtest] New stress test for changing the coarseness level of G1 remembered set
dfazunen
parents:
diff
changeset
|
263 } |
89c75331f9b6
8134963: [Newtest] New stress test for changing the coarseness level of G1 remembered set
dfazunen
parents:
diff
changeset
|
264 } |
89c75331f9b6
8134963: [Newtest] New stress test for changing the coarseness level of G1 remembered set
dfazunen
parents:
diff
changeset
|
265 if (pre > cur) { |
89c75331f9b6
8134963: [Newtest] New stress test for changing the coarseness level of G1 remembered set
dfazunen
parents:
diff
changeset
|
266 // Number of references went down. |
89c75331f9b6
8134963: [Newtest] New stress test for changing the coarseness level of G1 remembered set
dfazunen
parents:
diff
changeset
|
267 // Need to provoke recalculation of RSet. |
89c75331f9b6
8134963: [Newtest] New stress test for changing the coarseness level of G1 remembered set
dfazunen
parents:
diff
changeset
|
268 WB.g1StartConcMarkCycle(); |
89c75331f9b6
8134963: [Newtest] New stress test for changing the coarseness level of G1 remembered set
dfazunen
parents:
diff
changeset
|
269 while (WB.g1InConcurrentMark()) { |
89c75331f9b6
8134963: [Newtest] New stress test for changing the coarseness level of G1 remembered set
dfazunen
parents:
diff
changeset
|
270 Thread.sleep(1); |
89c75331f9b6
8134963: [Newtest] New stress test for changing the coarseness level of G1 remembered set
dfazunen
parents:
diff
changeset
|
271 } |
89c75331f9b6
8134963: [Newtest] New stress test for changing the coarseness level of G1 remembered set
dfazunen
parents:
diff
changeset
|
272 } |
89c75331f9b6
8134963: [Newtest] New stress test for changing the coarseness level of G1 remembered set
dfazunen
parents:
diff
changeset
|
273 |
89c75331f9b6
8134963: [Newtest] New stress test for changing the coarseness level of G1 remembered set
dfazunen
parents:
diff
changeset
|
274 // To force the use of rememebered set entries we need to provoke a GC. |
89c75331f9b6
8134963: [Newtest] New stress test for changing the coarseness level of G1 remembered set
dfazunen
parents:
diff
changeset
|
275 // To induce some fragmentation, and some mixed GCs, we need |
89c75331f9b6
8134963: [Newtest] New stress test for changing the coarseness level of G1 remembered set
dfazunen
parents:
diff
changeset
|
276 // to make a few objects unreachable. |
89c75331f9b6
8134963: [Newtest] New stress test for changing the coarseness level of G1 remembered set
dfazunen
parents:
diff
changeset
|
277 for (int toClean = i * regsToRefresh; toClean < (i + 1) * regsToRefresh; toClean++) { |
89c75331f9b6
8134963: [Newtest] New stress test for changing the coarseness level of G1 remembered set
dfazunen
parents:
diff
changeset
|
278 int to = toClean % regionCount; |
89c75331f9b6
8134963: [Newtest] New stress test for changing the coarseness level of G1 remembered set
dfazunen
parents:
diff
changeset
|
279 // Need to remove all references from all regions to the region 'to' |
89c75331f9b6
8134963: [Newtest] New stress test for changing the coarseness level of G1 remembered set
dfazunen
parents:
diff
changeset
|
280 for (int from = 0; from < regionCount; from++) { |
89c75331f9b6
8134963: [Newtest] New stress test for changing the coarseness level of G1 remembered set
dfazunen
parents:
diff
changeset
|
281 if (to == from) { |
89c75331f9b6
8134963: [Newtest] New stress test for changing the coarseness level of G1 remembered set
dfazunen
parents:
diff
changeset
|
282 continue; // no need to refer to itself |
89c75331f9b6
8134963: [Newtest] New stress test for changing the coarseness level of G1 remembered set
dfazunen
parents:
diff
changeset
|
283 } |
89c75331f9b6
8134963: [Newtest] New stress test for changing the coarseness level of G1 remembered set
dfazunen
parents:
diff
changeset
|
284 for (int rn = 0; rn <= cur; rn++) { |
89c75331f9b6
8134963: [Newtest] New stress test for changing the coarseness level of G1 remembered set
dfazunen
parents:
diff
changeset
|
285 storage[getY(to, from, rn)][getX(to, from, rn)] = null; |
89c75331f9b6
8134963: [Newtest] New stress test for changing the coarseness level of G1 remembered set
dfazunen
parents:
diff
changeset
|
286 } |
89c75331f9b6
8134963: [Newtest] New stress test for changing the coarseness level of G1 remembered set
dfazunen
parents:
diff
changeset
|
287 } |
89c75331f9b6
8134963: [Newtest] New stress test for changing the coarseness level of G1 remembered set
dfazunen
parents:
diff
changeset
|
288 // 'Refresh' storage elements for the region 'to' |
89c75331f9b6
8134963: [Newtest] New stress test for changing the coarseness level of G1 remembered set
dfazunen
parents:
diff
changeset
|
289 // After that loop all 'old' objects in the region 'to' |
89c75331f9b6
8134963: [Newtest] New stress test for changing the coarseness level of G1 remembered set
dfazunen
parents:
diff
changeset
|
290 // should become unreachable. |
89c75331f9b6
8134963: [Newtest] New stress test for changing the coarseness level of G1 remembered set
dfazunen
parents:
diff
changeset
|
291 for (int k = 0; k < K; k++) { |
89c75331f9b6
8134963: [Newtest] New stress test for changing the coarseness level of G1 remembered set
dfazunen
parents:
diff
changeset
|
292 storage[(to * K + k) % storage.length] = new Object[N]; |
89c75331f9b6
8134963: [Newtest] New stress test for changing the coarseness level of G1 remembered set
dfazunen
parents:
diff
changeset
|
293 } |
89c75331f9b6
8134963: [Newtest] New stress test for changing the coarseness level of G1 remembered set
dfazunen
parents:
diff
changeset
|
294 } |
89c75331f9b6
8134963: [Newtest] New stress test for changing the coarseness level of G1 remembered set
dfazunen
parents:
diff
changeset
|
295 } |
89c75331f9b6
8134963: [Newtest] New stress test for changing the coarseness level of G1 remembered set
dfazunen
parents:
diff
changeset
|
296 } catch (TimeoutException e) { |
89c75331f9b6
8134963: [Newtest] New stress test for changing the coarseness level of G1 remembered set
dfazunen
parents:
diff
changeset
|
297 System.out.println("%% TIMEOUT!!!"); |
89c75331f9b6
8134963: [Newtest] New stress test for changing the coarseness level of G1 remembered set
dfazunen
parents:
diff
changeset
|
298 } |
89c75331f9b6
8134963: [Newtest] New stress test for changing the coarseness level of G1 remembered set
dfazunen
parents:
diff
changeset
|
299 long now = System.currentTimeMillis(); |
89c75331f9b6
8134963: [Newtest] New stress test for changing the coarseness level of G1 remembered set
dfazunen
parents:
diff
changeset
|
300 System.out.println("%% Summary"); |
89c75331f9b6
8134963: [Newtest] New stress test for changing the coarseness level of G1 remembered set
dfazunen
parents:
diff
changeset
|
301 System.out.println("%% Time spent : " + ((now - start) / 1000) + " seconds"); |
89c75331f9b6
8134963: [Newtest] New stress test for changing the coarseness level of G1 remembered set
dfazunen
parents:
diff
changeset
|
302 System.out.println("%% Free memory left : " + Runtime.getRuntime().freeMemory() / KB + "K"); |
89c75331f9b6
8134963: [Newtest] New stress test for changing the coarseness level of G1 remembered set
dfazunen
parents:
diff
changeset
|
303 System.out.println("%% Test passed"); |
89c75331f9b6
8134963: [Newtest] New stress test for changing the coarseness level of G1 remembered set
dfazunen
parents:
diff
changeset
|
304 } |
89c75331f9b6
8134963: [Newtest] New stress test for changing the coarseness level of G1 remembered set
dfazunen
parents:
diff
changeset
|
305 |
89c75331f9b6
8134963: [Newtest] New stress test for changing the coarseness level of G1 remembered set
dfazunen
parents:
diff
changeset
|
306 /** |
89c75331f9b6
8134963: [Newtest] New stress test for changing the coarseness level of G1 remembered set
dfazunen
parents:
diff
changeset
|
307 * Returns X index in the Storage of the reference #rn from the region |
89c75331f9b6
8134963: [Newtest] New stress test for changing the coarseness level of G1 remembered set
dfazunen
parents:
diff
changeset
|
308 * 'from' to the region 'to'. |
89c75331f9b6
8134963: [Newtest] New stress test for changing the coarseness level of G1 remembered set
dfazunen
parents:
diff
changeset
|
309 * |
89c75331f9b6
8134963: [Newtest] New stress test for changing the coarseness level of G1 remembered set
dfazunen
parents:
diff
changeset
|
310 * @param to region # to refer to |
89c75331f9b6
8134963: [Newtest] New stress test for changing the coarseness level of G1 remembered set
dfazunen
parents:
diff
changeset
|
311 * @param from region # to refer from |
89c75331f9b6
8134963: [Newtest] New stress test for changing the coarseness level of G1 remembered set
dfazunen
parents:
diff
changeset
|
312 * @param rn number of reference |
89c75331f9b6
8134963: [Newtest] New stress test for changing the coarseness level of G1 remembered set
dfazunen
parents:
diff
changeset
|
313 * |
89c75331f9b6
8134963: [Newtest] New stress test for changing the coarseness level of G1 remembered set
dfazunen
parents:
diff
changeset
|
314 * @return X index in the range: [0 ... N-1] |
89c75331f9b6
8134963: [Newtest] New stress test for changing the coarseness level of G1 remembered set
dfazunen
parents:
diff
changeset
|
315 */ |
89c75331f9b6
8134963: [Newtest] New stress test for changing the coarseness level of G1 remembered set
dfazunen
parents:
diff
changeset
|
316 private int getX(int to, int from, int rn) { |
89c75331f9b6
8134963: [Newtest] New stress test for changing the coarseness level of G1 remembered set
dfazunen
parents:
diff
changeset
|
317 return (rn * regionCount + to) % N; |
89c75331f9b6
8134963: [Newtest] New stress test for changing the coarseness level of G1 remembered set
dfazunen
parents:
diff
changeset
|
318 } |
89c75331f9b6
8134963: [Newtest] New stress test for changing the coarseness level of G1 remembered set
dfazunen
parents:
diff
changeset
|
319 |
89c75331f9b6
8134963: [Newtest] New stress test for changing the coarseness level of G1 remembered set
dfazunen
parents:
diff
changeset
|
320 /** |
89c75331f9b6
8134963: [Newtest] New stress test for changing the coarseness level of G1 remembered set
dfazunen
parents:
diff
changeset
|
321 * Returns Y index in the Storage of the reference #rn from the region |
89c75331f9b6
8134963: [Newtest] New stress test for changing the coarseness level of G1 remembered set
dfazunen
parents:
diff
changeset
|
322 * 'from' to the region 'to'. |
89c75331f9b6
8134963: [Newtest] New stress test for changing the coarseness level of G1 remembered set
dfazunen
parents:
diff
changeset
|
323 * |
89c75331f9b6
8134963: [Newtest] New stress test for changing the coarseness level of G1 remembered set
dfazunen
parents:
diff
changeset
|
324 * @param to region # to refer to |
89c75331f9b6
8134963: [Newtest] New stress test for changing the coarseness level of G1 remembered set
dfazunen
parents:
diff
changeset
|
325 * @param from region # to refer from |
89c75331f9b6
8134963: [Newtest] New stress test for changing the coarseness level of G1 remembered set
dfazunen
parents:
diff
changeset
|
326 * @param rn number of reference |
89c75331f9b6
8134963: [Newtest] New stress test for changing the coarseness level of G1 remembered set
dfazunen
parents:
diff
changeset
|
327 * |
89c75331f9b6
8134963: [Newtest] New stress test for changing the coarseness level of G1 remembered set
dfazunen
parents:
diff
changeset
|
328 * @return Y index in the range: [0 ... K*regionCount -1] |
89c75331f9b6
8134963: [Newtest] New stress test for changing the coarseness level of G1 remembered set
dfazunen
parents:
diff
changeset
|
329 */ |
89c75331f9b6
8134963: [Newtest] New stress test for changing the coarseness level of G1 remembered set
dfazunen
parents:
diff
changeset
|
330 private int getY(int to, int from, int rn) { |
89c75331f9b6
8134963: [Newtest] New stress test for changing the coarseness level of G1 remembered set
dfazunen
parents:
diff
changeset
|
331 return ((rn * regionCount + to) / N + from * K) % (regionCount * K); |
89c75331f9b6
8134963: [Newtest] New stress test for changing the coarseness level of G1 remembered set
dfazunen
parents:
diff
changeset
|
332 } |
89c75331f9b6
8134963: [Newtest] New stress test for changing the coarseness level of G1 remembered set
dfazunen
parents:
diff
changeset
|
333 } |
89c75331f9b6
8134963: [Newtest] New stress test for changing the coarseness level of G1 remembered set
dfazunen
parents:
diff
changeset
|
334 |