Skip to content

Commit 9411384

Browse files
committed
Benchmarks setup [2]
1 parent b03f70b commit 9411384

23 files changed

+198
-149
lines changed

.github/workflows/ci-benchmarks.yml

Lines changed: 51 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ on:
33
push:
44

55
jobs:
6-
benchmark:
6+
benchmark-local:
77
runs-on: ${{ matrix.os }}
88
strategy:
99
fail-fast: false
@@ -15,22 +15,62 @@ jobs:
1515

1616
- run: >
1717
./gradlew
18-
FastCsvLocalRequestChannelBenchmark
19-
FastCsvLocalRequestResponseBenchmark
20-
FastCsvLocalRequestStreamBenchmark
21-
--dry-run
18+
LocalRequestResponseBenchmark
19+
LocalRequestStreamBenchmark
20+
LocalRequestChannelBenchmark
21+
-Prsocketbuild.skipBenchmarkTasks=true
22+
--no-daemon
2223
2324
- run: >
2425
./gradlew
25-
FastCsvLocalRequestChannelBenchmark
26-
FastCsvLocalRequestResponseBenchmark
27-
FastCsvLocalRequestStreamBenchmark
26+
LocalRequestResponseBenchmark
27+
LocalRequestStreamBenchmark
28+
LocalRequestChannelBenchmark
2829
--no-parallel
2930
--max-workers=1
31+
--no-daemon
32+
--continue
3033
3134
- if: always() && !cancelled()
3235
uses: actions/upload-artifact@v4
3336
with:
34-
name: benchmark-reports-${{ matrix.os }}
35-
path: "benchmarks/**/build/reports/benchmarks/**/*.csv"
36-
retention-days: 1
37+
name: benchmark-reports-local-${{ matrix.os }}
38+
path: "rsocket-transport-benchmarks/**/build/reports/benchmarks/**/*.csv"
39+
retention-days: 7
40+
41+
benchmark-network:
42+
runs-on: ${{ matrix.os }}
43+
strategy:
44+
fail-fast: false
45+
matrix:
46+
os: [ ubuntu-latest, macos-latest ]
47+
steps:
48+
- uses: actions/checkout@v4
49+
- uses: ./.github/actions/setup-gradle
50+
51+
- run: >
52+
./gradlew
53+
KtorTcpRequestResponseBenchmark
54+
KtorWsRequestResponseBenchmark
55+
NettyTcpRequestResponseBenchmark
56+
NettyQuicRequestResponseBenchmark
57+
-Prsocketbuild.skipBenchmarkTasks=true
58+
--no-daemon
59+
60+
- run: >
61+
./gradlew
62+
KtorTcpRequestResponseBenchmark
63+
KtorWsRequestResponseBenchmark
64+
NettyTcpRequestResponseBenchmark
65+
NettyQuicRequestResponseBenchmark
66+
--no-parallel
67+
--max-workers=1
68+
--no-daemon
69+
--continue
70+
71+
- if: always() && !cancelled()
72+
uses: actions/upload-artifact@v4
73+
with:
74+
name: benchmark-reports-network-${{ matrix.os }}
75+
path: "rsocket-transport-benchmarks/**/build/reports/benchmarks/**/*.csv"
76+
retention-days: 7

benchmarks/rsocket-java/src/jvmMain/kotlin/WsRSocketJavaBenchmark.kt

Lines changed: 0 additions & 26 deletions
This file was deleted.

build-logic/src/main/kotlin/rsocketbuild.multiplatform-benchmarks.gradle.kts

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,10 @@
1414
* limitations under the License.
1515
*/
1616

17+
import gradle.kotlin.dsl.accessors._5e24a5abecdb427308a6c627b6f26b4a.allOpen
18+
import gradle.kotlin.dsl.accessors._5e24a5abecdb427308a6c627b6f26b4a.benchmark
19+
import kotlinx.benchmark.gradle.JvmBenchmarkTarget
20+
1721
plugins {
1822
id("rsocketbuild.multiplatform-base")
1923
kotlin("plugin.allopen")
@@ -23,3 +27,16 @@ plugins {
2327
allOpen {
2428
annotation("org.openjdk.jmh.annotations.State")
2529
}
30+
31+
benchmark {
32+
targets.configureEach {
33+
if (name == "jvm") {
34+
this as JvmBenchmarkTarget
35+
jmhVersion = "1.37"
36+
}
37+
}
38+
}
39+
40+
if (providers.gradleProperty("rsocketbuild.skipBenchmarkTasks").map(String::toBoolean).getOrElse(false)) {
41+
tasks.named { it.endsWith("Benchmark") }.configureEach { onlyIf { false } }
42+
}

build-logic/src/main/kotlin/rsocketbuild/benchmarks.kt

Lines changed: 11 additions & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -19,50 +19,25 @@ package rsocketbuild
1919
import kotlinx.benchmark.gradle.*
2020
import org.gradle.kotlin.dsl.support.*
2121

22-
fun BenchmarksExtension.registerBenchmarks(
22+
fun BenchmarksExtension.registerTransportBenchmarks(
2323
implName: String,
2424
transports: List<String>,
2525
customize: BenchmarkConfiguration.(transport: String) -> Unit = {},
2626
) {
27-
fun register(
28-
operation: String,
29-
transport: String,
30-
format: String,
31-
kind: String,
32-
) {
33-
configurations.register(
34-
listOf(kind, format, transport, operation).joinToString("", transform = String::uppercaseFirstChar)
35-
) {
36-
reportFormat = format
37-
when (kind) {
38-
"fast" -> param("payloadSize", "0")
39-
"full" -> param("payloadSize", "0", "64", "4096")
40-
else -> error("wrong `kind`=$kind")
41-
}
42-
43-
include("${transport.uppercaseFirstChar()}${implName}Benchmark.${operation}Blocking")
44-
include("${transport.uppercaseFirstChar()}${implName}Benchmark.${operation}Parallel")
45-
include("${transport.uppercaseFirstChar()}${implName}Benchmark.${operation}Concurrent")
46-
47-
customize(transport)
48-
}
49-
}
50-
5127
val operations = listOf("requestResponse", "requestStream", "requestChannel")
52-
val formats = listOf("text", "csv", "json")
53-
val kinds = listOf("fast", "full")
5428
transports.forEach { transport ->
5529
operations.forEach { operation ->
56-
formats.forEach { format ->
57-
kinds.forEach { kind ->
58-
register(operation, transport, format, kind)
59-
}
30+
configurations.register(
31+
listOf(transport, operation).joinToString("", transform = String::uppercaseFirstChar)
32+
) {
33+
reportFormat = "csv"
34+
35+
include("${transport.uppercaseFirstChar()}${implName}Benchmark.${operation}Blocking")
36+
include("${transport.uppercaseFirstChar()}${implName}Benchmark.${operation}Parallel")
37+
include("${transport.uppercaseFirstChar()}${implName}Benchmark.${operation}Concurrent")
38+
39+
customize(transport)
6040
}
6141
}
6242
}
6343
}
64-
65-
//if (transport == "local") {
66-
// param("dispatcher", "DEFAULT", "UNCONFINED")
67-
//// param("channels", "S", "M")
68-
//}

gradle/libs.versions.toml

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -17,10 +17,6 @@ bouncycastle = "1.80"
1717

1818
turbine = "1.2.0"
1919

20-
rsocket-java = "1.1.4"
21-
22-
jmh = "1.37"
23-
2420
maven-publish = "0.30.0"
2521

2622
[libraries]
@@ -48,10 +44,6 @@ bouncycastle = { module = "org.bouncycastle:bcpkix-jdk18on", version.ref = "boun
4844

4945
turbine = { module = "app.cash.turbine:turbine", version.ref = "turbine" }
5046

51-
rsocket-java-core = { module = 'io.rsocket:rsocket-core', version.ref = "rsocket-java" }
52-
rsocket-java-transport-local = { module = 'io.rsocket:rsocket-transport-local', version.ref = "rsocket-java" }
53-
rsocket-java-transport-netty = { module = 'io.rsocket:rsocket-transport-netty', version.ref = "rsocket-java" }
54-
5547
kotlin-gradle-plugin = { module = "org.jetbrains.kotlin:kotlin-gradle-plugin", version.ref = "kotlin" }
5648
kotlin-allopen-gradle-plugin = { module = "org.jetbrains.kotlin:kotlin-allopen", version.ref = "kotlin" }
5749
kotlinx-atomicfu-gradle-plugin = { module = "org.jetbrains.kotlinx:atomicfu-gradle-plugin", version.ref = "kotlinx-atomicfu" }

benchmarks/shared/src/commonMain/kotlin/RSocketBenchmark.kt renamed to rsocket-transport-benchmarks/base/src/commonMain/kotlin/RSocketTransportBenchmark.kt

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -14,18 +14,18 @@
1414
* limitations under the License.
1515
*/
1616

17-
package io.rsocket.kotlin.benchmarks
17+
package io.rsocket.kotlin.transport.benchmarks
1818

1919
import kotlinx.coroutines.*
2020
import kotlinx.coroutines.flow.*
2121

22-
const val ITERATION = 5
22+
const val ITERATION = 3
2323
const val ITERATION_DURATION = 3
2424

25-
const val WARMUP = 5
25+
const val WARMUP = 3
2626
const val WARMUP_DURATION = 3
2727

28-
abstract class RSocketBenchmark<Payload : Any, Blackhole : Any> {
28+
abstract class RSocketTransportBenchmark<Payload : Any, Blackhole : Any> {
2929

3030
// payload operations
3131
abstract val payloadSize: Int
@@ -45,7 +45,6 @@ abstract class RSocketBenchmark<Payload : Any, Blackhole : Any> {
4545

4646
// benchmarks
4747

48-
// Benchmark annotation doesn't inherit on jvm
4948
open fun requestResponseBlocking(bh: Blackhole) = blocking(bh, 1000, ::requestResponse)
5049
open fun requestResponseParallel(bh: Blackhole) = parallel(bh, 1000, ::requestResponse)
5150
open fun requestResponseConcurrent(bh: Blackhole) = concurrent(bh, 1000, ::requestResponse)

benchmarks/rsocket-java/build.gradle.kts renamed to rsocket-transport-benchmarks/rsocket-java/build.gradle.kts

Lines changed: 6 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -26,22 +26,18 @@ kotlin {
2626

2727
sourceSets {
2828
jvmMain.dependencies {
29-
implementation(projects.benchmarksShared)
30-
29+
implementation(projects.rsocketTransportBenchmarksBase)
3130
implementation(libs.kotlinx.coroutines.reactor)
32-
implementation(libs.rsocket.java.transport.local)
33-
implementation(libs.rsocket.java.transport.netty)
31+
32+
implementation("io.rsocket:rsocket-transport-local:1.1.5")
33+
implementation("io.rsocket:rsocket-transport-netty:1.1.5")
3434
}
3535
}
3636
}
3737

3838
benchmark {
3939
targets {
40-
register("jvm") {
41-
this as JvmBenchmarkTarget
42-
jmhVersion = libs.versions.jmh.get()
43-
}
40+
register("jvm")
4441
}
45-
46-
registerBenchmarks("RSocketJava", listOf("local", "tcp", "ws"))
42+
registerTransportBenchmarks("RSocketJava", listOf("local", "nettyTcp"))
4743
}

benchmarks/rsocket-java/src/jvmMain/kotlin/LocalRSocketJavaBenchmark.kt renamed to rsocket-transport-benchmarks/rsocket-java/src/jvmMain/kotlin/LocalRSocketJavaBenchmark.kt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@
1414
* limitations under the License.
1515
*/
1616

17-
package io.rsocket.kotlin.benchmarks.java
17+
package io.rsocket.kotlin.transport.benchmarks.java
1818

1919
import io.rsocket.transport.*
2020
import io.rsocket.transport.local.*

benchmarks/rsocket-java/src/jvmMain/kotlin/TcpRSocketJavaBenchmark.kt renamed to rsocket-transport-benchmarks/rsocket-java/src/jvmMain/kotlin/NettyTcpRSocketJavaBenchmark.kt

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,13 +14,13 @@
1414
* limitations under the License.
1515
*/
1616

17-
package io.rsocket.kotlin.benchmarks.java
17+
package io.rsocket.kotlin.transport.benchmarks.java
1818

1919
import io.rsocket.transport.*
2020
import io.rsocket.transport.netty.client.*
2121
import io.rsocket.transport.netty.server.*
2222

23-
class TcpRSocketJavaBenchmark : RSocketJavaBenchmark() {
23+
class NettyTcpRSocketJavaBenchmark : RSocketJavaBenchmark() {
2424
override val serverTransport: ServerTransport<*> = TcpServerTransport.create(9000)
2525
override val clientTransport: ClientTransport = TcpClientTransport.create(9000)
2626
}

0 commit comments

Comments
 (0)