Skip to content

Conversation

@ShreckYe
Copy link
Contributor

Changes

In both projects

  • bump the Gradle versions and the dependency versions to the latest
  • use the new kotlin.jvmToolchain DSL

vertx-web-kotlinx

  • bump the JVM version to 21
  • resolve deprecations
  • update the dockerfile to use the installDist Gradle task so the time for archiving and unarchiving is saved
  • enable io_uring
  • use static kotlinx.serialization serializers, which improves performance slightly
  • wrap a Vert.x Buffer as a kotlinx-io RawSink and replace Json.encodeToString with Json.encodeToSink in "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"
  • use the new CoroutineRouterSupport APIs from "vertx-lang-kotlin-coroutines"

vertx-web-kotlin-coroutines

  • remove the broken tag added in commit e53e026
    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.
  • The JVM version and some dependency versions are not bumped, and io_uring is not enabled, so that the project is consistent with the "vert-web" portion as stated in the README.
  • The "gradlew" script somehow had incorrect access permissions and is fixed by bumping the Gradle wrapper.
  • remove 2 useless COPYs in "vertx-web-kotlin-coroutines-postgres.dockerfile"

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.
…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`.
@NateBrady23 NateBrady23 merged commit fed744b into TechEmpower:master Nov 4, 2024
3 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants