-
Notifications
You must be signed in to change notification settings - Fork 2.8k
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
Use Jdk heap buffer pooling in Reactive SQL Clients #46865
base: main
Are you sure you want to change the base?
Conversation
See quarkusio#42224 To avoid having several sys props for config, reuse the existing one related to http server.
cc @franz1981 |
Status for workflow
|
🎊 PR Preview d702f49 has been successfully built and deployed to https://quarkus-pr-main-46865-preview.surge.sh/version/main/guides/
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I can't remember if the system property was documented (I think we said we wanted to keep it hidden for now). If it's documented we should amend the documentation to mention this new usage.
It's purposely not documented (for expert users only): |
Status for workflow
|
Hi @tsegismont similarly to the test performed by other users, please verify that it works as expected. In theory the difference is so big which should be a net win 🙏 |
I've created this project for testing: https://github.com/tsegismont/quarkus-ssl-jdk-buffer-pooling So far, this PR has no effect. With some debugging, I noticed that there is a difference between client/server when vert.x chooses the allocator. For servers: ByteBufAllocator serverByteBufAllocator(SslContextProvider ctxProvider) {
if (!ssl || usesJDKSSLWithPooledHeapBuffers(ctxProvider)) {
return PooledByteBufAllocator.DEFAULT;
}
return PartialPooledByteBufAllocator.INSTANCE;
} For clients: ByteBufAllocator clientByteBufAllocator(SslContextProvider ctxProvider) {
if (usesJDKSSLWithPooledHeapBuffers(ctxProvider)) {
return PooledByteBufAllocator.DEFAULT;
}
return PartialPooledByteBufAllocator.INSTANCE;
}
private boolean usesJDKSSLWithPooledHeapBuffers(SslContextProvider ctxProvider) {
return ssl && sslEngineOptions instanceof JdkSSLEngineOptions &&
ctxProvider.jdkSSLProvider() &&
((JdkSSLEngineOptions) sslEngineOptions).isPooledHeapBuffers();
} With PgClient, this @franz1981 why is there a difference between the two methods in the PR you sent? eclipse-vertx/vert.x#5316 |
It was to grant that without the configured option (i.e
Argh! Actually I've implemented what I've done assuming HTTP (which doesn't have a common Another option would be to rework what I've done in Vertx and just have a sys property which enable using the right allocator regardless - overriding the decision upfront: I've discarded this option at the time of the change, to save having a global behaviour enforced - but it's likely the easiest solution. |
Exactly |
@franz1981 More details about upstream The ability to switch between the Vert.x so-called partial byte buffer allocator and the default pooled allocator was introduced in 4.2 with eclipse-vertx/vert.x#4110 A key point is that buffers are converted to "safe" buffers if they were allocated from any pooling allocator (or they are composite). To my knowledge, this is safety check is in place for both servers and clients so, with some extra tests to make sure all is good, I think we could merge the two methods in SSLHelper into one: ByteBufAllocator byteBufAllocator(SslContextProvider ctxProvider) {
if (!ssl || usesJDKSSLWithPooledHeapBuffers(ctxProvider)) {
return PooledByteBufAllocator.DEFAULT;
}
return PartialPooledByteBufAllocator.INSTANCE;
}
That is certainly cheaper to do, and given the sysprop is for advanced users and not documented, perhaps the way to go. But before getting started, I'd like to know if @vietj has any comment on this. |
Just to add some color why it could be concerning to use a partial allocator as the one defined in vertx: https://github.com/eclipse-vertx/vert.x/blob/adbe97600cc6215f15ce2fac629c89f93618ca8f/src/main/java/io/vertx/core/buffer/impl/PartialPooledByteBufAllocator.java#L44 This is overriding the buffer method which is not just available to users and internal vertx code, but to Netty itself, see https://github.com/netty/netty/blob/0ec94939a1deb86b4bd96e6c3198304acad8e1ae/codec-http/src/main/java/io/netty/handler/codec/http/HttpObjectEncoder.java#L328 Which shows that Netty can start to unexpectedly allocate big unpooled heap buffers where it usually allocate direct pooled ones. |
See #42224
To avoid having several sys props for config, reuse the existing one related to http server.