From 69f9a94f594007d6600d060f0198e59c5f6acbe3 Mon Sep 17 00:00:00 2001 From: Norman Maurer Date: Tue, 22 Sep 2020 17:27:25 +0200 Subject: [PATCH] Increase initial buffer size in AdaptiveRecvByteBufAllocator (#10600) Motivation: We should use an initial buffer size with is >= 1500 (which is a common setting for MTU) to reduce the need for memory copies when a new connection is established. This is especially interesting when SSL / TLS comes into the mix. This was ported from swiftnio: https://github.com/apple/swift-nio/pull/1641 Modifications: Increase the initial size from 1024 to 2048. Result: Possible less memory copies on new connections --- .../java/io/netty/channel/AdaptiveRecvByteBufAllocator.java | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/transport/src/main/java/io/netty/channel/AdaptiveRecvByteBufAllocator.java b/transport/src/main/java/io/netty/channel/AdaptiveRecvByteBufAllocator.java index d2456dd25b..93d7a803e9 100644 --- a/transport/src/main/java/io/netty/channel/AdaptiveRecvByteBufAllocator.java +++ b/transport/src/main/java/io/netty/channel/AdaptiveRecvByteBufAllocator.java @@ -35,7 +35,8 @@ import static java.lang.Math.min; public class AdaptiveRecvByteBufAllocator extends DefaultMaxMessagesRecvByteBufAllocator { static final int DEFAULT_MINIMUM = 64; - static final int DEFAULT_INITIAL = 1024; + // Use an initial value that is bigger than the common MTU of 1500 + static final int DEFAULT_INITIAL = 2048; static final int DEFAULT_MAXIMUM = 65536; private static final int INDEX_INCREMENT = 4;