-
Notifications
You must be signed in to change notification settings - Fork 1.9k
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
Server configuration for direct/heap ByteBuffers #3952
Comments
On the read side, the place where we need to know whether to use heap/direct buffers is typically from On the write side, the place where we need to know whether to use heap/direct buffers is typically in the generation phase, where we take some application content (could be heap or direct) and we need to generate some additional framing around it. HttpOutput.write(byte[]) // writes to aggregate buffer or it's wrapped
HttpOutput.Interceptor.write(ByteBuffer, boolean, Callback)
HttpChannel.write(ByteBuffer, boolean, Callback)
HttpTransport.send(..., ByteBuffer, boolean, Callback)
|
My proposal is the following:
To remove:
To change:
All of the above is proposed for Jetty 10 only, where we can remove methods. |
I think that if we are to remove the The problem is that I don't think we yet really understand the pros/cons of using Direct buffers. I'm sure that the assumptions about them that existed when this code was written have changed a lot, so we definitely need to update this code. But the assumption now appears to be that using direct buffers now is all pro and no con? If it is true (and I'm dubious), then we should just remove the ability to configure it at all. So I think further research is need for us to better understand the current tradeoffs before we propose any API changes. We need to hurry up with this as the door for major API changes in 10 is closing |
We know that direct buffers are not much different from heap buffers to read one byte at a time. We know they are better for raw reads and raw writes because there is one less copy involved (done by the JVM). I don't know think we need further research - we know read wise they are comparable, and write wise direct buffers perform less copies. |
OK - I'm still dubious that it is all upside for direct buffers.... but if we can mostly run with them then getting rid of the |
Updated server-side to use direct/heap ByteBuffers based on getters and setters in the relevant components. Made HTTP/1.1, HTTP/2, and WebSocket use the same mechanism. Removed unused obsoleted methods: * EndPoint.isOptimizedForDirectBuffers() * HttpTransport.isOptimizedForDirectBuffers() * HttpOutput.Interceptor.isOptimizedForDirectBuffers() * HttpChannel.useDirectBuffers() Signed-off-by: Simone Bordet <simone.bordet@gmail.com>
…_heap_bytebuffers Fixes #3952 - Server configuration for direct/heap ByteBuffers.
This issue aggregates #183, #226, #351, #2135.
Currently we have a number of configurations for dealing with direct/heap buffers:
HttpConfiguration.useDirectBuffers
- introduced in master: Support Direct Byte Buffers #348 for Jetty 9.x: Support Direct Byte Buffers #351. While I don't think this is a HTTP configuration (it's more a ServerConnector/ConnectionFactory configuration) I guess it's ok to have it here as we also haveHttpConfiguration.idleTimeout
. Javadocs forHttpConfiguration.useDirectBuffers
says it's about requests, but it is in fact applied to responses too. It is only used inHttpConnection
so not for SSL and neither for HTTP/2 nor WebSocket.EndPoint.isOptimizedForDirectBuffers()
- this is a getter only property that supposedly tells whether theEndPoint
works better with direct buffers. I think there are wrong assumptions here, such as "TLS EndPoints will work better with heap buffers" which may be true when using the JDK TLS implementation (and even then it's questionable if it really is), but it's wrong when we use native implementations such as Conscrypt. I believe this getter should be completely removed since it's based on wrong assumptions.HttpTransport.isOptimizedForDirectBuffers()
- write side only and trickled up fromEndPoint
, same observations, should be removed.HttpOutput.Interceptor.isOptimizedForDirectBuffers()
- ditto.HttpChannel.isOptimizedForDirectBuffers()
- ditto. This is inherited fromHttpOutput.Interceptor
.HttpChannel.useDirectBuffers()
- this is a getter only property that is a duplicate in functionality forHttpChannel.isOptimizedForDirectBuffers()
and it's used in the write side byHttpOutput
so nowHttpChannel
has 2 getters for the same thing andHttpOutput
looks sometimes at one and sometimes at the other - should be removed.SslConnectionFactory.directBuffersFor[Encryption|Decryption]
- introduced by Android 8.1 needs direct buffers for SSL/TLS to work #2135 used only bySslConnection
which defeatsEndPoint.isOptimizedForDirectBuffers()
.The text was updated successfully, but these errors were encountered: