GeezerVisonThe World Wide Web, restored to 800 pixels of glory. | |||||||||
| Home|About|Gaming cabinet|Archives|How it works|Starter sites | |||||||||
GeezerVison is showing github.com — Avoid double promise allocation in SslHandler.wrap() by doom369 · Pull Request #17382 · netty/netty Conversation
Contributor
Motivation: Production allocation profiling identified
Flow: Modification: Added a guard check Result: Less garbage in SslHandler for outgoing packets.
Sorry, something went wrong. Uh oh!
There was an error while loading. Please reload this page. All reactions
franz1981
approved these changes
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. LGTM let's see the CI!
Sorry, something went wrong. Uh oh!
There was an error while loading. Please reload this page. All reactions
|
There was an error while loading. Please reload this page.
🚨 TestLens detected 1 failed test 🚨Here is what you can do:
Test SummaryBuild PR / macos-x86_64-java11-boringssl build > Netty/Transport/Native/KQueue
🏷️ Commit: 67b60c1 Test FailuresKQueueDatagramUnicastIPv6MappedTest > testSimpleSendWithConnect(TestInfo) (Netty/Transport/Native/KQueue in Build PR / macos-x86_64-java11-boringssl build)Rerun ControlsSelect tests to mute in this pull request:
Reuse successful test results:
Click the checkbox to trigger a rerun:
Learn more about TestLens at testlens.app/docs. |
Sorry, something went wrong.
There was an error while loading. Please reload this page.
There was an error while loading. Please reload this page.
|
Could not create auto-port PR. |
Sorry, something went wrong.
There was an error while loading. Please reload this page.
|
PR for 5.0: #17413 |
Sorry, something went wrong.
There was an error while loading. Please reload this page.
Motivation: Production allocation profiling identified `SslHandler.wrap()`'s `ctx.newPromise()` as the source of ~79% of sampled `DefaultChannelPromise` allocations. `wrap()` allocates the promise before checking whether `pendingUnencryptedWrites` contains another entry. After the last entry is consumed, the loop may iterate once more, allocate a `ChannelPromise`, receive null from remove/removeFirst, and immediately discard the promise. <img width="1538" height="110" alt="image" src="https://github.com/user-attachments/assets/e567e5f5-281e-4fcd-8c64-d5e5a320efcd" /> Flow: ``` iteration #1 newPromise() // useful removeFirst() -> buf encrypt buf queue now empty iteration #2 newPromise() // wasted allocation removeFirst() -> null break ``` Modification: Added a guard check `!pendingUnencryptedWrites.isEmpty()` to avoid unnecessary loop iteration. Result: Less garbage in SslHandler for outgoing packets. ``` import io.netty.buffer.ByteBuf; import org.openjdk.jmh.annotations.Benchmark; public class SslHandlerWrapBenchmark extends AbstractSslHandlerThroughputBenchmark { @benchmark public int wrapOneWrite() throws Exception { ByteBuf encrypted = doWrite(1); try { return encrypted.readableBytes(); } finally { encrypted.release(); } } } ``` ``` baseline: 1411.886 B/op patched: 1336.061 B/op delta: 75.825 B/op ``` Co-authored-by: Dmytro Dumanskiy <[email protected]>
There was an error while loading. Please reload this page.
Successfully merging this pull request may close these issues.
There was an error while loading. Please reload this page.