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() (#17382) by normanmaurer · Pull Request #17413 · netty/netty Conversation
Member
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 reactionsMotivation: 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 ```
|
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-aarch64-java25-boringssl build > Netty/Transport/Native/KQueue
🏷️ Commit: 233437c Test FailuresKQueueDatagramUnicastIPv6MappedTest > testSimpleSendHeapByteBuf(TestInfo) (Netty/Transport/Native/KQueue in Build PR / macos-aarch64-java25-boringssl build)Rerun ControlsNote Checks are currently running using the configuration below. Select tests to mute in this pull request: 🔲 KQueueDatagramUnicastIPv6MappedTest > testSimpleSendHeapByteBuf(TestInfo) Reuse successful test results: 🔲 ♻️ Only rerun the tests that failed or were muted before Click the checkbox to trigger a rerun: 🔲 Rerun jobs 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.
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.