From b047ceca178996fec707b0820807e11edfbd8792 Mon Sep 17 00:00:00 2001 From: Jonas Konrad Date: Wed, 24 Jan 2024 16:39:01 +0100 Subject: [PATCH] Change default of iosqeAsyncThreshold to Integer.MAX_VALUE (#233) --- .../channel/uring/IOUringEventLoopGroup.java | 6 +++--- .../io/netty/incubator/channel/uring/Native.java | 15 +++++++++++---- 2 files changed, 14 insertions(+), 7 deletions(-) diff --git a/transport-classes-io_uring/src/main/java/io/netty/incubator/channel/uring/IOUringEventLoopGroup.java b/transport-classes-io_uring/src/main/java/io/netty/incubator/channel/uring/IOUringEventLoopGroup.java index f0c86904..fbb2f21d 100644 --- a/transport-classes-io_uring/src/main/java/io/netty/incubator/channel/uring/IOUringEventLoopGroup.java +++ b/transport-classes-io_uring/src/main/java/io/netty/incubator/channel/uring/IOUringEventLoopGroup.java @@ -52,21 +52,21 @@ public IOUringEventLoopGroup(int nThreads) { * Create a new instance using the default number of threads and the given {@link ThreadFactory}. */ public IOUringEventLoopGroup(ThreadFactory threadFactory) { - this(0, threadFactory, 0, Native.DEFAULT_IOSEQ_ASYNC_THRESHOLD); + this(0, threadFactory, 0, Native.DEFAULT_IOSQE_ASYNC_THRESHOLD); } /** * Create a new instance using the specified number of threads and the given {@link ThreadFactory}. */ public IOUringEventLoopGroup(int nThreads, ThreadFactory threadFactory) { - this(nThreads, threadFactory, 0, Native.DEFAULT_IOSEQ_ASYNC_THRESHOLD); + this(nThreads, threadFactory, 0, Native.DEFAULT_IOSQE_ASYNC_THRESHOLD); } /** * Create a new instance using the specified number of threads and the given {@link Executor}. */ public IOUringEventLoopGroup(int nThreads, Executor executor) { - this(nThreads, executor, 0, Native.DEFAULT_IOSEQ_ASYNC_THRESHOLD); + this(nThreads, executor, 0, Native.DEFAULT_IOSQE_ASYNC_THRESHOLD); } /** diff --git a/transport-classes-io_uring/src/main/java/io/netty/incubator/channel/uring/Native.java b/transport-classes-io_uring/src/main/java/io/netty/incubator/channel/uring/Native.java index 6b09b54c..a4ee381e 100644 --- a/transport-classes-io_uring/src/main/java/io/netty/incubator/channel/uring/Native.java +++ b/transport-classes-io_uring/src/main/java/io/netty/incubator/channel/uring/Native.java @@ -40,8 +40,15 @@ final class Native { private static final InternalLogger logger = InternalLoggerFactory.getInstance(Native.class); static final int DEFAULT_RING_SIZE = Math.max(64, SystemPropertyUtil.getInt("io.netty.iouring.ringSize", 4096)); - static final int DEFAULT_IOSEQ_ASYNC_THRESHOLD = - Math.max(0, SystemPropertyUtil.getInt("io.netty.iouring.iosqeAsyncThreshold", 25)); + /** + * When there are more FDs (= connections) than this setting, the FDs will be marked as IOSQE_ASYNC, under the + * expectation that read/write ops on the FDs will usually block. If this expectation is correct, IOSQE_ASYNC can + * reduce CPU usage, but if the expectation is incorrect, it may add additional, unnecessary latency. + *

+ * Default is to never use IOSQE_ASYNC. + */ + static final int DEFAULT_IOSQE_ASYNC_THRESHOLD = + Math.max(0, SystemPropertyUtil.getInt("io.netty.iouring.iosqeAsyncThreshold", Integer.MAX_VALUE)); static { Selector selector = null; @@ -194,7 +201,7 @@ public void run() { (TCP_FASTOPEN_MODE & TFO_ENABLED_SERVER_MASK) == TFO_ENABLED_SERVER_MASK; static RingBuffer createRingBuffer(int ringSize) { - return createRingBuffer(ringSize, DEFAULT_IOSEQ_ASYNC_THRESHOLD); + return createRingBuffer(ringSize, DEFAULT_IOSQE_ASYNC_THRESHOLD); } static RingBuffer createRingBuffer(int ringSize, int iosqeAsyncThreshold) { @@ -231,7 +238,7 @@ static RingBuffer createRingBuffer(int ringSize, int iosqeAsyncThreshold) { } static RingBuffer createRingBuffer() { - return createRingBuffer(DEFAULT_RING_SIZE, DEFAULT_IOSEQ_ASYNC_THRESHOLD); + return createRingBuffer(DEFAULT_RING_SIZE, DEFAULT_IOSQE_ASYNC_THRESHOLD); } static void checkAllIOSupported(int ringFd) {