Skip to content

Commit 83d97f7

Browse files
committed
Merge branch 'release/1.0.0-RC6'
2 parents 0a4559e + 7f76f0a commit 83d97f7

File tree

60 files changed

+5151
-678
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

60 files changed

+5151
-678
lines changed

.travis.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ matrix:
2323
- jdk: openjdk8
2424
- jdk: openjdk11
2525
env: SKIP_RELEASE=true
26-
- jdk: openjdk12
26+
- jdk: openjdk13
2727
env: SKIP_RELEASE=true
2828

2929
env:

benchmarks/README.md

Lines changed: 47 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,47 @@
1+
## Usage of JMH tasks
2+
3+
Only execute specific benchmark(s) (wildcards are added before and after):
4+
```
5+
../gradlew jmh --include="(BenchmarkPrimary|OtherBench)"
6+
```
7+
If you want to specify the wildcards yourself, you can pass the full regexp:
8+
```
9+
../gradlew jmh --fullInclude=.*MyBenchmark.*
10+
```
11+
12+
Specify extra profilers:
13+
```
14+
../gradlew jmh --profilers="gc,stack"
15+
```
16+
17+
Prominent profilers (for full list call `jmhProfilers` task):
18+
- comp - JitCompilations, tune your iterations
19+
- stack - which methods used most time
20+
- gc - print garbage collection stats
21+
- hs_thr - thread usage
22+
23+
Change report format from JSON to one of [CSV, JSON, NONE, SCSV, TEXT]:
24+
```
25+
./gradlew jmh --format=csv
26+
```
27+
28+
Specify JVM arguments:
29+
```
30+
../gradlew jmh --jvmArgs="-Dtest.cluster=local"
31+
```
32+
33+
Run in verification mode (execute benchmarks with minimum of fork/warmup-/benchmark-iterations):
34+
```
35+
../gradlew jmh --verify=true
36+
```
37+
38+
## Comparing with the baseline
39+
If you wish you run two sets of benchmarks, one for the current change and another one for the "baseline",
40+
there is an additional task `jmhBaseline` that will use the latest release:
41+
```
42+
../gradlew jmh jmhBaseline --include=MyBenchmark
43+
```
44+
45+
## Resources
46+
- http://tutorials.jenkov.com/java-performance/jmh.html (Introduction)
47+
- http://hg.openjdk.java.net/code-tools/jmh/file/tip/jmh-samples/src/main/java/org/openjdk/jmh/samples/ (Samples)

benchmarks/build.gradle

Lines changed: 163 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,163 @@
1+
apply plugin: 'java'
2+
apply plugin: 'idea'
3+
4+
configurations {
5+
current
6+
baseline {
7+
resolutionStrategy.cacheChangingModulesFor 0, 'seconds'
8+
}
9+
}
10+
11+
dependencies {
12+
// Use the baseline to avoid using new APIs in the benchmarks
13+
compileOnly "io.rsocket:rsocket-core:${perfBaselineVersion}"
14+
compileOnly "io.rsocket:rsocket-transport-local:${perfBaselineVersion}"
15+
16+
implementation "org.openjdk.jmh:jmh-core:1.21"
17+
annotationProcessor "org.openjdk.jmh:jmh-generator-annprocess:1.21"
18+
19+
current project(':rsocket-core')
20+
current project(':rsocket-transport-local')
21+
baseline "io.rsocket:rsocket-core:${perfBaselineVersion}", {
22+
changing = true
23+
}
24+
baseline "io.rsocket:rsocket-transport-local:${perfBaselineVersion}", {
25+
changing = true
26+
}
27+
}
28+
29+
task jmhProfilers(type: JavaExec, description:'Lists the available profilers for the jmh task', group: 'Development') {
30+
classpath = sourceSets.main.runtimeClasspath
31+
main = 'org.openjdk.jmh.Main'
32+
args '-lprof'
33+
}
34+
35+
task jmh(type: JmhExecTask, description: 'Executing JMH benchmarks') {
36+
classpath = sourceSets.main.runtimeClasspath + configurations.current
37+
}
38+
39+
task jmhBaseline(type: JmhExecTask, description: 'Executing JMH baseline benchmarks') {
40+
classpath = sourceSets.main.runtimeClasspath + configurations.baseline
41+
}
42+
43+
class JmhExecTask extends JavaExec {
44+
45+
private String include;
46+
private String fullInclude;
47+
private String exclude;
48+
private String format = "json";
49+
private String profilers;
50+
private String jmhJvmArgs;
51+
private String verify;
52+
53+
public JmhExecTask() {
54+
super();
55+
}
56+
57+
public String getInclude() {
58+
return include;
59+
}
60+
61+
@Option(option = "include", description="configure bench inclusion using substring")
62+
public void setInclude(String include) {
63+
this.include = include;
64+
}
65+
66+
public String getFullInclude() {
67+
return fullInclude;
68+
}
69+
70+
@Option(option = "fullInclude", description = "explicitly configure bench inclusion using full JMH style regexp")
71+
public void setFullInclude(String fullInclude) {
72+
this.fullInclude = fullInclude;
73+
}
74+
75+
public String getExclude() {
76+
return exclude;
77+
}
78+
79+
@Option(option = "exclude", description = "explicitly configure bench exclusion using full JMH style regexp")
80+
public void setExclude(String exclude) {
81+
this.exclude = exclude;
82+
}
83+
84+
public String getFormat() {
85+
return format;
86+
}
87+
88+
@Option(option = "format", description = "configure report format")
89+
public void setFormat(String format) {
90+
this.format = format;
91+
}
92+
93+
public String getProfilers() {
94+
return profilers;
95+
}
96+
97+
@Option(option = "profilers", description = "configure jmh profiler(s) to use, comma separated")
98+
public void setProfilers(String profilers) {
99+
this.profilers = profilers;
100+
}
101+
102+
public String getJmhJvmArgs() {
103+
return jmhJvmArgs;
104+
}
105+
106+
@Option(option = "jvmArgs", description = "configure additional JMH JVM arguments, comma separated")
107+
public void setJmhJvmArgs(String jvmArgs) {
108+
this.jmhJvmArgs = jvmArgs;
109+
}
110+
111+
public String getVerify() {
112+
return verify;
113+
}
114+
115+
@Option(option = "verify", description = "run in verify mode")
116+
public void setVerify(String verify) {
117+
this.verify = verify;
118+
}
119+
120+
@TaskAction
121+
public void exec() {
122+
setMain("org.openjdk.jmh.Main");
123+
File resultFile = getProject().file("build/reports/" + getName() + "/result." + format);
124+
125+
if (include != null) {
126+
args(".*" + include + ".*");
127+
}
128+
else if (fullInclude != null) {
129+
args(fullInclude);
130+
}
131+
132+
if(exclude != null) {
133+
args("-e", exclude);
134+
}
135+
if(verify != null) { // execute benchmarks with the minimum amount of execution (only to check if they are working)
136+
System.out.println("Running in verify mode");
137+
args("-f", 1);
138+
args("-wi", 1);
139+
args("-i", 1);
140+
}
141+
args("-foe", "true"); //fail-on-error
142+
args("-v", "NORMAL"); //verbosity [SILENT, NORMAL, EXTRA]
143+
if(profilers != null) {
144+
for (String prof : profilers.split(",")) {
145+
args("-prof", prof);
146+
}
147+
}
148+
args("-jvmArgsPrepend", "-Xmx3072m");
149+
args("-jvmArgsPrepend", "-Xms3072m");
150+
if(jmhJvmArgs != null) {
151+
for(String jvmArg : jmhJvmArgs.split(" ")) {
152+
args("-jvmArgsPrepend", jvmArg);
153+
}
154+
}
155+
args("-rf", format);
156+
args("-rff", resultFile);
157+
158+
System.out.println("\nExecuting JMH with: " + getArgs() + "\n");
159+
resultFile.getParentFile().mkdirs();
160+
161+
super.exec();
162+
}
163+
}

rsocket-core/src/jmh/java/io/rsocket/MaxPerfSubscriber.java renamed to benchmarks/src/main/java/io/rsocket/MaxPerfSubscriber.java

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -5,12 +5,12 @@
55
import org.reactivestreams.Subscription;
66
import reactor.core.CoreSubscriber;
77

8-
public class MaxPerfSubscriber implements CoreSubscriber<Payload> {
8+
public class MaxPerfSubscriber<T> extends CountDownLatch implements CoreSubscriber<T> {
99

10-
final CountDownLatch latch = new CountDownLatch(1);
1110
final Blackhole blackhole;
1211

1312
public MaxPerfSubscriber(Blackhole blackhole) {
13+
super(1);
1414
this.blackhole = blackhole;
1515
}
1616

@@ -20,19 +20,18 @@ public void onSubscribe(Subscription s) {
2020
}
2121

2222
@Override
23-
public void onNext(Payload payload) {
24-
payload.release();
23+
public void onNext(T payload) {
2524
blackhole.consume(payload);
2625
}
2726

2827
@Override
2928
public void onError(Throwable t) {
3029
blackhole.consume(t);
31-
latch.countDown();
30+
countDown();
3231
}
3332

3433
@Override
3534
public void onComplete() {
36-
latch.countDown();
35+
countDown();
3736
}
3837
}
Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
package io.rsocket;
2+
3+
import org.openjdk.jmh.infra.Blackhole;
4+
5+
public class PayloadsMaxPerfSubscriber extends MaxPerfSubscriber<Payload> {
6+
7+
public PayloadsMaxPerfSubscriber(Blackhole blackhole) {
8+
super(blackhole);
9+
}
10+
11+
@Override
12+
public void onNext(Payload payload) {
13+
payload.release();
14+
super.onNext(payload);
15+
}
16+
}
Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
package io.rsocket;
2+
3+
import org.openjdk.jmh.infra.Blackhole;
4+
5+
public class PayloadsPerfSubscriber extends PerfSubscriber<Payload> {
6+
7+
public PayloadsPerfSubscriber(Blackhole blackhole) {
8+
super(blackhole);
9+
}
10+
11+
@Override
12+
public void onNext(Payload payload) {
13+
payload.release();
14+
super.onNext(payload);
15+
}
16+
}

rsocket-core/src/jmh/java/io/rsocket/PerfSubscriber.java renamed to benchmarks/src/main/java/io/rsocket/PerfSubscriber.java

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -5,14 +5,14 @@
55
import org.reactivestreams.Subscription;
66
import reactor.core.CoreSubscriber;
77

8-
public class PerfSubscriber implements CoreSubscriber<Payload> {
8+
public class PerfSubscriber<T> extends CountDownLatch implements CoreSubscriber<T> {
99

10-
final CountDownLatch latch = new CountDownLatch(1);
1110
final Blackhole blackhole;
1211

1312
Subscription s;
1413

1514
public PerfSubscriber(Blackhole blackhole) {
15+
super(1);
1616
this.blackhole = blackhole;
1717
}
1818

@@ -23,20 +23,19 @@ public void onSubscribe(Subscription s) {
2323
}
2424

2525
@Override
26-
public void onNext(Payload payload) {
27-
payload.release();
26+
public void onNext(T payload) {
2827
blackhole.consume(payload);
2928
s.request(1);
3029
}
3130

3231
@Override
3332
public void onError(Throwable t) {
3433
blackhole.consume(t);
35-
latch.countDown();
34+
countDown();
3635
}
3736

3837
@Override
3938
public void onComplete() {
40-
latch.countDown();
39+
countDown();
4140
}
4241
}

0 commit comments

Comments
 (0)