--- old/test/compiler/compilercontrol/jcmd/StressAddJcmdBase.java 2016-02-19 19:51:44.000000000 +0300 +++ new/test/compiler/compilercontrol/jcmd/StressAddJcmdBase.java 2016-02-19 19:51:43.000000000 +0300 @@ -32,66 +32,86 @@ import jdk.test.lib.Utils; import pool.PoolHelper; +import java.util.ArrayList; import java.util.List; +import java.util.Random; import java.util.stream.Collectors; -import java.util.stream.Stream; public abstract class StressAddJcmdBase { private static final int DIRECTIVES_AMOUNT = Integer.getInteger( "compiler.compilercontrol.jcmd.StressAddJcmdBase.directivesAmount", - 1000); - private static final int DIRECTIVE_FILES = Integer.getInteger( - "compiler.compilercontrol.jcmd.StressAddJcmdBase.directiveFiles", - 5); + 999); private static final List DESCRIPTORS = new PoolHelper() .getAllMethods().stream() .map(pair -> AbstractTestBase .getValidMethodDescriptor(pair.first)) .collect(Collectors.toList()); + private static final String DIRECTIVE_FILE = "directives.json"; + private static final List VM_OPTIONS = new ArrayList<>(); + private static final Random RANDOM = Utils.getRandomInstance(); + + static { + VM_OPTIONS.add("-XX:+UnlockDiagnosticVMOptions"); + VM_OPTIONS.add("-XX:+LogCompilation"); + VM_OPTIONS.add("-XX:CompilerDirectivesLimit=1000"); + } /** * Performs test */ public void test() { - List commands = prepareCommands(); - Executor executor = new TimeLimitedExecutor(commands); + HugeDirectiveUtil.createHugeFile(DESCRIPTORS, DIRECTIVE_FILE, + DIRECTIVES_AMOUNT); + Executor executor = new TimeLimitedExecutor(); List outputAnalyzers = executor.execute(); outputAnalyzers.get(0).shouldHaveExitValue(0); } /** - * Makes connection to the test VM + * Makes connection to the test VM and performs a diagnostic command * - * @param pid a pid of the VM under test - * @param commands a list of jcmd commands to be executed + * @param pid a pid of the VM under test * @return true if the test should continue invocation of this method */ - protected abstract boolean makeConnection(int pid, List commands); + protected abstract boolean makeConnection(int pid); /** * Finish test executions */ protected void finish() { } - private List prepareCommands() { - String[] files = new String[DIRECTIVE_FILES]; - for (int i = 0; i < DIRECTIVE_FILES; i++) { - files[i] = "directives" + i + ".json"; - HugeDirectiveUtil.createHugeFile(DESCRIPTORS, files[i], - DIRECTIVES_AMOUNT); + protected String nextCommand() { + int i = RANDOM.nextInt(JcmdCommand.values().length); + JcmdCommand jcmdCommand = JcmdCommand.values()[i]; + switch (jcmdCommand) { + case ADD: + return jcmdCommand.command + " " + DIRECTIVE_FILE; + case PRINT: + case CLEAR: + case REMOVE: + return jcmdCommand.command; + default: + throw new Error("TESTBUG: incorrect command: " + jcmdCommand); } - return Stream.of(files) - .map(file -> "Compiler.directives_add " + file) - .collect(Collectors.toList()); } - private class TimeLimitedExecutor extends Executor { - private final List jcmdCommands; + private enum JcmdCommand { + ADD("Compiler.directives_add"), + PRINT("Compiler.directives_print"), + CLEAR("Compiler.directives_clear"), + REMOVE("Compiler.directives_remove"); - public TimeLimitedExecutor(List jcmdCommands) { + public final String command; + + JcmdCommand(String command) { + this.command = command; + } + } + + private class TimeLimitedExecutor extends Executor { + public TimeLimitedExecutor() { /* There are no need to check the state */ - super(true, null, null, jcmdCommands); - this.jcmdCommands = jcmdCommands; + super(true, VM_OPTIONS, null, null); } @Override @@ -99,7 +119,7 @@ TimeLimitedRunner runner = new TimeLimitedRunner( Utils.DEFAULT_TEST_TIMEOUT, Utils.TIMEOUT_FACTOR, - () -> makeConnection(pid, jcmdCommands)); + () -> makeConnection(pid)); try { runner.call(); } catch (Exception e) { --- old/test/compiler/compilercontrol/jcmd/StressAddMultiThreadedTest.java 2016-02-19 19:51:44.000000000 +0300 +++ new/test/compiler/compilercontrol/jcmd/StressAddMultiThreadedTest.java 2016-02-19 19:51:44.000000000 +0300 @@ -27,21 +27,19 @@ * @summary Tests jcmd to be able to add a lot of huge directive files with * parallel executed jcmds until timeout has reached * @library /testlibrary /test/lib /compiler/testlibrary ../share / - * @ignore 8148563 * @build compiler.compilercontrol.jcmd.StressAddMultiThreadedTest * pool.sub.* pool.subpack.* sun.hotspot.WhiteBox * compiler.testlibrary.CompilerUtils * compiler.compilercontrol.share.actions.* * @run main ClassFileInstaller sun.hotspot.WhiteBox * sun.hotspot.WhiteBox$WhiteBoxPermission - * @run main/othervm/timeout=360 compiler.compilercontrol.jcmd.StressAddMultiThreadedTest + * @run main/othervm/timeout=360 -Xmixed compiler.compilercontrol.jcmd.StressAddMultiThreadedTest */ package compiler.compilercontrol.jcmd; import jdk.test.lib.dcmd.PidJcmdExecutor; -import java.util.List; import java.util.concurrent.ArrayBlockingQueue; import java.util.concurrent.BlockingQueue; import java.util.concurrent.ExecutorService; @@ -54,9 +52,9 @@ private final ExecutorService executor; static { - THREADS = Runtime.getRuntime().availableProcessors() - * Integer.getInteger("compiler.compilercontrol.jcmd" + - ".StressAddMultiThreadedTest.threadFactor", 10); + THREADS = (int) (Math.log(Runtime.getRuntime().availableProcessors() + * Integer.getInteger("compiler.compilercontrol.jcmd" + + ".StressAddMultiThreadedTest.threadFactor", 10))); } public StressAddMultiThreadedTest() { @@ -64,6 +62,7 @@ executor = new ThreadPoolExecutor(THREADS, THREADS, 100, TimeUnit.MILLISECONDS, queue, new ThreadPoolExecutor.CallerRunsPolicy()); + System.out.println("INFO: stress threads: " + THREADS); } public static void main(String[] args) { @@ -71,13 +70,11 @@ } @Override - protected boolean makeConnection(int pid, List commands) { - commands.forEach(command -> { - if (!executor.isShutdown()) { - executor.submit(() -> new PidJcmdExecutor(String.valueOf(pid)) - .execute(command)); - } - }); + protected boolean makeConnection(int pid) { + if (!executor.isShutdown()) { + executor.submit(() -> new PidJcmdExecutor(String.valueOf(pid)) + .execute(nextCommand())); + } return !executor.isShutdown(); } @@ -85,7 +82,7 @@ protected void finish() { executor.shutdown(); try { - executor.awaitTermination(10, TimeUnit.SECONDS); + executor.awaitTermination(1, TimeUnit.SECONDS); } catch (InterruptedException e) { throw new Error("Interrupted while awaiting for termination: " + e, e); --- old/test/compiler/compilercontrol/jcmd/StressAddSequentiallyTest.java 2016-02-19 19:51:45.000000000 +0300 +++ new/test/compiler/compilercontrol/jcmd/StressAddSequentiallyTest.java 2016-02-19 19:51:45.000000000 +0300 @@ -32,24 +32,21 @@ * compiler.compilercontrol.share.actions.* * @run main ClassFileInstaller sun.hotspot.WhiteBox * sun.hotspot.WhiteBox$WhiteBoxPermission - * @run main/othervm/timeout=300 compiler.compilercontrol.jcmd.StressAddSequentiallyTest + * @run main/othervm/timeout=300 -Xmixed compiler.compilercontrol.jcmd.StressAddSequentiallyTest */ package compiler.compilercontrol.jcmd; import jdk.test.lib.dcmd.PidJcmdExecutor; -import java.util.List; - public class StressAddSequentiallyTest extends StressAddJcmdBase { public static void main(String[] args) { new StressAddSequentiallyTest().test(); } @Override - protected boolean makeConnection(int pid, List commands) { - commands.forEach(command -> new PidJcmdExecutor(String.valueOf(pid)) - .execute(command)); + protected boolean makeConnection(int pid) { + new PidJcmdExecutor(String.valueOf(pid)).execute(nextCommand()); return true; } }