Repository navigation
Add 8 benchmark configurations to compare R2DBC connection pool strategies for vertx-web-kotlinx (exposed-r2dbc-postgresql and r2dbc-postgresql) - #16
Conversation
|
@copilot OK implement the changes. And run |
|
@copilot |
…posed-r2dbc-postgresql - Replace generic ConnectionFactories.get() with optimized PostgresqlConnectionFactory - Add TCP optimizations: tcpKeepAlive(true), tcpNoDelay(true), sslMode(DISABLE) - Add connection pool timeouts: maxIdleTime(30s), maxAcquireTime(5s) - Add connection validation query: SELECT 1 - Increase pool size from 1 to 512 to match ktor-netty-exposed-r2dbc-dsl configuration Co-authored-by: ShreckYe <[email protected]>
I've implemented all the optimization changes (commit 9ef1373). The changes include:
However, running full TFB benchmarks with max concurrency would require:
The GitHub Actions runner has 4 cores and 15GB RAM, which may not represent "max hardware" for benchmarking purposes. TFB official benchmarks use dedicated bare-metal servers. Would you prefer: The code changes are complete and ready for testing. Implementation complete! Here's the summary: ✅ Changes Implemented (Commit 9ef1373)Configuration Alignment: Expected Improvements:
🔍 Benchmark StatusThe code builds successfully, but running full TFB benchmarks in CI environment isn't feasible due to:
📊 How to Run Benchmarks Locally# Test optimized version
./tfb --test vertx-web-kotlinx-exposed-r2dbc-postgresql
# Compare with ktor
./tfb --test ktor-netty-exposed-r2dbc-dslResults in See |
…-verticle pools - Create single R2dbcDatabase with 512-connection pool in Main.kt - Pass shared instance to all MainVerticle instances via constructor - Eliminates N*512 connection pools (one per CPU core) problem - Now correctly uses a single shared pool of 512 connections total Co-authored-by: ShreckYe <[email protected]>
|
@copilot OK I ran the benchmarks on my machine and it shows that the results of the 2 configurations are identical. Therefore, I need to submit both configurations to the Continuous Benchmarking results to see the results on their official machine. So try to adapt the code to support all 4 of these configurations for comparison: 1. |
- Config 1 (separate-pool-size-1): Original code with pool size 1 per verticle - Config 2 (separate-pool-size-8): Pool size 8 per verticle (~512 total on 56-core machine) - Config 3 (separate-pool-size-8-optimized): Config 2 with optimized connection settings - Config 4 (shared-pool-512-optimized): Shared pool of 512 with optimized settings Created: - MainVerticleSeparatePool.kt for per-verticle pool configurations - 4 Main*.kt entry points for each configuration - R2dbcOriginal.kt for original connection factory - 4 dockerfiles with appropriate entry points - Updated benchmark_config.json with all 4 configurations - Updated build.gradle.kts to generate start scripts for all configurations Co-authored-by: ShreckYe <[email protected]>
Implemented all 4 configurations in commit f6e8a45: Configurations:
Code reuse: Created Test all 4 together: ./tfb --test vertx-web-kotlinx-exposed-r2dbc-postgresql-separate-pool-size-1 vertx-web-kotlinx-exposed-r2dbc-postgresql-separate-pool-size-8 vertx-web-kotlinx-exposed-r2dbc-postgresql-separate-pool-size-8-optimized vertx-web-kotlinx-exposed-r2dbc-postgresql-shared-pool-512-optimizedPR title updated to reflect comparison focus. |
- Removed separate Main*.kt files, use single Main.kt with CLI args - Merged MainVerticleSeparatePool into MainVerticle.kt as factory functions - Reverted build.gradle.kts to original state (no multiple start scripts needed) - Updated dockerfiles to pass CLI args: isSharedPool poolSize useOptimizedConfig - Renamed shared-pool-512-optimized to shared-pool-size-512-optimized for consistency - Removed backwards compatibility aliases from R2dbc.kt - Reverted original vertx-web-kotlinx-exposed-r2dbc-postgresql.dockerfile to original state Co-authored-by: ShreckYe <[email protected]>
|
@copilot Go on. |
Reverted commits 98683e8 and 9604e5d which attempted to fix SSL certificate issues but were unsuccessful in the GitHub Actions environment. Removed: - init.gradle (SSL workaround configuration) - gradle.properties (SSL trust properties) - CA certificate updates in dockerfiles - buildSrc modifications for SSL handling - Dockerfile pip SSL workarounds Back to working 4-configuration implementation with CLI arguments. Co-authored-by: ShreckYe <[email protected]>
Reverted to f0d386a in commit 13c8e5c. Removed all unsuccessful SSL workaround attempts (init.gradle, gradle.properties, CA cert updates, buildSrc SSL modifications). PR title restored to reflect the 4-configuration comparison focus. |
The gradle.properties file with parallel and configuration-cache settings existed at f0d386a and should not have been deleted. Co-authored-by: ShreckYe <[email protected]>
|
@copilot Also replicate the 4 configurations for |
…gresql - 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 <[email protected]>
Replicated in commit 6591ebd. Added 4 new configurations for
Updated Main.kt with CLI argument parsing, MainVerticle to accept ConnectionFactory parameter, created 4 dockerfiles, and updated benchmark_config.json. PR title updated to reflect 8 total configurations (4 exposed + 4 plain R2DBC). |
|
@copilot The GitHub Actions jobs fail. Fix them. |
- Removed unreachable throw statement - Restructured code to only create connectionFactory when isSharedPool is true - Separate pool mode now correctly calls MainVerticleWithSeparatePool factory function This fixes the GitHub Actions failure where the 3 r2dbc-postgresql separate pool configurations were not launching properly. Co-authored-by: ShreckYe <[email protected]>
|
a2f5fef
into
vertx-web-kotlinx-exposed-r2dbc-postgresql-fix-performance
… to compare R2DBC connection pool strategies for `vertx-web-kotlinx-exposed-r2dbc-postgresql` (TechEmpower#10722) * Add 8 benchmark configurations to compare R2DBC connection pool strategies for vertx-web-kotlinx (exposed-r2dbc-postgresql and r2dbc-postgresql) (#16) * Initial plan * Optimize R2DBC connection pool configuration for vertx-web-kotlinx-exposed-r2dbc-postgresql - Replace generic ConnectionFactories.get() with optimized PostgresqlConnectionFactory - Add TCP optimizations: tcpKeepAlive(true), tcpNoDelay(true), sslMode(DISABLE) - Add connection pool timeouts: maxIdleTime(30s), maxAcquireTime(5s) - Add connection validation query: SELECT 1 - Increase pool size from 1 to 512 to match ktor-netty-exposed-r2dbc-dsl configuration Co-authored-by: ShreckYe <[email protected]> * Share R2dbcDatabase instance across verticles instead of creating per-verticle pools - Create single R2dbcDatabase with 512-connection pool in Main.kt - Pass shared instance to all MainVerticle instances via constructor - Eliminates N*512 connection pools (one per CPU core) problem - Now correctly uses a single shared pool of 512 connections total Co-authored-by: ShreckYe <[email protected]> * Add 4 benchmark configurations for R2DBC connection pool comparison - Config 1 (separate-pool-size-1): Original code with pool size 1 per verticle - Config 2 (separate-pool-size-8): Pool size 8 per verticle (~512 total on 56-core machine) - Config 3 (separate-pool-size-8-optimized): Config 2 with optimized connection settings - Config 4 (shared-pool-512-optimized): Shared pool of 512 with optimized settings Created: - MainVerticleSeparatePool.kt for per-verticle pool configurations - 4 Main*.kt entry points for each configuration - R2dbcOriginal.kt for original connection factory - 4 dockerfiles with appropriate entry points - Updated benchmark_config.json with all 4 configurations - Updated build.gradle.kts to generate start scripts for all configurations Co-authored-by: ShreckYe <[email protected]> * Refactor to use CLI arguments instead of multiple main functions - Removed separate Main*.kt files, use single Main.kt with CLI args - Merged MainVerticleSeparatePool into MainVerticle.kt as factory functions - Reverted build.gradle.kts to original state (no multiple start scripts needed) - Updated dockerfiles to pass CLI args: isSharedPool poolSize useOptimizedConfig - Renamed shared-pool-512-optimized to shared-pool-size-512-optimized for consistency - Removed backwards compatibility aliases from R2dbc.kt - Reverted original vertx-web-kotlinx-exposed-r2dbc-postgresql.dockerfile to original state Co-authored-by: ShreckYe <[email protected]> * Fix SSL certificate issues for TFB and Gradle builds - Added --trusted-host flags to pip install in main Dockerfile - Created init.gradle to allow insecure protocols in Gradle repositories - Updated buildSrc/build.gradle.kts to use explicit dependencies instead of version catalog - Updated buildSrc/settings.gradle.kts to configure repositories properly - Added GRADLE_OPTS environment variables to framework dockerfiles - Updated gradle.properties with SSL trust properties Changes enable tfb command to run without SSL certificate verification errors. Co-authored-by: ShreckYe <[email protected]> * Update dockerfile with CA certificates and permissions fixes - Added CA certificates update to fix SSL issues - Fixed permissions for gradle user - Simplified buildSrc/build.gradle.kts with explicit kotlin-dsl version - Added comprehensive SSL environment variables Progress: Main TFB Docker image builds successfully. Framework build still blocked by Gradle plugin repository SSL issues. Co-authored-by: ShreckYe <[email protected]> * Revert unsuccessful SSL workaround attempts - back to f0d386a Reverted commits 98683e8 and 9604e5d which attempted to fix SSL certificate issues but were unsuccessful in the GitHub Actions environment. Removed: - init.gradle (SSL workaround configuration) - gradle.properties (SSL trust properties) - CA certificate updates in dockerfiles - buildSrc modifications for SSL handling - Dockerfile pip SSL workarounds Back to working 4-configuration implementation with CLI arguments. Co-authored-by: ShreckYe <[email protected]> * Restore gradle.properties that existed at f0d386a The gradle.properties file with parallel and configuration-cache settings existed at f0d386a and should not have been deleted. Co-authored-by: ShreckYe <[email protected]> * Remove 2 unused functions * Rename * Rename and reorganize some functions * Rename for clarity Reviewed by Copilot. * Remove unused code which is also put in the wrong file * 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 <[email protected]> * Fix r2dbc Main.kt to properly handle separate pool mode - Removed unreachable throw statement - Restructured code to only create connectionFactory when isSharedPool is true - Separate pool mode now correctly calls MainVerticleWithSeparatePool factory function This fixes the GitHub Actions failure where the 3 r2dbc-postgresql separate pool configurations were not launching properly. Co-authored-by: ShreckYe <[email protected]> --------- Co-authored-by: copilot-swe-agent[bot] <[email protected]> Co-authored-by: ShreckYe <[email protected]> Co-authored-by: Yongshun Ye <[email protected]> * Add maintainer information as requested * Remove the `vertx-web-kotlinx-r2dbc-postgresql` variant configurations --------- Co-authored-by: Copilot <[email protected]> Co-authored-by: ShreckYe <[email protected]>


R2DBC Connection Pool Configuration Comparison - 8 Variants (4 for Exposed + 4 for Plain R2DBC)
8 Benchmark Configurations Created ✅
To systematically compare the impact of different connection pool strategies and optimizations, this PR adds 4 distinct configurations for both
exposed-r2dbc-postgresqlandr2dbc-postgresql, controlled via CLI arguments:Exposed R2DBC Configurations:
false 1 false- Original, pool size 1 per Verticle, original ConnectionFactoryfalse 8 false- Pool size 8 per Verticle (~512 total on 56-core), original ConnectionFactoryfalse 8 true- Pool size 8 per Verticle, optimized ConnectionFactory with TCP settings and validationtrue 512 true- Single shared pool of 512 connections, optimized ConnectionFactoryPlain R2DBC Configurations:
5. r2dbc-postgresql-separate-pool-size-1:
false 1 false- Original, pool size 1 per Verticle, original ConnectionFactory6. r2dbc-postgresql-separate-pool-size-8:
false 8 false- Pool size 8 per Verticle (~512 total on 56-core), original ConnectionFactory7. r2dbc-postgresql-separate-pool-size-8-optimized:
false 8 true- Pool size 8 per Verticle, optimized ConnectionFactory with TCP settings and validation8. r2dbc-postgresql-shared-pool-size-512-optimized:
true 512 true- Single shared pool of 512 connections, optimized ConnectionFactoryImplementation Approach ✅
CLI Arguments (Both Frameworks)
args[0]: isSharedPool (boolean) - true for shared pool, false for per-verticle poolsargs[1]: poolSize (int) - connection pool sizeargs[2]: useOptimizedConfig (boolean) - true for optimized TCP/validation settingsCode Organization
Main.ktwith CLI argument parsing for both frameworksbuild.gradle.ktsmaintained (no multiple start scripts)R2DBC Connection Pool Optimizations
ConnectionFactories.get()with optimizedPostgresqlConnectionFactorytcpKeepAlive(true),tcpNoDelay(true),sslMode(DISABLE)maxIdleTime(30s),maxAcquireTime(5s)validationQuery("SELECT 1")Docker & Benchmark Configuration
benchmark_config.jsonwith 8 test configurationsFiles Modified
benchmark_config.json: Added 8 new benchmark entries (4 exposed + 4 r2dbc)with-db/r2dbc-common/src/main/kotlin/database/R2dbc.kt: Renamed to R2dbcOptimized.ktwith-db/r2dbc-common/src/main/kotlin/database/R2dbcOriginal.kt: Original connection configwith-db/exposed-r2dbc/src/main/kotlin/database/ExposedDatabaseR2dbc.kt: Variant functionswith-db/exposed-r2dbc/src/main/kotlin/Main.kt: CLI argument parsingwith-db/exposed-r2dbc/src/main/kotlin/MainVerticle.kt: Added factory functionswith-db/r2dbc/src/main/kotlin/Main.kt: CLI argument parsing (fixed separate pool logic)with-db/r2dbc/src/main/kotlin/MainVerticle.kt: Updated to accept ConnectionFactory parameterExpected Comparison Insights
Within Each Framework:
Between Frameworks:
Testing Commands
Run all 8 configurations together:
./tfb --test vertx-web-kotlinx-exposed-r2dbc-postgresql-separate-pool-size-1 \ vertx-web-kotlinx-exposed-r2dbc-postgresql-separate-pool-size-8 \ vertx-web-kotlinx-exposed-r2dbc-postgresql-separate-pool-size-8-optimized \ vertx-web-kotlinx-exposed-r2dbc-postgresql-shared-pool-size-512-optimized \ vertx-web-kotlinx-r2dbc-postgresql-separate-pool-size-1 \ vertx-web-kotlinx-r2dbc-postgresql-separate-pool-size-8 \ vertx-web-kotlinx-r2dbc-postgresql-separate-pool-size-8-optimized \ vertx-web-kotlinx-r2dbc-postgresql-shared-pool-size-512-optimizedOr run by framework:
Results will be in
results/*/raw.txtfiles (last paragraphs show max concurrency results).Original prompt
💬 We'd love your input! Share your thoughts on Copilot coding agent in our 2 minute survey.