Skip to content

Commit f52405d

Browse files
authored
IoUring: Explicit set CQSIZE by default and use a much saner default … (#15477)
…value for the submission ring Motivation: As default we used a size of 4096 for the submission ring which these days does not make a lot of sense anymore as you can size the submission queue and completion queue seperately. Generally speaking usually you see much more completions compared to submissions, especially as we enable multishot by default these days. Beside this you should also not batch too much in general before submission as this will affect latency. Because of this we should use a more sane default value for the submission queue which will also ensure we submit fast enough while still get some batching to reduce syscalls. Also we need to size the completion queue big enough to be able to receive enough completioms per batch. Modifications: - Change the default submission queue size to 128 - Change the default completion queue size to 4096 Result: Better defaults
1 parent b23e304 commit f52405d

3 files changed

Lines changed: 15 additions & 5 deletions

File tree

transport-classes-io_uring/src/main/java/io/netty/channel/uring/IoUring.java

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,9 @@ public final class IoUring {
4949
private static final boolean IORING_RECVSEND_BUNDLE_ENABLED;
5050
private static final boolean IORING_POLL_ADD_MULTISHOT_ENABLED;
5151
static final int NUM_ELEMENTS_IOVEC;
52+
static final int DEFAULT_RING_SIZE;
53+
static final int DEFAULT_CQ_SIZE;
54+
static final int DISABLE_SETUP_CQ_SIZE = -1;
5255

5356
private static final InternalLogger logger;
5457

@@ -188,6 +191,15 @@ public final class IoUring {
188191
IORING_POLL_ADD_MULTISHOT_ENABLED = IORING_POLL_ADD_MULTISHOT_SUPPORTED && SystemPropertyUtil.getBoolean(
189192
"io.netty.iouring.pollAddMultishotEnabled", true);
190193
NUM_ELEMENTS_IOVEC = numElementsIoVec;
194+
195+
DEFAULT_RING_SIZE = Math.max(16, SystemPropertyUtil.getInt("io.netty.iouring.ringSize", 128));
196+
197+
if (IORING_SETUP_CQ_SIZE_SUPPORTED) {
198+
DEFAULT_CQ_SIZE = Math.max(DEFAULT_RING_SIZE,
199+
SystemPropertyUtil.getInt("io.netty.iouring.cqSize", 4096));
200+
} else {
201+
DEFAULT_CQ_SIZE = DISABLE_SETUP_CQ_SIZE;
202+
}
191203
}
192204

193205
public static boolean isAvailable() {

transport-classes-io_uring/src/main/java/io/netty/channel/uring/IoUringIoHandlerConfig.java

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -97,10 +97,9 @@
9797
*/
9898

9999
public final class IoUringIoHandlerConfig {
100-
private static final int DISABLE_SETUP_CQ_SIZE = -1;
101100

102-
private int ringSize = Native.DEFAULT_RING_SIZE;
103-
private int cqSize = DISABLE_SETUP_CQ_SIZE;
101+
private int ringSize = IoUring.DEFAULT_RING_SIZE;
102+
private int cqSize = IoUring.DEFAULT_CQ_SIZE;
104103

105104
private int maxBoundedWorker;
106105

@@ -227,7 +226,7 @@ boolean needRegisterIowqMaxWorker() {
227226
}
228227

229228
boolean needSetupCqeSize() {
230-
return cqSize != DISABLE_SETUP_CQ_SIZE;
229+
return cqSize != IoUring.DISABLE_SETUP_CQ_SIZE;
231230
}
232231

233232
Set<IoUringBufferRingConfig> getInternBufferRingConfigs() {

transport-classes-io_uring/src/main/java/io/netty/channel/uring/Native.java

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,6 @@
3838

3939
final class Native {
4040
private static final InternalLogger logger = InternalLoggerFactory.getInstance(Native.class);
41-
static final int DEFAULT_RING_SIZE = Math.max(64, SystemPropertyUtil.getInt("io.netty.iouring.ringSize", 4096));
4241

4342
static {
4443
Selector selector = null;

0 commit comments

Comments
 (0)