changeset 285:9c8a067c5565

Runners: make sure minStride is always honored, even in the absence of lagged workers.
author shade
date Thu, 02 Jun 2016 17:00:07 +0300
parents 15032b3442e0
children 0709374cd9bd
files jcstress-core/src/main/java/org/openjdk/jcstress/infra/processors/JCStressTestProcessor.java jcstress-core/src/main/java/org/openjdk/jcstress/infra/runners/StateHolder.java
diffstat 2 files changed, 15 insertions(+), 7 deletions(-) [+]
line wrap: on
line diff
--- a/jcstress-core/src/main/java/org/openjdk/jcstress/infra/processors/JCStressTestProcessor.java	Wed Jun 01 17:05:53 2016 +0300
+++ b/jcstress-core/src/main/java/org/openjdk/jcstress/infra/processors/JCStressTestProcessor.java	Thu Jun 02 17:00:07 2016 +0300
@@ -325,7 +325,6 @@
             pw.println("    " + t + " test;");
         }
         pw.println("    volatile StateHolder<Pair> version;");
-        pw.println("    volatile int epoch;");
         pw.println();
 
         pw.println("    public " + className + "(TestConfig config, TestResultCollector collector, ExecutorService pool) {");
@@ -366,8 +365,7 @@
         if (!isStateItself) {
             pw.println("        test = new " + t + "();");
         }
-        pw.println("        version = new StateHolder<>(false, new Pair[0], " + actorsCount + ", config.spinLoopStyle);");
-        pw.println("        epoch = 0;");
+        pw.println("        version = new StateHolder<>(new Pair[0], " + actorsCount + ", config.spinLoopStyle);");
 
         for (ExecutableElement a : info.getActors()) {
             pw.println("        counter_" + a.getSimpleName() + " = new OpenAddressHashCounter<>();");
@@ -449,7 +447,7 @@
         pw.println("        Pair[] pairs = holder.pairs;");
         pw.println("        int len = pairs.length;");
         pw.println();
-        pw.println("        int newLen = holder.hasLaggedWorkers ? Math.max(config.minStride, Math.min(len * 2, config.maxStride)) : len;");
+        pw.println("        int newLen = holder.updateStride ? Math.max(config.minStride, Math.min(len * 2, config.maxStride)) : len;");
         pw.println();
         pw.println("        Pair[] newPairs = pairs;");
         pw.println("        if (newLen > len) {");
--- a/jcstress-core/src/main/java/org/openjdk/jcstress/infra/runners/StateHolder.java	Wed Jun 01 17:05:53 2016 +0300
+++ b/jcstress-core/src/main/java/org/openjdk/jcstress/infra/runners/StateHolder.java	Thu Jun 02 17:00:07 2016 +0300
@@ -24,7 +24,6 @@
  */
 package org.openjdk.jcstress.infra.runners;
 
-import java.util.concurrent.atomic.AtomicBoolean;
 import java.util.concurrent.atomic.AtomicInteger;
 
 /**
@@ -37,8 +36,19 @@
     public final SpinLoopStyle spinStyle;
     public final AtomicInteger started, ready, finished, consumed;
     public volatile boolean notAllStarted, notAllReady, notAllFinished, notUpdated;
-    public volatile boolean hasLaggedWorkers;
+    public volatile boolean updateStride;
 
+    /**
+     * Initial version
+     */
+    public StateHolder(P[] pairs, int expectedWorkers, SpinLoopStyle spinStyle) {
+        this(false, pairs, expectedWorkers, spinStyle);
+        updateStride = true;
+    }
+
+    /**
+     * Updated version
+     */
     public StateHolder(boolean stopped, P[] pairs, int expectedWorkers, SpinLoopStyle spinStyle) {
         this.stopped = stopped;
         this.pairs = pairs;
@@ -80,7 +90,7 @@
         if (finished.decrementAndGet() == 0) {
             notAllFinished = false;
         }
-        hasLaggedWorkers |= notAllStarted;
+        updateStride |= notAllStarted;
 
         switch (spinStyle) {
             case THREAD_YIELD: