Skip to content

Commit 9ed7352

Browse files
authored
Add Sysprop to Adjust IO Buffer Size (elastic#48267) (elastic#48667)
The 1MB IO-buffer size per transport thread is causing trouble in some tests, albeit at a low rate. Reducing the number of transport threads was not enough to fully fix this situation. Allowing to configure the size of the buffer and reducing it by more than an order of magnitude should fix these tests. Closes elastic#46803
1 parent 1b64c19 commit 9ed7352

File tree

2 files changed

+9
-1
lines changed

2 files changed

+9
-1
lines changed

modules/transport-netty4/src/main/java/org/elasticsearch/transport/CopyBytesSocketChannel.java

+3-1
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,7 @@
3939
import io.netty.channel.RecvByteBufAllocator;
4040
import io.netty.channel.socket.nio.NioSocketChannel;
4141
import org.elasticsearch.common.SuppressForbidden;
42+
import org.elasticsearch.common.unit.ByteSizeValue;
4243

4344
import java.io.IOException;
4445
import java.nio.ByteBuffer;
@@ -60,7 +61,8 @@
6061
@SuppressForbidden(reason = "Channel#write")
6162
public class CopyBytesSocketChannel extends NioSocketChannel {
6263

63-
private static final int MAX_BYTES_PER_WRITE = 1 << 20;
64+
private static final int MAX_BYTES_PER_WRITE = StrictMath.toIntExact(ByteSizeValue.parseBytesSizeValue(
65+
System.getProperty("es.transport.buffer.size", "1m"), "es.transport.buffer.size").getBytes());
6466

6567
private static final ThreadLocal<ByteBuffer> ioBuffer = ThreadLocal.withInitial(() -> ByteBuffer.allocateDirect(MAX_BYTES_PER_WRITE));
6668
private final WriteConfig writeConfig = new WriteConfig();

x-pack/plugin/security/build.gradle

+6
Original file line numberDiff line numberDiff line change
@@ -315,6 +315,12 @@ test {
315315
* other if we allow them to set the number of available processors as it's set-once in Netty.
316316
*/
317317
systemProperty 'es.set.netty.runtime.available.processors', 'false'
318+
319+
/*
320+
* Some tests in this module set up a lot of transport threads so we reduce the buffer size per transport thread from the 1M default
321+
* to keep direct memory usage under control.
322+
*/
323+
systemProperty 'es.transport.buffer.size', '256k'
318324
}
319325

320326
// xpack modules are installed in real clusters as the meta plugin, so

0 commit comments

Comments
 (0)