< prev index next >

test/hotspot/jtreg/gc/shenandoah/TestEvilSyncBug.java

Print this page
rev 57639 : 8237038: Shenandoah: Reduce thread pool size in TestEvilSyncBug.java test
   1 /*
   2  * Copyright (c) 2016, 2018, Red Hat, Inc. All rights reserved.
   3  *
   4  * This code is free software; you can redistribute it and/or modify it
   5  * under the terms of the GNU General Public License version 2 only, as
   6  * published by the Free Software Foundation.
   7  *
   8  * This code is distributed in the hope that it will be useful, but WITHOUT
   9  * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
  10  * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
  11  * version 2 for more details (a copy is included in the LICENSE file that
  12  * accompanied this code).
  13  *
  14  * You should have received a copy of the GNU General Public License version
  15  * 2 along with this work; if not, write to the Free Software Foundation,
  16  * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
  17  *
  18  * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
  19  * or visit www.oracle.com if you need additional information or have any
  20  * questions.
  21  *
  22  */


  32  * @run driver/timeout=480 TestEvilSyncBug
  33  */
  34 
  35 import java.util.*;
  36 import java.util.concurrent.*;
  37 import java.util.concurrent.locks.*;
  38 
  39 import jdk.test.lib.process.ProcessTools;
  40 import jdk.test.lib.process.OutputAnalyzer;
  41 
  42 public class TestEvilSyncBug {
  43 
  44     private static final int NUM_RUNS = 100;
  45 
  46     static Thread[] hooks = new MyHook[10000];
  47 
  48     public static void main(String[] args) throws Exception {
  49         if (args.length > 0) {
  50             test();
  51         } else {
  52             ExecutorService pool = Executors.newFixedThreadPool(Runtime.getRuntime().availableProcessors());
  53 


  54             Future<?>[] fs = new Future<?>[NUM_RUNS];
  55 
  56             for (int c = 0; c < NUM_RUNS; c++) {
  57                 Callable<Void> task = () -> {
  58                     ProcessBuilder pb = ProcessTools.createJavaProcessBuilder("-Xms128m",
  59                             "-Xmx128m",
  60                             "-XX:+UnlockExperimentalVMOptions",
  61                             "-XX:+UnlockDiagnosticVMOptions",
  62                             "-XX:+UseShenandoahGC",
  63                             "-XX:ShenandoahGCHeuristics=aggressive",
  64                             "TestEvilSyncBug", "test");
  65                     OutputAnalyzer output = new OutputAnalyzer(pb.start());
  66                     output.shouldHaveExitValue(0);
  67                     return null;
  68                 };
  69                 fs[c] = pool.submit(task);
  70             }
  71 
  72             for (Future<?> f : fs) {
  73                 f.get();


   1 /*
   2  * Copyright (c) 2016, 2020, Red Hat, Inc. All rights reserved.
   3  *
   4  * This code is free software; you can redistribute it and/or modify it
   5  * under the terms of the GNU General Public License version 2 only, as
   6  * published by the Free Software Foundation.
   7  *
   8  * This code is distributed in the hope that it will be useful, but WITHOUT
   9  * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
  10  * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
  11  * version 2 for more details (a copy is included in the LICENSE file that
  12  * accompanied this code).
  13  *
  14  * You should have received a copy of the GNU General Public License version
  15  * 2 along with this work; if not, write to the Free Software Foundation,
  16  * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
  17  *
  18  * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
  19  * or visit www.oracle.com if you need additional information or have any
  20  * questions.
  21  *
  22  */


  32  * @run driver/timeout=480 TestEvilSyncBug
  33  */
  34 
  35 import java.util.*;
  36 import java.util.concurrent.*;
  37 import java.util.concurrent.locks.*;
  38 
  39 import jdk.test.lib.process.ProcessTools;
  40 import jdk.test.lib.process.OutputAnalyzer;
  41 
  42 public class TestEvilSyncBug {
  43 
  44     private static final int NUM_RUNS = 100;
  45 
  46     static Thread[] hooks = new MyHook[10000];
  47 
  48     public static void main(String[] args) throws Exception {
  49         if (args.length > 0) {
  50             test();
  51         } else {
  52             // Use 1/4 of available processors to avoid over provisioning thread pool on many core
  53             // systems.
  54             int numProcessors = Runtime.getRuntime().availableProcessors();
  55             ExecutorService pool = Executors.newFixedThreadPool(Math.max(1, numProcessors / 4));
  56             Future<?>[] fs = new Future<?>[NUM_RUNS];
  57 
  58             for (int c = 0; c < NUM_RUNS; c++) {
  59                 Callable<Void> task = () -> {
  60                     ProcessBuilder pb = ProcessTools.createJavaProcessBuilder("-Xms128m",
  61                             "-Xmx128m",
  62                             "-XX:+UnlockExperimentalVMOptions",
  63                             "-XX:+UnlockDiagnosticVMOptions",
  64                             "-XX:+UseShenandoahGC",
  65                             "-XX:ShenandoahGCHeuristics=aggressive",
  66                             "TestEvilSyncBug", "test");
  67                     OutputAnalyzer output = new OutputAnalyzer(pb.start());
  68                     output.shouldHaveExitValue(0);
  69                     return null;
  70                 };
  71                 fs[c] = pool.submit(task);
  72             }
  73 
  74             for (Future<?> f : fs) {
  75                 f.get();


< prev index next >