Remove Netty UnpooledByteBufAllocator workaround#6967
Conversation
If using the JDK SSL provider with Netty, we currently switch away from Netty's default ByteBuffer allocator to the unpooled allocator, to work around a regression in Netty 4.1.43 - netty/netty#9768. This has been fixed in later versions, so we should revert back to using the default. This is essentially a revert of the relevant parts of a72f494. Reduces allocation rate on NettyHttpClientH1Benchmark by around 45% when using the JDK SSL provider.
|
Hi @olivergillespie , Thanks for the high quality PR. Can you share a little bit of info about the JVM version, and machine architecture you are running the JMH benchmarks on? We usually run benchmarks with at least 2 forks to minimize noise. Can you please rerun those benchmarks with additional forks? Additionally you mentioned
Do you have any benchmarks that show the increase in throughput? All the best, |
|
Thanks @RanVaknin. My original results were with Corretto 17.0.19 on x86 (AWS EC2 m5.4xl). Allocation per op is usually not noisy and doesn't vary fork to fork or across architectures, nor JVM version (in most cases, compiler optimizations and object layout can vary but since the key here is large byte buffers it won't make a difference) but for completeness I've run again with 5 forks on both x86 (Corretto 17.0.19m m5.4xl) and aarch64 (Corretto 21.0.8, m6g.xl). The improvement holds. The same benchmarks are what (initially) showed the throughput improvement - sequentialApiCall op/s increased by 8% - but seems like this was just noise, it's not reproduced in these runs with more forks. I've updated the description to remove that part, it's not the point of this change anyway. Throughput (ops/s)
Allocation Rate (B/op)
|
|
Merged in #6968, thanks! |
Motivation and Context
If using the JDK SSL provider with Netty, we currently switch away from Netty's default ByteBuffer allocator to the unpooled allocator, to work around a regression in Netty 4.1.43 -
netty/netty#9768.
The unpooled allocator causes high allocation rate, increasing GC frequency and reducing application throughput.
The Netty issue has been fixed in later versions, so we should revert back to using the default.
Fixes #6843
Modifications
This is essentially a revert of the relevant parts of a72f494ac1fb. Don't override the buffer allocator, and remove the wiring that was added just to allow that. Also remove the test that only tests that behaviour, no longer useful. Now, whatever the environment default allocator is will be respected.
Testing
Benchmark Results
We can see huge allocation rate reduction
along with some throughput improvementwhen using JDK provider, and no effect when using the OpenSSL provider, as expected.sslProvider = JDK
sslProvider = OpenSSL
Screenshots (if appropriate)
Types of changes
Checklist
mvn installsucceedsscripts/new-changescript and following the instructions. Commit the new file created by the script in.changes/next-releasewith your changes.License