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