author | drwhite |
Wed, 29 Apr 2015 09:59:51 +0200 | |
changeset 30573 | a0bd2a51cdb3 |
parent 29809 | c59a5f161524 |
child 30607 | 035f5801a92e |
permissions | -rw-r--r-- |
29809
c59a5f161524
8017462: G1: guarantee fails with UseDynamicNumberOfGCThreads
jmasa
parents:
diff
changeset
|
1 |
/* |
c59a5f161524
8017462: G1: guarantee fails with UseDynamicNumberOfGCThreads
jmasa
parents:
diff
changeset
|
2 |
* Copyright (c) 2015, Oracle and/or its affiliates. All rights reserved. |
c59a5f161524
8017462: G1: guarantee fails with UseDynamicNumberOfGCThreads
jmasa
parents:
diff
changeset
|
3 |
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. |
c59a5f161524
8017462: G1: guarantee fails with UseDynamicNumberOfGCThreads
jmasa
parents:
diff
changeset
|
4 |
* |
c59a5f161524
8017462: G1: guarantee fails with UseDynamicNumberOfGCThreads
jmasa
parents:
diff
changeset
|
5 |
* This code is free software; you can redistribute it and/or modify it |
c59a5f161524
8017462: G1: guarantee fails with UseDynamicNumberOfGCThreads
jmasa
parents:
diff
changeset
|
6 |
* under the terms of the GNU General Public License version 2 only, as |
c59a5f161524
8017462: G1: guarantee fails with UseDynamicNumberOfGCThreads
jmasa
parents:
diff
changeset
|
7 |
* published by the Free Software Foundation. |
c59a5f161524
8017462: G1: guarantee fails with UseDynamicNumberOfGCThreads
jmasa
parents:
diff
changeset
|
8 |
* |
c59a5f161524
8017462: G1: guarantee fails with UseDynamicNumberOfGCThreads
jmasa
parents:
diff
changeset
|
9 |
* This code is distributed in the hope that it will be useful, but WITHOUT |
c59a5f161524
8017462: G1: guarantee fails with UseDynamicNumberOfGCThreads
jmasa
parents:
diff
changeset
|
10 |
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or |
c59a5f161524
8017462: G1: guarantee fails with UseDynamicNumberOfGCThreads
jmasa
parents:
diff
changeset
|
11 |
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License |
c59a5f161524
8017462: G1: guarantee fails with UseDynamicNumberOfGCThreads
jmasa
parents:
diff
changeset
|
12 |
* version 2 for more details (a copy is included in the LICENSE file that |
c59a5f161524
8017462: G1: guarantee fails with UseDynamicNumberOfGCThreads
jmasa
parents:
diff
changeset
|
13 |
* accompanied this code). |
c59a5f161524
8017462: G1: guarantee fails with UseDynamicNumberOfGCThreads
jmasa
parents:
diff
changeset
|
14 |
* |
c59a5f161524
8017462: G1: guarantee fails with UseDynamicNumberOfGCThreads
jmasa
parents:
diff
changeset
|
15 |
* You should have received a copy of the GNU General Public License version |
c59a5f161524
8017462: G1: guarantee fails with UseDynamicNumberOfGCThreads
jmasa
parents:
diff
changeset
|
16 |
* 2 along with this work; if not, write to the Free Software Foundation, |
c59a5f161524
8017462: G1: guarantee fails with UseDynamicNumberOfGCThreads
jmasa
parents:
diff
changeset
|
17 |
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. |
c59a5f161524
8017462: G1: guarantee fails with UseDynamicNumberOfGCThreads
jmasa
parents:
diff
changeset
|
18 |
* |
c59a5f161524
8017462: G1: guarantee fails with UseDynamicNumberOfGCThreads
jmasa
parents:
diff
changeset
|
19 |
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA |
c59a5f161524
8017462: G1: guarantee fails with UseDynamicNumberOfGCThreads
jmasa
parents:
diff
changeset
|
20 |
* or visit www.oracle.com if you need additional information or have any |
c59a5f161524
8017462: G1: guarantee fails with UseDynamicNumberOfGCThreads
jmasa
parents:
diff
changeset
|
21 |
* questions. |
c59a5f161524
8017462: G1: guarantee fails with UseDynamicNumberOfGCThreads
jmasa
parents:
diff
changeset
|
22 |
*/ |
c59a5f161524
8017462: G1: guarantee fails with UseDynamicNumberOfGCThreads
jmasa
parents:
diff
changeset
|
23 |
|
c59a5f161524
8017462: G1: guarantee fails with UseDynamicNumberOfGCThreads
jmasa
parents:
diff
changeset
|
24 |
/* |
c59a5f161524
8017462: G1: guarantee fails with UseDynamicNumberOfGCThreads
jmasa
parents:
diff
changeset
|
25 |
* @test TestDynamicNumberOfGCThreads |
c59a5f161524
8017462: G1: guarantee fails with UseDynamicNumberOfGCThreads
jmasa
parents:
diff
changeset
|
26 |
* @bug 8017462 |
c59a5f161524
8017462: G1: guarantee fails with UseDynamicNumberOfGCThreads
jmasa
parents:
diff
changeset
|
27 |
* @summary Ensure that UseDynamicNumberOfGCThreads runs |
c59a5f161524
8017462: G1: guarantee fails with UseDynamicNumberOfGCThreads
jmasa
parents:
diff
changeset
|
28 |
* @requires vm.gc=="null" |
c59a5f161524
8017462: G1: guarantee fails with UseDynamicNumberOfGCThreads
jmasa
parents:
diff
changeset
|
29 |
* @key gc |
c59a5f161524
8017462: G1: guarantee fails with UseDynamicNumberOfGCThreads
jmasa
parents:
diff
changeset
|
30 |
* @library /testlibrary |
c59a5f161524
8017462: G1: guarantee fails with UseDynamicNumberOfGCThreads
jmasa
parents:
diff
changeset
|
31 |
*/ |
c59a5f161524
8017462: G1: guarantee fails with UseDynamicNumberOfGCThreads
jmasa
parents:
diff
changeset
|
32 |
|
c59a5f161524
8017462: G1: guarantee fails with UseDynamicNumberOfGCThreads
jmasa
parents:
diff
changeset
|
33 |
import com.oracle.java.testlibrary.ProcessTools; |
c59a5f161524
8017462: G1: guarantee fails with UseDynamicNumberOfGCThreads
jmasa
parents:
diff
changeset
|
34 |
import com.oracle.java.testlibrary.OutputAnalyzer; |
c59a5f161524
8017462: G1: guarantee fails with UseDynamicNumberOfGCThreads
jmasa
parents:
diff
changeset
|
35 |
|
c59a5f161524
8017462: G1: guarantee fails with UseDynamicNumberOfGCThreads
jmasa
parents:
diff
changeset
|
36 |
public class TestDynamicNumberOfGCThreads { |
c59a5f161524
8017462: G1: guarantee fails with UseDynamicNumberOfGCThreads
jmasa
parents:
diff
changeset
|
37 |
public static void main(String[] args) throws Exception { |
c59a5f161524
8017462: G1: guarantee fails with UseDynamicNumberOfGCThreads
jmasa
parents:
diff
changeset
|
38 |
|
c59a5f161524
8017462: G1: guarantee fails with UseDynamicNumberOfGCThreads
jmasa
parents:
diff
changeset
|
39 |
testDynamicNumberOfGCThreads("UseConcMarkSweepGC"); |
c59a5f161524
8017462: G1: guarantee fails with UseDynamicNumberOfGCThreads
jmasa
parents:
diff
changeset
|
40 |
|
c59a5f161524
8017462: G1: guarantee fails with UseDynamicNumberOfGCThreads
jmasa
parents:
diff
changeset
|
41 |
testDynamicNumberOfGCThreads("UseG1GC"); |
c59a5f161524
8017462: G1: guarantee fails with UseDynamicNumberOfGCThreads
jmasa
parents:
diff
changeset
|
42 |
|
c59a5f161524
8017462: G1: guarantee fails with UseDynamicNumberOfGCThreads
jmasa
parents:
diff
changeset
|
43 |
testDynamicNumberOfGCThreads("UseParallelGC"); |
c59a5f161524
8017462: G1: guarantee fails with UseDynamicNumberOfGCThreads
jmasa
parents:
diff
changeset
|
44 |
} |
c59a5f161524
8017462: G1: guarantee fails with UseDynamicNumberOfGCThreads
jmasa
parents:
diff
changeset
|
45 |
|
c59a5f161524
8017462: G1: guarantee fails with UseDynamicNumberOfGCThreads
jmasa
parents:
diff
changeset
|
46 |
private static void verifyDynamicNumberOfGCThreads(OutputAnalyzer output) { |
30573
a0bd2a51cdb3
8076995: gc/ergonomics/TestDynamicNumberOfGCThreads.java failed with java.lang.RuntimeException: 'new_active_workers' missing from stdout/stderr
drwhite
parents:
29809
diff
changeset
|
47 |
output.shouldHaveExitValue(0); // test should run succesfully |
29809
c59a5f161524
8017462: G1: guarantee fails with UseDynamicNumberOfGCThreads
jmasa
parents:
diff
changeset
|
48 |
output.shouldContain("new_active_workers"); |
c59a5f161524
8017462: G1: guarantee fails with UseDynamicNumberOfGCThreads
jmasa
parents:
diff
changeset
|
49 |
} |
c59a5f161524
8017462: G1: guarantee fails with UseDynamicNumberOfGCThreads
jmasa
parents:
diff
changeset
|
50 |
|
c59a5f161524
8017462: G1: guarantee fails with UseDynamicNumberOfGCThreads
jmasa
parents:
diff
changeset
|
51 |
private static void testDynamicNumberOfGCThreads(String gcFlag) throws Exception { |
c59a5f161524
8017462: G1: guarantee fails with UseDynamicNumberOfGCThreads
jmasa
parents:
diff
changeset
|
52 |
// UseDynamicNumberOfGCThreads and TraceDynamicGCThreads enabled |
30573
a0bd2a51cdb3
8076995: gc/ergonomics/TestDynamicNumberOfGCThreads.java failed with java.lang.RuntimeException: 'new_active_workers' missing from stdout/stderr
drwhite
parents:
29809
diff
changeset
|
53 |
String[] baseArgs = {"-XX:+" + gcFlag, "-Xmx10M", "-XX:+PrintGCDetails", "-XX:+UseDynamicNumberOfGCThreads", "-XX:+TraceDynamicGCThreads", GCTest.class.getName()}; |
a0bd2a51cdb3
8076995: gc/ergonomics/TestDynamicNumberOfGCThreads.java failed with java.lang.RuntimeException: 'new_active_workers' missing from stdout/stderr
drwhite
parents:
29809
diff
changeset
|
54 |
|
a0bd2a51cdb3
8076995: gc/ergonomics/TestDynamicNumberOfGCThreads.java failed with java.lang.RuntimeException: 'new_active_workers' missing from stdout/stderr
drwhite
parents:
29809
diff
changeset
|
55 |
// Base test with gc and +UseDynamicNumberOfGCThreads: |
a0bd2a51cdb3
8076995: gc/ergonomics/TestDynamicNumberOfGCThreads.java failed with java.lang.RuntimeException: 'new_active_workers' missing from stdout/stderr
drwhite
parents:
29809
diff
changeset
|
56 |
ProcessBuilder pb_enabled = ProcessTools.createJavaProcessBuilder(baseArgs); |
a0bd2a51cdb3
8076995: gc/ergonomics/TestDynamicNumberOfGCThreads.java failed with java.lang.RuntimeException: 'new_active_workers' missing from stdout/stderr
drwhite
parents:
29809
diff
changeset
|
57 |
verifyDynamicNumberOfGCThreads(new OutputAnalyzer(pb_enabled.start())); |
a0bd2a51cdb3
8076995: gc/ergonomics/TestDynamicNumberOfGCThreads.java failed with java.lang.RuntimeException: 'new_active_workers' missing from stdout/stderr
drwhite
parents:
29809
diff
changeset
|
58 |
|
a0bd2a51cdb3
8076995: gc/ergonomics/TestDynamicNumberOfGCThreads.java failed with java.lang.RuntimeException: 'new_active_workers' missing from stdout/stderr
drwhite
parents:
29809
diff
changeset
|
59 |
// Ensure it also works on uniprocessors or if user specifies -XX:ParallelGCThreads=1: |
a0bd2a51cdb3
8076995: gc/ergonomics/TestDynamicNumberOfGCThreads.java failed with java.lang.RuntimeException: 'new_active_workers' missing from stdout/stderr
drwhite
parents:
29809
diff
changeset
|
60 |
String[] extraArgs = {"-XX:+UnlockDiagnosticVMOptions", "-XX:+ForceDynamicNumberOfGCThreads", "-XX:ParallelGCThreads=1"}; |
a0bd2a51cdb3
8076995: gc/ergonomics/TestDynamicNumberOfGCThreads.java failed with java.lang.RuntimeException: 'new_active_workers' missing from stdout/stderr
drwhite
parents:
29809
diff
changeset
|
61 |
String[] finalArgs = new String[baseArgs.length + extraArgs.length]; |
a0bd2a51cdb3
8076995: gc/ergonomics/TestDynamicNumberOfGCThreads.java failed with java.lang.RuntimeException: 'new_active_workers' missing from stdout/stderr
drwhite
parents:
29809
diff
changeset
|
62 |
System.arraycopy(extraArgs, 0, finalArgs, 0, extraArgs.length); |
a0bd2a51cdb3
8076995: gc/ergonomics/TestDynamicNumberOfGCThreads.java failed with java.lang.RuntimeException: 'new_active_workers' missing from stdout/stderr
drwhite
parents:
29809
diff
changeset
|
63 |
System.arraycopy(baseArgs, 0, finalArgs, extraArgs.length, baseArgs.length); |
a0bd2a51cdb3
8076995: gc/ergonomics/TestDynamicNumberOfGCThreads.java failed with java.lang.RuntimeException: 'new_active_workers' missing from stdout/stderr
drwhite
parents:
29809
diff
changeset
|
64 |
pb_enabled = ProcessTools.createJavaProcessBuilder(finalArgs); |
29809
c59a5f161524
8017462: G1: guarantee fails with UseDynamicNumberOfGCThreads
jmasa
parents:
diff
changeset
|
65 |
verifyDynamicNumberOfGCThreads(new OutputAnalyzer(pb_enabled.start())); |
c59a5f161524
8017462: G1: guarantee fails with UseDynamicNumberOfGCThreads
jmasa
parents:
diff
changeset
|
66 |
} |
c59a5f161524
8017462: G1: guarantee fails with UseDynamicNumberOfGCThreads
jmasa
parents:
diff
changeset
|
67 |
|
c59a5f161524
8017462: G1: guarantee fails with UseDynamicNumberOfGCThreads
jmasa
parents:
diff
changeset
|
68 |
static class GCTest { |
c59a5f161524
8017462: G1: guarantee fails with UseDynamicNumberOfGCThreads
jmasa
parents:
diff
changeset
|
69 |
private static byte[] garbage; |
c59a5f161524
8017462: G1: guarantee fails with UseDynamicNumberOfGCThreads
jmasa
parents:
diff
changeset
|
70 |
public static void main(String [] args) { |
c59a5f161524
8017462: G1: guarantee fails with UseDynamicNumberOfGCThreads
jmasa
parents:
diff
changeset
|
71 |
System.out.println("Creating garbage"); |
c59a5f161524
8017462: G1: guarantee fails with UseDynamicNumberOfGCThreads
jmasa
parents:
diff
changeset
|
72 |
// create 128MB of garbage. This should result in at least one GC |
c59a5f161524
8017462: G1: guarantee fails with UseDynamicNumberOfGCThreads
jmasa
parents:
diff
changeset
|
73 |
for (int i = 0; i < 1024; i++) { |
c59a5f161524
8017462: G1: guarantee fails with UseDynamicNumberOfGCThreads
jmasa
parents:
diff
changeset
|
74 |
garbage = new byte[128 * 1024]; |
c59a5f161524
8017462: G1: guarantee fails with UseDynamicNumberOfGCThreads
jmasa
parents:
diff
changeset
|
75 |
} |
c59a5f161524
8017462: G1: guarantee fails with UseDynamicNumberOfGCThreads
jmasa
parents:
diff
changeset
|
76 |
System.out.println("Done"); |
c59a5f161524
8017462: G1: guarantee fails with UseDynamicNumberOfGCThreads
jmasa
parents:
diff
changeset
|
77 |
} |
c59a5f161524
8017462: G1: guarantee fails with UseDynamicNumberOfGCThreads
jmasa
parents:
diff
changeset
|
78 |
} |
c59a5f161524
8017462: G1: guarantee fails with UseDynamicNumberOfGCThreads
jmasa
parents:
diff
changeset
|
79 |
} |