-
Notifications
You must be signed in to change notification settings - Fork 2k
Revamp the Kotlin Vert.x portions "vertx-web-kotlinx" and "vertx-web-kotlin-coroutines" #9374
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
NateBrady23
merged 16 commits into
TechEmpower:master
from
huanshankeji:kotlin-vertx-benchmarks-revamp
Nov 4, 2024
Merged
Revamp the Kotlin Vert.x portions "vertx-web-kotlinx" and "vertx-web-kotlin-coroutines" #9374
NateBrady23
merged 16 commits into
TechEmpower:master
from
huanshankeji:kotlin-vertx-benchmarks-revamp
Nov 4, 2024
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Changes: 1. bump the Gradle versions and the dependency versions to the latest 1. bump the JVM version to 21 with the new `jvmToolchain` DSL 1. resolve deprecations 1. update the dockerfile to use the `installDist` Gradle task so the time for archiving and unarchiving is saved
There are no build or runtime errors. Single query performance seems to have been improved by 2% with the bumped versions (I think most likely due to Java 21). Vagrant reduces performance by about 20% compared to running directly with Docker.
The single query performance is improved by 5% - 10%.
…in the "single query" and "JSON serialization" tests in the [Continuous Benchmarking results](https://tfb-status.techempower.com/) by using static kotlinx.serialization serializers The "vertx-web-kotlinx" results in the Continuous Benchmarking results are much lower than those of the "vertx-web-kotlin-coroutines" portion. See [the latest results](https://www.techempower.com/benchmarks/#section=test&runid=592cab59-a9db-463b-a9c9-33d2f9484e92&hw=ph&test=db) for example. Looking at the "single query" results, I first suspected that it was caused by there being not enough memory for the JVM runtime, so I added some logging code that prints the memory usage using `Runtime.totalMemory` and `Runtime.maxMemory`. It showed that there was about 7 GB max memory available during the benchmark runs, and the program only used 400 MB to 1 GB. I then tried allocating a 4 GB array during the run to ensure that the memory was usable and it worked with no problem. Then looking at the "JSON serialization" results again, I saw that "vertx-web-kotlinx" performs a lot worse in this test too, and decided that this is more likely to be the bottleneck. Therefore, the static serializers are provided explicitly and the performance is improved slightly as tested on my machine. (Also, see commit 315b4e3 for an attempt before.) I then copied the "JSON serialization" test code from "vertx-web-kotlin-coroutines" and ran the benchmark to see if there were other factors, such as project configuration differences, affecting the performance, and the answer was no. On my machine, the "JSON serialization" performance of "vertx-web-kotlinx" is about 80% - 85% of that of "vertx-web-kotlin-coroutines". And I think the bottleneck possibly lies in kotlinx.serialization serializing an object to a byte array first and then copying it to a Vert.x buffer. Remove the broken tag in "vertx-web-kotlin-coroutines" BTW, which was added in commit e53e026, for the benchmark runs without problems now as I tested.
…a custom-implemented `VertxBufferSink` in JSON serialization The "JSON serialization" performance is on par with using `io.vertx.core.json.Json.encodeToBuffer` as tested on my machine after this change.
The "JSON serialization" performance seems to be slightly less.
…on-io' into kotlin-vertx-benchmarks-revamp Use `encodeToSink` in "kotlinx-serialization-json-io" with a custom-implemented `VertxBufferRawSink` in JSON serialization
…-kotlin#253 / vert-x3/vertx-lang-kotlin@e841975 There is no noticeable performance degradation in the "plaintext" and "JSON serialization" tests.
…icle` implement `CoroutineRouterSupport` I didn't go through [the docs](https://vertx.io/docs/vertx-lang-kotlin-coroutines/kotlin/#_vert_x_web) thoroughly before implementing this.
…' into kotlin-vertx-benchmarks-revamp
…g the changes made to the "vertx-web-kotlinx" portion The "gradlew" script somehow had incorrect access permissions and is fixed by bumping the Gradle wrapper. To keep the dependencies consistent with the "vert-web" portion, some dependencies are not updated to the latest versions. Remove 2 useless `COPY`s in "vertx-web-kotlin-coroutines-postgres.dockerfile" BTW.
Wrapping something as a Vert.x `Buffer` by implementing the `Buffer` interface is not viable because `BufferImpl` contains casts from a `Buffer` to a `BufferImpl`.
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Changes
In both projects
kotlin.jvmToolchainDSLvertx-web-kotlinx
installDistGradle task so the time for archiving and unarchiving is savedBufferas a kotlinx-ioRawSinkand replaceJson.encodeToStringwithJson.encodeToSinkin "kotlinx-serialization-json-io", which improves JSON serialization performance by about 15% to 20% as tested on my machine to be on par with that of "vertx-web-kotlin-coroutines"CoroutineRouterSupportAPIs from "vertx-lang-kotlin-coroutines"vertx-web-kotlin-coroutines
The benchmark runs fine on my machine, but if you encounter furthur problems in your enviroments, you can revert this and let me know. Thanks.
COPYs in "vertx-web-kotlin-coroutines-postgres.dockerfile"