Skip to content
This repository was archived by the owner on Jun 20, 2025. It is now read-only.

Prepare new release #85

Merged
merged 24 commits into from
Aug 31, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
24 commits
Select commit Hold shift + click to select a range
7e2d1c4
++++ Prepare for next development iteration build: 422 ++++
io-scalecube-ci Aug 13, 2018
a281b94
Reformat code and optimize imports according to Google Checkstyle
Aug 15, 2018
0b19e48
Satisfy codacy
Aug 15, 2018
9a7f88a
Merge pull request #77 from scalecube/use-parent-pom
artem-v Aug 15, 2018
3476785
+ script files
io-scalecube-ci Aug 19, 2018
576665d
Merge pull request #81 from scalecube/travis-ci-cd
artem-v Aug 20, 2018
ee4e585
Fixed utilizing all cores for runForAsync
segabriel Aug 25, 2018
fdc4e6b
Added magic number as a concurrency and changed prefetch
segabriel Aug 28, 2018
1c0b421
Minor
segabriel Aug 29, 2018
2d4910f
Added concurrency param
segabriel Aug 29, 2018
5fb1ef6
Merge pull request #82 from scalecube/feature/issue-57-runForAsync
artem-v Aug 30, 2018
994b045
Added custom metrics entities and warm up
segabriel Aug 30, 2018
a10b1f3
Removed delegated benchmarks metrics
segabriel Aug 30, 2018
4c43329
Merge branch 'develop' into feature/warmpup-phase
segabriel Aug 30, 2018
c9742f7
Merge remote-tracking branch 'origin/feature/warmpup-phase' into feat…
segabriel Aug 30, 2018
d860f98
Fixed checkstyle
segabriel Aug 30, 2018
0b732ef
Changed reporters starting
segabriel Aug 30, 2018
0dbe456
CR changes
artem-v Aug 31, 2018
39587cb
Changed default values for test scenario time and warm up period
artem-v Aug 31, 2018
b3e6546
Fixed codacy issues
artem-v Aug 31, 2018
1f073a0
Merge pull request #83 from scalecube/feature/warmpup-phase
artem-v Aug 31, 2018
d333e56
Set superpom 0.0.11
artem-v Aug 31, 2018
8b46b81
Merge pull request #84 from scalecube/feature/move-onto-parent-011
artem-v Aug 31, 2018
9a9236b
Merge branch 'master' into develop
artem-v Aug 31, 2018
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 3 additions & 10 deletions benchmarks-api/pom.xml
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<project xmlns="http://maven.apache.org/POM/4.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>

<parent>
Expand All @@ -19,10 +21,6 @@
<groupId>io.dropwizard.metrics</groupId>
<artifactId>metrics-core</artifactId>
</dependency>
<dependency>
<groupId>com.codahale.metrics</groupId>
<artifactId>metrics-jvm</artifactId>
</dependency>
<dependency>
<groupId>org.openjdk.jmh</groupId>
<artifactId>jmh-core</artifactId>
Expand All @@ -37,11 +35,6 @@
</dependency>

<!-- Test scope -->
<dependency>
<groupId>org.junit.jupiter</groupId>
<artifactId>junit-jupiter-api</artifactId>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.junit.jupiter</groupId>
<artifactId>junit-jupiter-engine</artifactId>
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
package io.scalecube.benchmarks;

import io.scalecube.benchmarks.metrics.BenchmarksMeter;
import io.scalecube.benchmarks.metrics.BenchmarksTimer;

public interface BenchmarksMetrics {

BenchmarksTimer timer(String name);

BenchmarksMeter meter(String name);
}
Original file line number Diff line number Diff line change
@@ -1,7 +1,5 @@
package io.scalecube.benchmarks;

import com.codahale.metrics.MetricRegistry;

import java.io.File;
import java.nio.file.Paths;
import java.time.Duration;
Expand All @@ -18,29 +16,33 @@
public class BenchmarksSettings {

private static final int N_THREADS = Runtime.getRuntime().availableProcessors();
private static final Duration EXECUTION_TASK_DURATION = Duration.ofSeconds(60);
private static final int CONCURRENCY = 16;
private static final Duration EXECUTION_TASK_DURATION = Duration.ofSeconds(120);
private static final Duration EXECUTION_TASK_INTERVAL = Duration.ZERO;
private static final Duration MINIMAL_INTERVAL = Duration.ofMillis(100);
private static final Duration REPORTER_INTERVAL = Duration.ofSeconds(3);
private static final TimeUnit DURATION_UNIT = TimeUnit.MILLISECONDS;
private static final TimeUnit RATE_UNIT = TimeUnit.SECONDS;
private static final long NUM_OF_ITERATIONS = Long.MAX_VALUE;
private static final Duration WARM_UP_DURATION = Duration.ofSeconds(20);
private static final Duration RAMP_UP_DURATION = Duration.ofSeconds(10);
private static final Duration RAMP_UP_INTERVAL = Duration.ofSeconds(1);
private static final boolean CONSOLE_REPORTER_ENABLED = true;
private static final String ALIAS_PATTERN = "^[.a-zA-Z_0-9]+$";
private static final Predicate<String> ALIAS_PREDICATE = Pattern.compile(ALIAS_PATTERN).asPredicate();
private static final Predicate<String> ALIAS_PREDICATE =
Pattern.compile(ALIAS_PATTERN).asPredicate();

private final int nThreads;
private final int numberThreads;
private final int concurrency;
private final Duration executionTaskDuration;
private final Duration executionTaskInterval;
private final Duration reporterInterval;
private final File csvReporterDirectory;
private final String taskName;
private final TimeUnit durationUnit;
private final TimeUnit rateUnit;
private final MetricRegistry registry;
private final long numOfIterations;
private final Duration warmUpDuration;
private final Duration rampUpDuration;
private final Duration rampUpInterval;
private final boolean consoleReporterEnabled;
Expand All @@ -51,19 +53,25 @@ public class BenchmarksSettings {

private final Map<String, String> options;

/**
* Parses array of command line parameters to override settings that are already defined.
*
* @param args - array of command line arguments.
*/
public static Builder from(String[] args) {
Builder builder = new Builder();
builder.args = args;
return builder;
}

private BenchmarksSettings(Builder builder) {
this.nThreads = builder.nThreads;
this.numberThreads = builder.numberThreads;
this.executionTaskDuration = builder.executionTaskDuration;
this.executionTaskInterval = builder.executionTaskInterval;
this.reporterInterval = builder.reporterInterval;
this.numOfIterations = builder.numOfIterations;
this.consoleReporterEnabled = builder.consoleReporterEnabled;
this.warmUpDuration = builder.warmUpDuration;
this.rampUpDuration = builder.rampUpDuration;
this.rampUpInterval = builder.rampUpInterval;
this.options = builder.options;
Expand All @@ -73,27 +81,28 @@ private BenchmarksSettings(Builder builder) {
this.messagesPerExecutionInterval = builder.messagesPerExecutionInterval;
this.injectors = builder.injectors;
this.messageRate = builder.messageRate;

this.registry = new MetricRegistry();
this.concurrency = builder.concurrency;

StackTraceElement[] stackTrace = Thread.currentThread().getStackTrace();
this.taskName = minifyClassName(stackTrace[stackTrace.length - 1].getClassName());

String time = LocalDateTime.ofInstant(Instant.now(), ZoneOffset.UTC)
.format(DateTimeFormatter.ofPattern("yyyy-MM-dd-HH-mm-ss"));
String time =
LocalDateTime.ofInstant(Instant.now(), ZoneOffset.UTC)
.format(DateTimeFormatter.ofPattern("yyyy-MM-dd-HH-mm-ss"));

String alias = find("alias", taskName);
if (!ALIAS_PREDICATE.test(alias)) {
throw new IllegalArgumentException("alias '" + alias + "' must match pattern " + ALIAS_PATTERN);
throw new IllegalArgumentException(
"alias '" + alias + "' must match pattern " + ALIAS_PATTERN);
}

this.csvReporterDirectory = Paths.get("reports", "benchmarks", alias, time).toFile();
// noinspection ResultOfMethodCallIgnored
this.csvReporterDirectory.mkdirs();
}

public int nThreads() {
return nThreads;
public int numberThreads() {
return numberThreads;
}

public Duration executionTaskDuration() {
Expand All @@ -120,10 +129,6 @@ public String find(String key, String defValue) {
return options.getOrDefault(key, defValue);
}

public MetricRegistry registry() {
return registry;
}

public TimeUnit durationUnit() {
return durationUnit;
}
Expand All @@ -136,6 +141,10 @@ public long numOfIterations() {
return numOfIterations;
}

public Duration warmUpDuration() {
return warmUpDuration;
}

public Duration rampUpDuration() {
return rampUpDuration;
}
Expand Down Expand Up @@ -164,10 +173,15 @@ public int messagesPerExecutionInterval() {
return messagesPerExecutionInterval;
}

public int concurrency() {
return concurrency;
}

@Override
public String toString() {
final StringBuilder sb = new StringBuilder("BenchmarksSettings{");
sb.append("nThreads=").append(nThreads);
sb.append("numberThreads=").append(numberThreads);
sb.append(", concurrency=").append(concurrency);
sb.append(", executionTaskDuration=").append(executionTaskDuration);
sb.append(", executionTaskInterval=").append(executionTaskInterval);
sb.append(", numOfIterations=").append(numOfIterations);
Expand All @@ -176,10 +190,10 @@ public String toString() {
sb.append(", taskName='").append(taskName).append('\'');
sb.append(", durationUnit=").append(durationUnit);
sb.append(", rateUnit=").append(rateUnit);
sb.append(", warmUpDuration=").append(warmUpDuration);
sb.append(", rampUpDuration=").append(rampUpDuration);
sb.append(", rampUpInterval=").append(rampUpInterval);
sb.append(", consoleReporterEnabled=").append(consoleReporterEnabled);
sb.append(", registry=").append(registry);
sb.append(", injectors=").append(injectors);
sb.append(", messageRate=").append(messageRate);
sb.append(", injectorsPerRampUpInterval=").append(injectorsPerRampUpInterval);
Expand All @@ -196,13 +210,14 @@ private String minifyClassName(String className) {
public static class Builder {
private final Map<String, String> options;

private int nThreads = N_THREADS;
private int numberThreads = N_THREADS;
private Duration executionTaskDuration = EXECUTION_TASK_DURATION;
private Duration executionTaskInterval = EXECUTION_TASK_INTERVAL;
private Duration reporterInterval = REPORTER_INTERVAL;
private TimeUnit durationUnit = DURATION_UNIT;
private TimeUnit rateUnit = RATE_UNIT;
private long numOfIterations = NUM_OF_ITERATIONS;
private Duration warmUpDuration = WARM_UP_DURATION;
private Duration rampUpDuration = RAMP_UP_DURATION;
private Duration rampUpInterval = RAMP_UP_INTERVAL; // calculated
private boolean consoleReporterEnabled = CONSOLE_REPORTER_ENABLED;
Expand All @@ -211,20 +226,22 @@ public static class Builder {
private int messageRate; // optional
private int injectorsPerRampUpInterval; // calculated
private int messagesPerExecutionInterval; // calculated
private int concurrency = CONCURRENCY;

private Builder() {
this.options = new HashMap<>();
}

private Builder(Builder that) {
this.options = that.options;
this.nThreads = that.nThreads;
this.numberThreads = that.numberThreads;
this.executionTaskDuration = that.executionTaskDuration;
this.executionTaskInterval = that.executionTaskInterval;
this.reporterInterval = that.reporterInterval;
this.durationUnit = that.durationUnit;
this.rateUnit = that.rateUnit;
this.numOfIterations = that.numOfIterations;
this.warmUpDuration = that.warmUpDuration;
this.rampUpDuration = that.rampUpDuration;
this.rampUpInterval = that.rampUpInterval;
this.consoleReporterEnabled = that.consoleReporterEnabled;
Expand All @@ -233,10 +250,11 @@ private Builder(Builder that) {
this.messagesPerExecutionInterval = that.messagesPerExecutionInterval;
this.injectors = that.injectors;
this.messageRate = that.messageRate;
this.concurrency = that.concurrency;
}

public Builder nThreads(int numThreads) {
this.nThreads = numThreads;
public Builder numberThreads(int numThreads) {
this.numberThreads = numThreads;
return this;
}

Expand Down Expand Up @@ -275,6 +293,11 @@ public Builder numOfIterations(long numOfIterations) {
return this;
}

public Builder warmUpDuration(Duration warmUpDuration) {
this.warmUpDuration = warmUpDuration;
return this;
}

public Builder rampUpDuration(Duration rampUpDuration) {
this.rampUpDuration = rampUpDuration;
return this;
Expand All @@ -300,6 +323,11 @@ public Builder messageRate(int messageRate) {
return this;
}

public Builder concurrency(int concurrency) {
this.concurrency = concurrency;
return this;
}

public BenchmarksSettings build() {
return new BenchmarksSettings(new Builder(this).parseArgs().calculateDynamicParams());
}
Expand All @@ -322,7 +350,8 @@ private Builder calculateDynamicParams() {
}

if (rampUpDuration.compareTo(executionTaskDuration) > 0) {
throw new IllegalArgumentException("'rampUpDuration' must be greater than 'executionTaskDuration'");
throw new IllegalArgumentException(
"'rampUpDuration' must be greater than 'executionTaskDuration'");
}

// calculate rampup parameters
Expand All @@ -342,18 +371,22 @@ private Builder calculateDynamicParams() {
// calculate execution parameters
double injectorRate = (double) messageRate / injectors;
if (injectorRate <= 1) {
// 1. Enough injectors to provide the required rate sending each injector 1 msg per (>= 1 second)
// 1. Enough injectors to provide the required rate sending each injector 1 msg per (>= 1
// second)
this.messagesPerExecutionInterval = 1;
this.executionTaskInterval = Duration.ofMillis((long) (1000 / injectorRate));
} else {
int maxInjectorsLoad = (int) Math.floorDiv(injectors * 1000, MINIMAL_INTERVAL.toMillis());
if (maxInjectorsLoad >= messageRate) {
// 2. Still can provide the required rate sending 1 mesg per tick, execution interval = [MIN_INTERVAL, 1 sec]
// 2. Still can provide the required rate sending 1 mesg per tick, execution interval =
// [MIN_INTERVAL, 1 sec]
this.messagesPerExecutionInterval = 1;
this.executionTaskInterval =
Duration.ofMillis(Math.floorDiv(maxInjectorsLoad, messageRate) * MINIMAL_INTERVAL.toMillis());
Duration.ofMillis(
Math.floorDiv(maxInjectorsLoad, messageRate) * MINIMAL_INTERVAL.toMillis());
} else {
// 3. Have to send multiple messages per execution interval , interval already minimum (MIN_INTERVAL)
// 3. Have to send multiple messages per execution interval , interval already minimum
// (MIN_INTERVAL)
this.messagesPerExecutionInterval = Math.floorDiv(messageRate, maxInjectorsLoad);
this.executionTaskInterval = MINIMAL_INTERVAL;
}
Expand All @@ -369,7 +402,10 @@ private Builder parseArgs() {
String value = keyValue[1];
switch (key) {
case "nThreads":
nThreads(Integer.parseInt(value));
numberThreads(Integer.parseInt(value));
break;
case "concurrency":
concurrency(Integer.parseInt(value));
break;
case "executionTaskDurationInSec":
executionTaskDuration(Duration.ofSeconds(Long.parseLong(value)));
Expand All @@ -383,6 +419,9 @@ private Builder parseArgs() {
case "numOfIterations":
numOfIterations(Long.parseLong(value));
break;
case "warmUpDurationInSec":
warmUpDuration(Duration.ofSeconds(Long.parseLong(value)));
break;
case "rampUpDurationInSec":
rampUpDuration(Duration.ofSeconds(Long.parseLong(value)));
break;
Expand Down
Loading