Skip to content
Snippets Groups Projects
Commit ad77aa32 authored by Nelson Tavares de Sousa's avatar Nelson Tavares de Sousa
Browse files

Merge remote-tracking branch 'origin/master' into release

Conflicts:
	pom.xml
parents c0e07e1f dd24f919
No related branches found
No related tags found
No related merge requests found
Showing
with 307 additions and 128 deletions
......@@ -23,13 +23,17 @@ public abstract class AbstractInterThreadPipe extends AbstractPipe {
this.signalQueue.offer(signal);
Thread owningThread = cachedTargetStage.getOwningThread();
if (owningThread == null) {
System.err.println("cachedTargetStage: " + cachedTargetStage);
}
if (null != owningThread && isThreadWaiting(owningThread)) { // FIXME remove the null check for performance
owningThread.interrupt();
}
}
protected boolean isThreadWaiting(final Thread thread) {
return thread.getState() == State.WAITING || thread.getState() == State.TIMED_WAITING;
protected final boolean isThreadWaiting(final Thread thread) {
final State state = thread.getState(); // store state in variable for performance reasons
return state == State.WAITING || state == State.TIMED_WAITING;
}
/**
......
......@@ -10,9 +10,8 @@ public abstract class AbstractIntraThreadPipe extends AbstractPipe {
@Override
public final void sendSignal(final ISignal signal) {
// if (this.getTargetPort() != null) { // BETTER remove this check since there are DummyPorts
// getTargetPort is always non-null since the framework adds dummy ports if necessary
this.cachedTargetStage.onSignal(signal, this.getTargetPort());
// }
}
@Override
......
......@@ -12,6 +12,8 @@ import teetime.framework.validation.InvalidPortConnection;
public abstract class AbstractStage extends Stage {
private static final IPipe DUMMY_PORT = new DummyPipe();
private final List<InputPort<?>> inputPortList = new ArrayList<InputPort<?>>();
private final List<OutputPort<?>> outputPortList = new ArrayList<OutputPort<?>>();
......@@ -84,6 +86,7 @@ public abstract class AbstractStage extends Stage {
}
public void onStarting() throws Exception {
this.owningThread = Thread.currentThread();
this.cachedInputPorts = this.inputPortList.toArray(new InputPort<?>[0]);
this.cachedOutputPorts = this.outputPortList.toArray(new OutputPort<?>[0]);
......@@ -97,7 +100,7 @@ public abstract class AbstractStage extends Stage {
for (OutputPort<?> outputPort : this.cachedOutputPorts) {
if (null == outputPort.getPipe()) { // if port is unconnected
this.logger.warn("Unconnected output port: " + outputPort + ". Connecting with a dummy output port.");
outputPort.setPipe(new DummyPipe());
outputPort.setPipe(DUMMY_PORT);
}
}
}
......
......@@ -11,6 +11,12 @@ final class RunnableConsumerStage extends RunnableStage {
private final IdleStrategy idleStrategy;
/**
* Creates a new instance with the {@link YieldStrategy} as default idle strategy.
*
* @param stage
* to execute within an own thread
*/
public RunnableConsumerStage(final Stage stage) {
this(stage, new YieldStrategy());
}
......
......@@ -27,7 +27,8 @@ public abstract class Stage {
@SuppressWarnings("PMD.LoggerIsNotStaticFinal")
protected final Logger logger;
private Thread owningThread;
/** The owning thread of this stage if this stage is directly executed by a {@link RunnableStage}, <code>null</code> otherwise. */
protected Thread owningThread;
protected Stage() {
this.id = this.createId();
......@@ -94,11 +95,12 @@ public abstract class Stage {
return owningThread;
}
public void setOwningThread(final Thread owningThread) {
void setOwningThread(final Thread owningThread) {
this.owningThread = owningThread;
}
protected abstract InputPort<?>[] getInputPorts();
protected abstract boolean isStarted();
}
package teetime.framework.pipe;
import teetime.framework.InputPort;
import teetime.framework.OutputPort;
import teetime.framework.pipe.PipeFactoryRegistry.PipeOrdering;
import teetime.framework.pipe.PipeFactoryRegistry.ThreadCommunication;
public class CommittablePipeFactory implements IPipeFactory {
@Override
public <T> IPipe create(final OutputPort<? extends T> sourcePort, final InputPort<T> targetPort) {
return this.create(sourcePort, targetPort, 1);
}
@Override
public <T> IPipe create(final OutputPort<? extends T> sourcePort, final InputPort<T> targetPort, final int capacity) {
return new CommittablePipe(sourcePort, targetPort);
}
@Override
public ThreadCommunication getThreadCommunication() {
return ThreadCommunication.INTRA;
}
@Override
public PipeOrdering getOrdering() {
return PipeOrdering.STACK_BASED;
}
@Override
public boolean isGrowable() {
return true;
}
}
package util;
import java.io.File;
import java.io.IOException;
import java.util.LinkedList;
import java.util.List;
public class MooBenchStarter {
private final File execDir;
public MooBenchStarter() {
this.execDir = new File("scripts/MooBench-cmd");
System.out.println("execDir: " + this.execDir.getAbsolutePath());
}
public void start(final int runs, final long calls) throws IOException {
final List<String> command = new LinkedList<String>();
command.add("cmd");
command.add("/c");
command.add("start");
command.add("/D");
command.add(this.execDir.getAbsolutePath());
command.add("Load Driver");
command.add("startMooBench.cmd");
command.add(String.valueOf(runs));
command.add(String.valueOf(calls));
new ProcessBuilder(command).start();
}
}
package util.test;
import java.net.InetAddress;
import java.net.UnknownHostException;
import java.util.HashMap;
import java.util.Map;
......@@ -16,10 +18,26 @@ public class PerformanceCheckProfileRepository {
private String currentProfile;
public PerformanceCheckProfileRepository() {
this.currentProfile = System.getProperty("TestProfile", "ChwWork");
String hostName = getHostName();
// this.currentProfile = System.getProperty("TestProfile", "ChwWork");
currentProfile = hostName;
LOGGER.info("Using test profile '" + this.currentProfile + "'");
}
private String getHostName() {
String hostname = "Unknown";
try
{
InetAddress addr = InetAddress.getLocalHost();
hostname = addr.getHostName();
} catch (UnknownHostException ex) {
LOGGER.warn("Hostname can not be resolved");
}
return hostname;
}
public void setCurrentProfile(final String currentProfile) {
this.currentProfile = currentProfile;
}
......
......@@ -2,6 +2,8 @@ package util.test;
import java.util.Map;
import util.test.eval.StatisticsUtil;
public class PerformanceResult {
public long overallDurationInNs;
......
package util;
package util.test.eval;
import java.io.BufferedReader;
import java.io.File;
......@@ -11,8 +11,6 @@ import java.util.Map;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import util.test.StatisticsUtil;
import com.google.common.base.Charsets;
import com.google.common.io.CharSource;
import com.google.common.io.Files;
......
......@@ -13,7 +13,7 @@
* See the License for the specific language governing permissions and
* limitations under the License.
***************************************************************************/
package util.test;
package util.test.eval;
import java.util.ArrayList;
import java.util.Collections;
......@@ -26,6 +26,7 @@ import java.util.concurrent.TimeUnit;
import teetime.util.MathUtil;
import teetime.util.TimestampObject;
import util.test.PerformanceResult;
/**
* @author Christian Wulf
......
......@@ -13,7 +13,7 @@ public class ChwHomeComparisonMethodcallWithPorts extends AbstractProfiledPerfor
@Override
public String getCorrespondingPerformanceProfile() {
return "ChwHome";
return HostName.CHW_HOME.toString();
}
@Override
......@@ -27,12 +27,6 @@ public class ChwHomeComparisonMethodcallWithPorts extends AbstractProfiledPerfor
.get("testWithManyObjects(teetime.examples.experiment01.MethodCallThoughputTimestampAnalysis1Test)");
PerformanceResult test15 = performanceResults
.get("testWithManyObjects(teetime.examples.experiment15.MethodCallThoughputTimestampAnalysis15Test)");
PerformanceResult test16a = performanceResults
.get("testWithManyObjectsAnd1Thread(teetime.examples.experiment16.MethodCallThoughputTimestampAnalysis16Test)");
PerformanceResult test16b = performanceResults
.get("testWithManyObjectsAnd2Threads(teetime.examples.experiment16.MethodCallThoughputTimestampAnalysis16Test)");
PerformanceResult test16c = performanceResults
.get("testWithManyObjectsAnd4Threads(teetime.examples.experiment16.MethodCallThoughputTimestampAnalysis16Test)");
PerformanceResult test19a = performanceResults
.get("testWithManyObjectsAnd1Thread(teetime.examples.experiment19.MethodCallThoughputTimestampAnalysis19Test)");
PerformanceResult test19b = performanceResults
......@@ -69,24 +63,15 @@ public class ChwHomeComparisonMethodcallWithPorts extends AbstractProfiledPerfor
// assertEquals(78, value17, 4.1); // +3
// since 13.12.2014 (incl.)
assertEquals(40, value15, 4.1); // -28
// assertEquals(40, value15, 4.1); // -28
// assertEquals(43, value17, 4.1); // -35
// below results vary too much, possibly due to the OS' scheduler
// assertEquals(RESULT_TESTS_16, (double) test16a.quantiles.get(0.5) / test1.quantiles.get(0.5), 5.1);
// assertEquals(RESULT_TESTS_16, (double) test16b.quantiles.get(0.5) / test1.quantiles.get(0.5), 5.1);
// assertEquals(RESULT_TESTS_16, (double) test16c.quantiles.get(0.5) / test1.quantiles.get(0.5), 5.1);
//
// assertEquals(RESULT_TESTS_19, (double) test19a.quantiles.get(0.5) / test1.quantiles.get(0.5), 5.1);
// assertEquals(RESULT_TESTS_19, (double) test19b.quantiles.get(0.5) / test1.quantiles.get(0.5), 5.1);
// assertEquals(RESULT_TESTS_19, (double) test19c.quantiles.get(0.5) / test1.quantiles.get(0.5), 5.1);
// since 28.12.2014 (incl.)
assertEquals(30, value15, 4.1); // -10
// check speedup
assertEquals(2, (double) test16a.overallDurationInNs / test16b.overallDurationInNs, 0.3);
assertEquals(2.5, (double) test16a.overallDurationInNs / test16c.overallDurationInNs, 0.2);
assertEquals(2, (double) test19a.overallDurationInNs / test19b.overallDurationInNs, 0.3);
assertEquals(2.5, (double) test19a.overallDurationInNs / test19c.overallDurationInNs, 0.3);
assertEquals(2, (double) test19b.overallDurationInNs / test19c.overallDurationInNs, 0.3);
}
}
......@@ -7,10 +7,8 @@ import org.junit.runners.Suite;
import org.junit.runners.Suite.SuiteClasses;
import teetime.examples.experiment01.MethodCallThoughputTimestampAnalysis1Test;
import teetime.examples.experiment09.MethodCallThoughputTimestampAnalysis9Test;
import teetime.examples.experiment10.MethodCallThoughputTimestampAnalysis10Test;
import teetime.examples.experiment09pipeimpls.MethodCallThoughputTimestampAnalysis9Test;
import teetime.examples.experiment11.MethodCallThoughputTimestampAnalysis11Test;
import teetime.examples.experiment14.MethodCallThoughputTimestampAnalysis14Test;
import teetime.examples.experiment15.MethodCallThoughputTimestampAnalysis15Test;
import teetime.examples.experiment16.MethodCallThoughputTimestampAnalysis16Test;
import teetime.examples.experiment19.MethodCallThoughputTimestampAnalysis19Test;
......@@ -21,9 +19,7 @@ import util.test.PerformanceCheckProfileRepository;
@SuiteClasses({
MethodCallThoughputTimestampAnalysis1Test.class,
MethodCallThoughputTimestampAnalysis9Test.class,
MethodCallThoughputTimestampAnalysis10Test.class,
MethodCallThoughputTimestampAnalysis11Test.class,
MethodCallThoughputTimestampAnalysis14Test.class,
MethodCallThoughputTimestampAnalysis15Test.class,
MethodCallThoughputTimestampAnalysis16Test.class,
MethodCallThoughputTimestampAnalysis19Test.class,
......@@ -32,7 +28,7 @@ public class ComparisonMethodcallWithPorts {
@BeforeClass
public static void beforeClass() {
System.setProperty("logback.configurationFile", "src/test/resources/logback.groovy");
// System.setProperty("logback.configurationFile", "src/test/resources/logback.groovy");
PerformanceCheckProfileRepository.INSTANCE.register(ComparisonMethodcallWithPorts.class, new ChwWorkComparisonMethodcallWithPorts());
PerformanceCheckProfileRepository.INSTANCE.register(ComparisonMethodcallWithPorts.class, new ChwHomeComparisonMethodcallWithPorts());
PerformanceCheckProfileRepository.INSTANCE.register(ComparisonMethodcallWithPorts.class, new NieWorkComparisonMethodcallWithPorts());
......
package teetime.examples;
public enum HostName {
CHW_HOME("Nogge-PC"),
CHW_WORK("chw-PC"),
NIE_WORK("nie-PC");
private final String hostName;
HostName(final String hostName) {
this.hostName = hostName;
}
public String getHostName() {
return hostName;
}
@Override
public String toString() {
return getHostName();
}
}
package teetime.examples.experiment01;
import static org.junit.Assert.assertEquals;
import teetime.examples.HostName;
import util.test.AbstractProfiledPerformanceAssertion;
import util.test.PerformanceResult;
import util.test.PerformanceTest;
import util.test.AbstractProfiledPerformanceAssertion;
class ChwHomePerformanceCheck extends AbstractProfiledPerformanceAssertion {
@Override
public String getCorrespondingPerformanceProfile() {
return "ChwHome";
return HostName.CHW_HOME.toString();
}
@Override
......
package teetime.examples.experiment09;
import teetime.examples.experiment01.MethodCallThoughputTimestampAnalysis1Test;
import util.test.MeasurementRepository;
import util.test.PerformanceResult;
import util.test.PerformanceTest;
import util.test.AbstractProfiledPerformanceAssertion;
abstract class AbstractPerformanceCheck extends AbstractProfiledPerformanceAssertion {
protected PerformanceResult test01;
protected PerformanceResult test09;
@Override
public void check() {
String testMethodIdentifier = MeasurementRepository.buildTestMethodIdentifier(MethodCallThoughputTimestampAnalysis1Test.class, "testWithManyObjects");
test01 = PerformanceTest.measurementRepository.performanceResults.get(testMethodIdentifier);
testMethodIdentifier = MeasurementRepository.buildTestMethodIdentifier(MethodCallThoughputTimestampAnalysis9Test.class, "testWithManyObjects");
test09 = PerformanceTest.measurementRepository.performanceResults.get(testMethodIdentifier);
}
}
package teetime.examples.experiment09;
import static org.junit.Assert.assertEquals;
class ChwHomePerformanceCheck extends AbstractPerformanceCheck {
@Override
public String getCorrespondingPerformanceProfile() {
return "ChwHome";
}
@Override
public void check() {
super.check();
double medianSpeedup = (double) test09.quantiles.get(0.5) / test01.quantiles.get(0.5);
System.out.println("medianSpeedup (09): " + medianSpeedup);
// until 25.06.2014 (incl.)
// assertEquals(22, (double) test9.quantiles.get(0.5) / test1.quantiles.get(0.5), 2.1);
// since 26.06.2014 (incl.)
// assertEquals(36, value9, 2.1); // +14
// since 04.07.2014 (incl.)
// assertEquals(42, value9, 2.1); // +6
// since 11.08.2014 (incl.)
// assertEquals(42, value9, 2.1); // +6
// since 31.08.2014 (incl.)
// assertEquals(44, medianSpeedup, 2.1); // +2
// since 04.11.2014 (incl.)
// assertEquals(71, medianSpeedup, 2.1); // +33
// since 05.12.2014 (incl.)
assertEquals(45, medianSpeedup, 2.1); // -26
}
}
package teetime.examples.experiment10;
package teetime.examples.experiment09pipeimpls;
import teetime.examples.experiment01.MethodCallThoughputTimestampAnalysis1Test;
import util.test.AbstractProfiledPerformanceAssertion;
import util.test.MeasurementRepository;
import util.test.PerformanceResult;
import util.test.PerformanceTest;
import util.test.AbstractProfiledPerformanceAssertion;
abstract class AbstractPerformanceCheck extends AbstractProfiledPerformanceAssertion {
protected PerformanceResult test01;
protected PerformanceResult test10;
protected PerformanceResult test09CommittablePipes;
protected PerformanceResult test09SingleElementPipes;
protected PerformanceResult test09OrderedGrowableArrayPipes;
@Override
public void check() {
String testMethodIdentifier = MeasurementRepository.buildTestMethodIdentifier(MethodCallThoughputTimestampAnalysis1Test.class, "testWithManyObjects");
test01 = PerformanceTest.measurementRepository.performanceResults.get(testMethodIdentifier);
testMethodIdentifier = MeasurementRepository.buildTestMethodIdentifier(MethodCallThoughputTimestampAnalysis10Test.class, "testWithManyObjects");
test10 = PerformanceTest.measurementRepository.performanceResults.get(testMethodIdentifier);
testMethodIdentifier = MeasurementRepository.buildTestMethodIdentifier(MethodCallThoughputTimestampAnalysis9Test.class, "testCommittablePipes");
test09CommittablePipes = PerformanceTest.measurementRepository.performanceResults.get(testMethodIdentifier);
testMethodIdentifier = MeasurementRepository.buildTestMethodIdentifier(MethodCallThoughputTimestampAnalysis9Test.class, "testSingleElementPipes");
test09SingleElementPipes = PerformanceTest.measurementRepository.performanceResults.get(testMethodIdentifier);
testMethodIdentifier = MeasurementRepository.buildTestMethodIdentifier(MethodCallThoughputTimestampAnalysis9Test.class, "testOrderedGrowableArrayPipes");
test09OrderedGrowableArrayPipes = PerformanceTest.measurementRepository.performanceResults.get(testMethodIdentifier);
}
}
package teetime.examples.experiment09pipeimpls;
import static org.junit.Assert.assertEquals;
import teetime.examples.HostName;
class ChwHomePerformanceCheck extends AbstractPerformanceCheck {
@Override
public String getCorrespondingPerformanceProfile() {
return HostName.CHW_HOME.toString();
}
@Override
public void check() {
super.check();
checkCommittablePipes();
checkSingleElementPipes();
checkOrderedGrowableArrayPipes();
}
private void checkCommittablePipes() {
double medianSpeedup = (double) test09CommittablePipes.quantiles.get(0.5) / test01.quantiles.get(0.5);
System.out.println("medianSpeedup (09 committable pipes): " + medianSpeedup);
// until 25.06.2014 (incl.)
// assertEquals(22, (double) test9.quantiles.get(0.5) / test1.quantiles.get(0.5), 2.1);
// since 26.06.2014 (incl.)
// assertEquals(36, value9, 2.1); // +14
// since 04.07.2014 (incl.)
// assertEquals(42, value9, 2.1); // +6
// since 11.08.2014 (incl.)
// assertEquals(42, value9, 2.1); // +6
// since 31.08.2014 (incl.)
// assertEquals(44, medianSpeedup, 2.1); // +2
// since 04.11.2014 (incl.)
// assertEquals(71, medianSpeedup, 2.1); // +27
// since 05.12.2014 (incl.)
assertEquals(43, medianSpeedup, 4.1); // -28 (41-56)
}
private void checkSingleElementPipes() {
double medianSpeedup = (double) test09SingleElementPipes.quantiles.get(0.5) / test01.quantiles.get(0.5);
System.out.println("meanSpeedup (09 single element pipes): " + medianSpeedup);
// since 26.06.2014 (incl.)
// assertEquals(26, value10, 2.1); // +14
// // since 04.07.2014 (incl.)
// assertEquals(26, value10, 2.1); // +0
// since 11.08.2014 (incl.)
// assertEquals(47, value10, 2.1); // +21
// since 31.08.2014 (incl.)
// assertEquals(51, medianSpeedup, 3.2); // +4
// since 13.12.2014 (incl.)
// assertEquals(40, medianSpeedup, 3.2); // -11
// since 28.12.2014 (incl.)
assertEquals(26, medianSpeedup, 3.2); // -14
}
private void checkOrderedGrowableArrayPipes() {
double medianSpeedup = (double) test09OrderedGrowableArrayPipes.quantiles.get(0.5) / test01.quantiles.get(0.5);
System.out.println("medianSpeedup (09 ordered growable array pipes): " + medianSpeedup);
// until 25.06.2014 (incl.)
// assertEquals(60, (double) test14.quantiles.get(0.5) / test1.quantiles.get(0.5), 5.1);
// since 26.06.2014 (incl.)
// assertEquals(76, medianSpeedup, 5.1); // +16
// since 04.07.2014 (incl.)
// assertEquals(86, medianSpeedup, 5.1); // +16
// since 11.08.2014 (incl.)
// assertEquals(103, medianSpeedup, 5.1); // +17
// since 31.08.2014 (incl.)
// assertEquals(62, medianSpeedup, 2.1); // -41
// since 04.11.2014 (incl.)
// assertEquals(84, medianSpeedup, 2.1); // +22
// since 05.12.2014 (incl.)
// assertEquals(75, medianSpeedup, 2.1); // -9
// since 13.12.2014 (incl.)
// assertEquals(44, medianSpeedup, 2.1); // -31
// since 28.12.2014 (incl.)
assertEquals(46, medianSpeedup, 2.1); // +2
}
}
package teetime.examples.experiment09;
package teetime.examples.experiment09pipeimpls;
import static org.junit.Assert.assertEquals;
......@@ -13,7 +13,13 @@ class ChwWorkPerformanceCheck extends AbstractPerformanceCheck {
public void check() {
super.check();
double medianSpeedup = (double) test09.quantiles.get(0.5) / test01.quantiles.get(0.5);
checkCommittablePipes();
checkSingleElementPipes();
checkOrderedGrowableArrayPipes();
}
private void checkCommittablePipes() {
double medianSpeedup = (double) test09CommittablePipes.quantiles.get(0.5) / test01.quantiles.get(0.5);
System.out.println("medianSpeedup (09): " + medianSpeedup);
......@@ -30,4 +36,41 @@ class ChwWorkPerformanceCheck extends AbstractPerformanceCheck {
// since 19.12.2014 (incl.)
assertEquals(53, medianSpeedup, 3.1); // -14
}
private void checkSingleElementPipes() {
double medianSpeedup = (double) test09SingleElementPipes.quantiles.get(0.5) / test01.quantiles.get(0.5);
System.out.println("medianSpeedup (09 single element pipes): " + medianSpeedup);
// until 25.06.2014 (incl.)
// assertEquals(14, (double) test10.quantiles.get(0.5) / test1.quantiles.get(0.5), 2.1);
// since 26.06.2014 (incl.)
// assertEquals(26, meanSpeedup, 2.1); // +14
// since 04.07.2014 (incl.)
// assertEquals(26, meanSpeedup, 2.1); // +0
// since 27.08.2014 (incl.)
// assertEquals(56, meanSpeedup, 2.1); // +30
// since 14.10.2014 (incl.)
assertEquals(25, medianSpeedup, 3.1); // -31
}
private void checkOrderedGrowableArrayPipes() {
double medianSpeedup = (double) test09OrderedGrowableArrayPipes.quantiles.get(0.5) / test01.quantiles.get(0.5);
System.out.println("medianSpeedup (09 ordered growable array pipes): " + medianSpeedup);
// until 25.06.2014 (incl.)
// assertEquals(60, (double) test14.quantiles.get(0.5) / test1.quantiles.get(0.5), 5.1);
// since 26.06.2014 (incl.)
// assertEquals(76, medianSpeedup, 5.1); // +16
// since 04.07.2014 (incl.)
// assertEquals(86, medianSpeedup, 5.1); // +16
// since 27.08.2014 (incl.)
// assertEquals(102, medianSpeedup, 5.1); // +16
// since 14.10.2014 (incl.)
// assertEquals(81, medianSpeedup, 5.1); // -21
// since 19.12.2014 (incl.)
assertEquals(56, medianSpeedup, 5.1); // -25
}
}
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment