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
This commit is contained in:
Norman Maurer 2020-09-22 17:27:25 +02:00 committed by GitHub
parent b112483799
commit 69f9a94f59
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -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;