Skip to content

Commit

Permalink
Change default of iosqeAsyncThreshold to Integer.MAX_VALUE (#233)
Browse files Browse the repository at this point in the history
  • Loading branch information
yawkat authored Jan 24, 2024
1 parent b70fb97 commit b047cec
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 7 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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.
* <p>
* 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;
Expand Down Expand Up @@ -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) {
Expand Down Expand Up @@ -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) {
Expand Down

0 comments on commit b047cec

Please sign in to comment.