Skip to content

Commit 6591ebd

Browse files
CopilotShreckYe
andcommitted
Replicate 4 benchmark configurations for vertx-web-kotlinx-r2dbc-postgresql
- Updated r2dbc Main.kt to accept CLI arguments (isSharedPool, poolSize, useOptimizedConfig) - Updated r2dbc MainVerticle to accept ConnectionFactory parameter - Added MainVerticleWithSeparatePool factory function for separate pool configurations - Created 4 new dockerfiles for r2dbc-postgresql variants: * separate-pool-size-1: Pool size 1 per verticle, original connection factory * separate-pool-size-8: Pool size 8 per verticle (~512 total on 56-core), original factory * separate-pool-size-8-optimized: Pool size 8 with optimized TCP settings and validation * shared-pool-size-512-optimized: Single shared pool of 512 with optimizations - Added 4 new test configurations to benchmark_config.json - Build verification successful This mirrors the exposed-r2dbc-postgresql configuration approach for comprehensive comparison. Co-authored-by: ShreckYe <27768951+ShreckYe@users.noreply.github.com>
1 parent f7235c4 commit 6591ebd

7 files changed

+361
-7
lines changed

frameworks/Kotlin/vertx-web-kotlinx/benchmark_config.json

Lines changed: 84 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -63,6 +63,90 @@
6363
"notes": "",
6464
"versus": "vertx-web-kotlinx-postgresql"
6565
},
66+
"r2dbc-postgresql-separate-pool-size-1": {
67+
"db_url": "/db",
68+
"query_url": "/queries?queries=",
69+
"fortune_url": "/fortunes",
70+
"update_url": "/updates?queries=",
71+
"port": 8080,
72+
"approach": "Realistic",
73+
"classification": "Micro",
74+
"database": "postgres",
75+
"framework": "vertx-web",
76+
"language": "Kotlin",
77+
"flavor": "None",
78+
"orm": "Raw",
79+
"platform": "Vert.x",
80+
"webserver": "None",
81+
"os": "Linux",
82+
"database_os": "Linux",
83+
"display_name": "vertx-web-kotlinx-r2dbc-postgresql-separate-pool-size-1",
84+
"notes": "Original configuration: pool size 1 per verticle, original connection factory",
85+
"versus": "vertx-web-kotlinx-r2dbc-postgresql"
86+
},
87+
"r2dbc-postgresql-separate-pool-size-8": {
88+
"db_url": "/db",
89+
"query_url": "/queries?queries=",
90+
"fortune_url": "/fortunes",
91+
"update_url": "/updates?queries=",
92+
"port": 8080,
93+
"approach": "Realistic",
94+
"classification": "Micro",
95+
"database": "postgres",
96+
"framework": "vertx-web",
97+
"language": "Kotlin",
98+
"flavor": "None",
99+
"orm": "Raw",
100+
"platform": "Vert.x",
101+
"webserver": "None",
102+
"os": "Linux",
103+
"database_os": "Linux",
104+
"display_name": "vertx-web-kotlinx-r2dbc-postgresql-separate-pool-size-8",
105+
"notes": "Pool size 8 per verticle (~512 total on 56-core), original connection factory",
106+
"versus": "vertx-web-kotlinx-r2dbc-postgresql"
107+
},
108+
"r2dbc-postgresql-separate-pool-size-8-optimized": {
109+
"db_url": "/db",
110+
"query_url": "/queries?queries=",
111+
"fortune_url": "/fortunes",
112+
"update_url": "/updates?queries=",
113+
"port": 8080,
114+
"approach": "Realistic",
115+
"classification": "Micro",
116+
"database": "postgres",
117+
"framework": "vertx-web",
118+
"language": "Kotlin",
119+
"flavor": "None",
120+
"orm": "Raw",
121+
"platform": "Vert.x",
122+
"webserver": "None",
123+
"os": "Linux",
124+
"database_os": "Linux",
125+
"display_name": "vertx-web-kotlinx-r2dbc-postgresql-separate-pool-size-8-optimized",
126+
"notes": "Pool size 8 per verticle, optimized connection factory with TCP settings and validation",
127+
"versus": "vertx-web-kotlinx-r2dbc-postgresql"
128+
},
129+
"r2dbc-postgresql-shared-pool-size-512-optimized": {
130+
"db_url": "/db",
131+
"query_url": "/queries?queries=",
132+
"fortune_url": "/fortunes",
133+
"update_url": "/updates?queries=",
134+
"port": 8080,
135+
"approach": "Realistic",
136+
"classification": "Micro",
137+
"database": "postgres",
138+
"framework": "vertx-web",
139+
"language": "Kotlin",
140+
"flavor": "None",
141+
"orm": "Raw",
142+
"platform": "Vert.x",
143+
"webserver": "None",
144+
"os": "Linux",
145+
"database_os": "Linux",
146+
"display_name": "vertx-web-kotlinx-r2dbc-postgresql-shared-pool-size-512-optimized",
147+
"notes": "Single shared pool of 512 connections with optimized connection factory",
148+
"versus": "vertx-web-kotlinx-r2dbc-postgresql"
149+
},
66150
"exposed-r2dbc-postgresql-separate-pool-size-1": {
67151
"db_url": "/db",
68152
"query_url": "/queries?queries=",
Lines changed: 53 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,53 @@
1+
FROM gradle:9.2.1-jdk25
2+
3+
WORKDIR /vertx-web-kotlinx
4+
5+
6+
COPY gradle/libs.versions.toml gradle/libs.versions.toml
7+
COPY buildSrc buildSrc
8+
COPY settings.gradle.kts settings.gradle.kts
9+
COPY build.gradle.kts build.gradle.kts
10+
COPY gradle.properties gradle.properties
11+
12+
# make empty directories for subprojects that do not need to be copied for Gradle
13+
RUN mkdir -p common without-db/default with-db/common with-db/default with-db/r2dbc-common with-db/r2dbc with-db/exposed-common with-db/exposed-r2dbc with-db/exposed-vertx-sql-client
14+
15+
COPY common/build.gradle.kts common/build.gradle.kts
16+
COPY common/src common/src
17+
18+
COPY with-db/common/build.gradle.kts with-db/common/build.gradle.kts
19+
COPY with-db/common/src with-db/common/src
20+
21+
COPY with-db/r2dbc-common/build.gradle.kts with-db/r2dbc-common/build.gradle.kts
22+
COPY with-db/r2dbc-common/src with-db/r2dbc-common/src
23+
24+
COPY with-db/r2dbc/build.gradle.kts with-db/r2dbc/build.gradle.kts
25+
COPY with-db/r2dbc/src with-db/r2dbc/src
26+
27+
28+
RUN gradle --no-daemon with-db:r2dbc:installDist
29+
30+
EXPOSE 8080
31+
32+
CMD export JAVA_OPTS=" \
33+
--enable-native-access=ALL-UNNAMED \
34+
--sun-misc-unsafe-memory-access=allow \
35+
--add-opens=java.base/java.lang=ALL-UNNAMED \
36+
-server \
37+
-XX:+UseNUMA \
38+
-XX:+UseParallelGC \
39+
-XX:+UnlockDiagnosticVMOptions \
40+
-XX:+DebugNonSafepoints \
41+
-Djava.lang.Integer.IntegerCache.high=10000 \
42+
-Dvertx.disableMetrics=true \
43+
-Dvertx.disableWebsockets=true \
44+
-Dvertx.disableContextTimings=true \
45+
-Dvertx.disableHttpHeadersValidation=true \
46+
-Dvertx.cacheImmutableHttpResponseHeaders=true \
47+
-Dvertx.internCommonHttpRequestHeadersToLowerCase=true \
48+
-Dio.netty.noUnsafe=false \
49+
-Dio.netty.buffer.checkBounds=false \
50+
-Dio.netty.buffer.checkAccessible=false \
51+
-Dio.netty.iouring.ringSize=16384 \
52+
" && \
53+
with-db/r2dbc/build/install/r2dbc/bin/r2dbc false 1 false
Lines changed: 53 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,53 @@
1+
FROM gradle:9.2.1-jdk25
2+
3+
WORKDIR /vertx-web-kotlinx
4+
5+
6+
COPY gradle/libs.versions.toml gradle/libs.versions.toml
7+
COPY buildSrc buildSrc
8+
COPY settings.gradle.kts settings.gradle.kts
9+
COPY build.gradle.kts build.gradle.kts
10+
COPY gradle.properties gradle.properties
11+
12+
# make empty directories for subprojects that do not need to be copied for Gradle
13+
RUN mkdir -p common without-db/default with-db/common with-db/default with-db/r2dbc-common with-db/r2dbc with-db/exposed-common with-db/exposed-r2dbc with-db/exposed-vertx-sql-client
14+
15+
COPY common/build.gradle.kts common/build.gradle.kts
16+
COPY common/src common/src
17+
18+
COPY with-db/common/build.gradle.kts with-db/common/build.gradle.kts
19+
COPY with-db/common/src with-db/common/src
20+
21+
COPY with-db/r2dbc-common/build.gradle.kts with-db/r2dbc-common/build.gradle.kts
22+
COPY with-db/r2dbc-common/src with-db/r2dbc-common/src
23+
24+
COPY with-db/r2dbc/build.gradle.kts with-db/r2dbc/build.gradle.kts
25+
COPY with-db/r2dbc/src with-db/r2dbc/src
26+
27+
28+
RUN gradle --no-daemon with-db:r2dbc:installDist
29+
30+
EXPOSE 8080
31+
32+
CMD export JAVA_OPTS=" \
33+
--enable-native-access=ALL-UNNAMED \
34+
--sun-misc-unsafe-memory-access=allow \
35+
--add-opens=java.base/java.lang=ALL-UNNAMED \
36+
-server \
37+
-XX:+UseNUMA \
38+
-XX:+UseParallelGC \
39+
-XX:+UnlockDiagnosticVMOptions \
40+
-XX:+DebugNonSafepoints \
41+
-Djava.lang.Integer.IntegerCache.high=10000 \
42+
-Dvertx.disableMetrics=true \
43+
-Dvertx.disableWebsockets=true \
44+
-Dvertx.disableContextTimings=true \
45+
-Dvertx.disableHttpHeadersValidation=true \
46+
-Dvertx.cacheImmutableHttpResponseHeaders=true \
47+
-Dvertx.internCommonHttpRequestHeadersToLowerCase=true \
48+
-Dio.netty.noUnsafe=false \
49+
-Dio.netty.buffer.checkBounds=false \
50+
-Dio.netty.buffer.checkAccessible=false \
51+
-Dio.netty.iouring.ringSize=16384 \
52+
" && \
53+
with-db/r2dbc/build/install/r2dbc/bin/r2dbc false 8 true
Lines changed: 53 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,53 @@
1+
FROM gradle:9.2.1-jdk25
2+
3+
WORKDIR /vertx-web-kotlinx
4+
5+
6+
COPY gradle/libs.versions.toml gradle/libs.versions.toml
7+
COPY buildSrc buildSrc
8+
COPY settings.gradle.kts settings.gradle.kts
9+
COPY build.gradle.kts build.gradle.kts
10+
COPY gradle.properties gradle.properties
11+
12+
# make empty directories for subprojects that do not need to be copied for Gradle
13+
RUN mkdir -p common without-db/default with-db/common with-db/default with-db/r2dbc-common with-db/r2dbc with-db/exposed-common with-db/exposed-r2dbc with-db/exposed-vertx-sql-client
14+
15+
COPY common/build.gradle.kts common/build.gradle.kts
16+
COPY common/src common/src
17+
18+
COPY with-db/common/build.gradle.kts with-db/common/build.gradle.kts
19+
COPY with-db/common/src with-db/common/src
20+
21+
COPY with-db/r2dbc-common/build.gradle.kts with-db/r2dbc-common/build.gradle.kts
22+
COPY with-db/r2dbc-common/src with-db/r2dbc-common/src
23+
24+
COPY with-db/r2dbc/build.gradle.kts with-db/r2dbc/build.gradle.kts
25+
COPY with-db/r2dbc/src with-db/r2dbc/src
26+
27+
28+
RUN gradle --no-daemon with-db:r2dbc:installDist
29+
30+
EXPOSE 8080
31+
32+
CMD export JAVA_OPTS=" \
33+
--enable-native-access=ALL-UNNAMED \
34+
--sun-misc-unsafe-memory-access=allow \
35+
--add-opens=java.base/java.lang=ALL-UNNAMED \
36+
-server \
37+
-XX:+UseNUMA \
38+
-XX:+UseParallelGC \
39+
-XX:+UnlockDiagnosticVMOptions \
40+
-XX:+DebugNonSafepoints \
41+
-Djava.lang.Integer.IntegerCache.high=10000 \
42+
-Dvertx.disableMetrics=true \
43+
-Dvertx.disableWebsockets=true \
44+
-Dvertx.disableContextTimings=true \
45+
-Dvertx.disableHttpHeadersValidation=true \
46+
-Dvertx.cacheImmutableHttpResponseHeaders=true \
47+
-Dvertx.internCommonHttpRequestHeadersToLowerCase=true \
48+
-Dio.netty.noUnsafe=false \
49+
-Dio.netty.buffer.checkBounds=false \
50+
-Dio.netty.buffer.checkAccessible=false \
51+
-Dio.netty.iouring.ringSize=16384 \
52+
" && \
53+
with-db/r2dbc/build/install/r2dbc/bin/r2dbc false 8 false
Lines changed: 53 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,53 @@
1+
FROM gradle:9.2.1-jdk25
2+
3+
WORKDIR /vertx-web-kotlinx
4+
5+
6+
COPY gradle/libs.versions.toml gradle/libs.versions.toml
7+
COPY buildSrc buildSrc
8+
COPY settings.gradle.kts settings.gradle.kts
9+
COPY build.gradle.kts build.gradle.kts
10+
COPY gradle.properties gradle.properties
11+
12+
# make empty directories for subprojects that do not need to be copied for Gradle
13+
RUN mkdir -p common without-db/default with-db/common with-db/default with-db/r2dbc-common with-db/r2dbc with-db/exposed-common with-db/exposed-r2dbc with-db/exposed-vertx-sql-client
14+
15+
COPY common/build.gradle.kts common/build.gradle.kts
16+
COPY common/src common/src
17+
18+
COPY with-db/common/build.gradle.kts with-db/common/build.gradle.kts
19+
COPY with-db/common/src with-db/common/src
20+
21+
COPY with-db/r2dbc-common/build.gradle.kts with-db/r2dbc-common/build.gradle.kts
22+
COPY with-db/r2dbc-common/src with-db/r2dbc-common/src
23+
24+
COPY with-db/r2dbc/build.gradle.kts with-db/r2dbc/build.gradle.kts
25+
COPY with-db/r2dbc/src with-db/r2dbc/src
26+
27+
28+
RUN gradle --no-daemon with-db:r2dbc:installDist
29+
30+
EXPOSE 8080
31+
32+
CMD export JAVA_OPTS=" \
33+
--enable-native-access=ALL-UNNAMED \
34+
--sun-misc-unsafe-memory-access=allow \
35+
--add-opens=java.base/java.lang=ALL-UNNAMED \
36+
-server \
37+
-XX:+UseNUMA \
38+
-XX:+UseParallelGC \
39+
-XX:+UnlockDiagnosticVMOptions \
40+
-XX:+DebugNonSafepoints \
41+
-Djava.lang.Integer.IntegerCache.high=10000 \
42+
-Dvertx.disableMetrics=true \
43+
-Dvertx.disableWebsockets=true \
44+
-Dvertx.disableContextTimings=true \
45+
-Dvertx.disableHttpHeadersValidation=true \
46+
-Dvertx.cacheImmutableHttpResponseHeaders=true \
47+
-Dvertx.internCommonHttpRequestHeadersToLowerCase=true \
48+
-Dio.netty.noUnsafe=false \
49+
-Dio.netty.buffer.checkBounds=false \
50+
-Dio.netty.buffer.checkAccessible=false \
51+
-Dio.netty.iouring.ringSize=16384 \
52+
" && \
53+
with-db/r2dbc/build/install/r2dbc/bin/r2dbc true 512 true
Lines changed: 53 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,53 @@
1-
suspend fun main() =
2-
commonRunVertxServer(
3-
"Vert.x-Web Kotlinx with R2DBC (and PostgreSQL)",
4-
{},
5-
{ MainVerticle() }
6-
)
1+
import database.connectionPoolOptimized
2+
import database.connectionPoolOriginal
3+
import io.r2dbc.spi.ConnectionFactory
4+
import kotlinx.coroutines.reactive.awaitSingle
5+
6+
suspend fun main(args: Array<String>) {
7+
// Parse CLI arguments
8+
val isSharedPool = args.getOrNull(0)?.toBooleanStrictOrNull() ?: true
9+
val poolSize = args.getOrNull(1)?.toIntOrNull() ?: 512
10+
val useOptimizedConfig = args.getOrNull(2)?.toBooleanStrictOrNull() ?: true
11+
12+
val benchmarkName = buildString {
13+
append("Vert.x-Web Kotlinx with R2DBC (and PostgreSQL)")
14+
if (!isSharedPool || poolSize != 512 || !useOptimizedConfig) {
15+
append(" - ")
16+
if (isSharedPool) {
17+
append("Shared Pool Size $poolSize")
18+
} else {
19+
append("Separate Pool Size $poolSize")
20+
}
21+
if (useOptimizedConfig) {
22+
append(" Optimized")
23+
}
24+
}
25+
}
26+
27+
val connectionFactory: ConnectionFactory = if (isSharedPool) {
28+
// Shared pool: create one ConnectionPool that all verticles will share
29+
if (useOptimizedConfig) {
30+
connectionPoolOptimized(poolSize)
31+
} else {
32+
connectionPoolOriginal(poolSize)
33+
}
34+
} else {
35+
// Separate pool: each verticle creates its own pool, so we just pass the pool size
36+
// We'll use a dummy factory here, the actual pools are created in MainVerticle
37+
throw IllegalStateException("Separate pool mode requires MainVerticleWithSeparatePool")
38+
}
39+
40+
if (isSharedPool) {
41+
commonRunVertxServer(
42+
benchmarkName,
43+
{},
44+
{ MainVerticle(connectionFactory) }
45+
)
46+
} else {
47+
commonRunVertxServer(
48+
benchmarkName,
49+
{},
50+
{ MainVerticleWithSeparatePool(poolSize, useOptimizedConfig) }
51+
)
52+
}
53+
}

frameworks/Kotlin/vertx-web-kotlinx/with-db/r2dbc/src/main/kotlin/MainVerticle.kt

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
import database.*
22
import io.r2dbc.spi.Connection
3+
import io.r2dbc.spi.ConnectionFactory
34
import io.r2dbc.spi.Readable
45
import kotlinx.coroutines.reactive.awaitFirst
56
import kotlinx.coroutines.reactive.awaitSingle
@@ -10,7 +11,7 @@ import kotlinx.coroutines.reactive.collect
1011
https://github.com/pgjdbc/r2dbc-postgresql/issues/360#issuecomment-869422327 offers a workaround, but it doesn't seem like the officially recommended approach.
1112
The PostgreSQL R2DBC driver doesn't seem to have full support for pipelining and multiplexing as discussed in https://github.com/pgjdbc/r2dbc-postgresql/pull/28.
1213
*/
13-
class MainVerticle : CommonWithDbVerticle<Connection, Unit>(),
14+
class MainVerticle(private val connectionFactory: ConnectionFactory) : CommonWithDbVerticle<Connection, Unit>(),
1415
CommonWithDbVerticleI.SequentialSelectWorlds<Connection, Unit>,
1516
CommonWithDbVerticleI.WithoutTransaction<Connection> {
1617
override suspend fun initDbClient(): Connection =
@@ -52,4 +53,14 @@ class MainVerticle : CommonWithDbVerticle<Connection, Unit>(),
5253
//.asFlow().toList(fortunes)
5354
.collect(fortunes::add)
5455
}
56+
}
57+
58+
// Factory function for creating MainVerticle with separate connection pools
59+
fun MainVerticleWithSeparatePool(poolSize: Int, useOptimizedConfig: Boolean): MainVerticle {
60+
val connectionPool = if (useOptimizedConfig) {
61+
connectionPoolOptimized(poolSize)
62+
} else {
63+
connectionPoolOriginal(poolSize)
64+
}
65+
return MainVerticle(connectionPool)
5566
}

0 commit comments

Comments
 (0)