hotspot/test/gc/ergonomics/TestDynamicNumberOfGCThreads.java
author ctornqvi
Fri, 19 Aug 2016 10:06:30 -0400
changeset 40631 ed82623d7831
parent 38152 80e5da81fb2c
permissions -rw-r--r--
8157957: ClassNotFoundException: jdk.test.lib.JDKToolFinder Reviewed-by: coleenp, gtriantafill, mseledtsov, iignatyev, dholmes, dsamersoff
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
29809
c59a5f161524 8017462: G1: guarantee fails with UseDynamicNumberOfGCThreads
jmasa
parents:
diff changeset
     1
/*
37165
ed7da23aaa16 8149343: assert(rp->num_q() == no_of_gc_workers) failed: sanity
jmasa
parents: 35061
diff changeset
     2
 * Copyright (c) 2015, 2016, Oracle and/or its affiliates. All rights reserved.
29809
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
38152
80e5da81fb2c 8154258: [TESTBUG] Various serviceability tests fail compilation
dsamersoff
parents: 37165
diff changeset
    30
 * @modules java.base/jdk.internal.misc
40631
ed82623d7831 8157957: ClassNotFoundException: jdk.test.lib.JDKToolFinder
ctornqvi
parents: 38152
diff changeset
    31
 * @library /test/lib
29809
c59a5f161524 8017462: G1: guarantee fails with UseDynamicNumberOfGCThreads
jmasa
parents:
diff changeset
    32
 */
c59a5f161524 8017462: G1: guarantee fails with UseDynamicNumberOfGCThreads
jmasa
parents:
diff changeset
    33
40631
ed82623d7831 8157957: ClassNotFoundException: jdk.test.lib.JDKToolFinder
ctornqvi
parents: 38152
diff changeset
    34
import jdk.test.lib.process.OutputAnalyzer;
ed82623d7831 8157957: ClassNotFoundException: jdk.test.lib.JDKToolFinder
ctornqvi
parents: 38152
diff changeset
    35
import jdk.test.lib.process.ProcessTools;
29809
c59a5f161524 8017462: G1: guarantee fails with UseDynamicNumberOfGCThreads
jmasa
parents:
diff changeset
    36
c59a5f161524 8017462: G1: guarantee fails with UseDynamicNumberOfGCThreads
jmasa
parents:
diff changeset
    37
public class TestDynamicNumberOfGCThreads {
c59a5f161524 8017462: G1: guarantee fails with UseDynamicNumberOfGCThreads
jmasa
parents:
diff changeset
    38
  public static void main(String[] args) throws Exception {
c59a5f161524 8017462: G1: guarantee fails with UseDynamicNumberOfGCThreads
jmasa
parents:
diff changeset
    39
c59a5f161524 8017462: G1: guarantee fails with UseDynamicNumberOfGCThreads
jmasa
parents:
diff changeset
    40
    testDynamicNumberOfGCThreads("UseConcMarkSweepGC");
c59a5f161524 8017462: G1: guarantee fails with UseDynamicNumberOfGCThreads
jmasa
parents:
diff changeset
    41
c59a5f161524 8017462: G1: guarantee fails with UseDynamicNumberOfGCThreads
jmasa
parents:
diff changeset
    42
    testDynamicNumberOfGCThreads("UseG1GC");
c59a5f161524 8017462: G1: guarantee fails with UseDynamicNumberOfGCThreads
jmasa
parents:
diff changeset
    43
c59a5f161524 8017462: G1: guarantee fails with UseDynamicNumberOfGCThreads
jmasa
parents:
diff changeset
    44
    testDynamicNumberOfGCThreads("UseParallelGC");
c59a5f161524 8017462: G1: guarantee fails with UseDynamicNumberOfGCThreads
jmasa
parents:
diff changeset
    45
  }
c59a5f161524 8017462: G1: guarantee fails with UseDynamicNumberOfGCThreads
jmasa
parents:
diff changeset
    46
c59a5f161524 8017462: G1: guarantee fails with UseDynamicNumberOfGCThreads
jmasa
parents:
diff changeset
    47
  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
    48
    output.shouldHaveExitValue(0); // test should run succesfully
29809
c59a5f161524 8017462: G1: guarantee fails with UseDynamicNumberOfGCThreads
jmasa
parents:
diff changeset
    49
    output.shouldContain("new_active_workers");
c59a5f161524 8017462: G1: guarantee fails with UseDynamicNumberOfGCThreads
jmasa
parents:
diff changeset
    50
  }
c59a5f161524 8017462: G1: guarantee fails with UseDynamicNumberOfGCThreads
jmasa
parents:
diff changeset
    51
c59a5f161524 8017462: G1: guarantee fails with UseDynamicNumberOfGCThreads
jmasa
parents:
diff changeset
    52
  private static void testDynamicNumberOfGCThreads(String gcFlag) throws Exception {
c59a5f161524 8017462: G1: guarantee fails with UseDynamicNumberOfGCThreads
jmasa
parents:
diff changeset
    53
    // UseDynamicNumberOfGCThreads and TraceDynamicGCThreads enabled
35061
be6025ebffea 8145092: Use Unified Logging for the GC logging
brutisso
parents: 30607
diff changeset
    54
    String[] baseArgs = {"-XX:+" + gcFlag, "-Xmx10M", "-XX:+UseDynamicNumberOfGCThreads", "-Xlog:gc+task=trace", GCTest.class.getName()};
30573
a0bd2a51cdb3 8076995: gc/ergonomics/TestDynamicNumberOfGCThreads.java failed with java.lang.RuntimeException: 'new_active_workers' missing from stdout/stderr
drwhite
parents: 29809
diff changeset
    55
a0bd2a51cdb3 8076995: gc/ergonomics/TestDynamicNumberOfGCThreads.java failed with java.lang.RuntimeException: 'new_active_workers' missing from stdout/stderr
drwhite
parents: 29809
diff changeset
    56
    // 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
    57
    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
    58
    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
    59
a0bd2a51cdb3 8076995: gc/ergonomics/TestDynamicNumberOfGCThreads.java failed with java.lang.RuntimeException: 'new_active_workers' missing from stdout/stderr
drwhite
parents: 29809
diff changeset
    60
    // 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
    61
    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
    62
    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
    63
    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
    64
    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
    65
    pb_enabled = ProcessTools.createJavaProcessBuilder(finalArgs);
29809
c59a5f161524 8017462: G1: guarantee fails with UseDynamicNumberOfGCThreads
jmasa
parents:
diff changeset
    66
    verifyDynamicNumberOfGCThreads(new OutputAnalyzer(pb_enabled.start()));
37165
ed7da23aaa16 8149343: assert(rp->num_q() == no_of_gc_workers) failed: sanity
jmasa
parents: 35061
diff changeset
    67
ed7da23aaa16 8149343: assert(rp->num_q() == no_of_gc_workers) failed: sanity
jmasa
parents: 35061
diff changeset
    68
    // Turn on parallel reference processing
ed7da23aaa16 8149343: assert(rp->num_q() == no_of_gc_workers) failed: sanity
jmasa
parents: 35061
diff changeset
    69
    String[] parRefProcArg = {"-XX:+ParallelRefProcEnabled", "-XX:-ShowMessageBoxOnError"};
ed7da23aaa16 8149343: assert(rp->num_q() == no_of_gc_workers) failed: sanity
jmasa
parents: 35061
diff changeset
    70
    String[] parRefArgs = new String[baseArgs.length + parRefProcArg.length];
ed7da23aaa16 8149343: assert(rp->num_q() == no_of_gc_workers) failed: sanity
jmasa
parents: 35061
diff changeset
    71
    System.arraycopy(parRefProcArg, 0, parRefArgs, 0,                parRefProcArg.length);
ed7da23aaa16 8149343: assert(rp->num_q() == no_of_gc_workers) failed: sanity
jmasa
parents: 35061
diff changeset
    72
    System.arraycopy(baseArgs,  0, parRefArgs, parRefProcArg.length, baseArgs.length);
ed7da23aaa16 8149343: assert(rp->num_q() == no_of_gc_workers) failed: sanity
jmasa
parents: 35061
diff changeset
    73
    pb_enabled = ProcessTools.createJavaProcessBuilder(parRefArgs);
ed7da23aaa16 8149343: assert(rp->num_q() == no_of_gc_workers) failed: sanity
jmasa
parents: 35061
diff changeset
    74
    verifyDynamicNumberOfGCThreads(new OutputAnalyzer(pb_enabled.start()));
29809
c59a5f161524 8017462: G1: guarantee fails with UseDynamicNumberOfGCThreads
jmasa
parents:
diff changeset
    75
  }
c59a5f161524 8017462: G1: guarantee fails with UseDynamicNumberOfGCThreads
jmasa
parents:
diff changeset
    76
c59a5f161524 8017462: G1: guarantee fails with UseDynamicNumberOfGCThreads
jmasa
parents:
diff changeset
    77
  static class GCTest {
c59a5f161524 8017462: G1: guarantee fails with UseDynamicNumberOfGCThreads
jmasa
parents:
diff changeset
    78
    private static byte[] garbage;
c59a5f161524 8017462: G1: guarantee fails with UseDynamicNumberOfGCThreads
jmasa
parents:
diff changeset
    79
    public static void main(String [] args) {
c59a5f161524 8017462: G1: guarantee fails with UseDynamicNumberOfGCThreads
jmasa
parents:
diff changeset
    80
      System.out.println("Creating garbage");
c59a5f161524 8017462: G1: guarantee fails with UseDynamicNumberOfGCThreads
jmasa
parents:
diff changeset
    81
      // create 128MB of garbage. This should result in at least one GC
c59a5f161524 8017462: G1: guarantee fails with UseDynamicNumberOfGCThreads
jmasa
parents:
diff changeset
    82
      for (int i = 0; i < 1024; i++) {
c59a5f161524 8017462: G1: guarantee fails with UseDynamicNumberOfGCThreads
jmasa
parents:
diff changeset
    83
        garbage = new byte[128 * 1024];
c59a5f161524 8017462: G1: guarantee fails with UseDynamicNumberOfGCThreads
jmasa
parents:
diff changeset
    84
      }
c59a5f161524 8017462: G1: guarantee fails with UseDynamicNumberOfGCThreads
jmasa
parents:
diff changeset
    85
      System.out.println("Done");
c59a5f161524 8017462: G1: guarantee fails with UseDynamicNumberOfGCThreads
jmasa
parents:
diff changeset
    86
    }
c59a5f161524 8017462: G1: guarantee fails with UseDynamicNumberOfGCThreads
jmasa
parents:
diff changeset
    87
  }
c59a5f161524 8017462: G1: guarantee fails with UseDynamicNumberOfGCThreads
jmasa
parents:
diff changeset
    88
}