8060724: ant test262parallel in Nashorn spends a significant amount of time after almost all the tests are run

Mon, 20 Oct 2014 14:09:17 +0200

author
hannesw
date
Mon, 20 Oct 2014 14:09:17 +0200
changeset 1062
bf5f28dafa7c
parent 1061
42fc6bc42dae
child 1063
8c51767d534d

8060724: ant test262parallel in Nashorn spends a significant amount of time after almost all the tests are run
Reviewed-by: lagergren, attila, sundar

src/jdk/nashorn/internal/runtime/Context.java file | annotate | diff | comparison | revisions
test/src/jdk/nashorn/internal/test/framework/ParallelTestRunner.java file | annotate | diff | comparison | revisions
     1.1 --- a/src/jdk/nashorn/internal/runtime/Context.java	Mon Oct 20 18:40:42 2014 +0530
     1.2 +++ b/src/jdk/nashorn/internal/runtime/Context.java	Mon Oct 20 14:09:17 2014 +0200
     1.3 @@ -150,6 +150,13 @@
     1.4          private final Context      context;
     1.5          private final ScriptLoader loader;
     1.6          private final CodeSource   codeSource;
     1.7 +        private int usageCount = 0;
     1.8 +        private int bytesDefined = 0;
     1.9 +
    1.10 +        // We reuse this installer for 10 compilations or 200000 defined bytes. Usually the first condition
    1.11 +        // will occur much earlier, the second is a safety measure for very large scripts/functions.
    1.12 +        private final static int MAX_USAGES = 10;
    1.13 +        private final static int MAX_BYTES_DEFINED = 200_000;
    1.14  
    1.15          private ContextCodeInstaller(final Context context, final ScriptLoader loader, final CodeSource codeSource) {
    1.16              this.context    = context;
    1.17 @@ -168,6 +175,8 @@
    1.18  
    1.19          @Override
    1.20          public Class<?> install(final String className, final byte[] bytecode) {
    1.21 +            usageCount++;
    1.22 +            bytesDefined += bytecode.length;
    1.23              final String   binaryName = Compiler.binaryName(className);
    1.24              return loader.installClass(binaryName, bytecode, codeSource);
    1.25          }
    1.26 @@ -225,6 +234,10 @@
    1.27  
    1.28          @Override
    1.29          public CodeInstaller<ScriptEnvironment> withNewLoader() {
    1.30 +            // Reuse this installer if we're within our limits.
    1.31 +            if (usageCount < MAX_USAGES && bytesDefined < MAX_BYTES_DEFINED) {
    1.32 +                return this;
    1.33 +            }
    1.34              return new ContextCodeInstaller(context, context.createNewLoader(), codeSource);
    1.35          }
    1.36  
     2.1 --- a/test/src/jdk/nashorn/internal/test/framework/ParallelTestRunner.java	Mon Oct 20 18:40:42 2014 +0530
     2.2 +++ b/test/src/jdk/nashorn/internal/test/framework/ParallelTestRunner.java	Mon Oct 20 14:09:17 2014 +0200
     2.3 @@ -78,7 +78,8 @@
     2.4      // ParallelTestRunner-specific
     2.5      private static final String    TEST_JS_THREADS     = "test.js.threads";
     2.6      private static final String    TEST_JS_REPORT_FILE = "test.js.report.file";
     2.7 -    private static final int       THREADS             = Integer.getInteger(TEST_JS_THREADS, Runtime.getRuntime().availableProcessors());
     2.8 +    // test262 does a lot of eval's and the JVM hates multithreaded class definition, so lower thread count is usually faster.
     2.9 +    private static final int       THREADS = Integer.getInteger(TEST_JS_THREADS, Runtime.getRuntime().availableProcessors() > 4 ? 4 : 2);
    2.10  
    2.11      private final List<ScriptRunnable> tests    = new ArrayList<>();
    2.12      private final Set<String>      orphans  = new TreeSet<>();

mercurial