Package io.netty.channel.uring
Class IoUringIoHandlerConfig
- java.lang.Object
-
- io.netty.channel.uring.IoUringIoHandlerConfig
-
public final class IoUringIoHandlerConfig extends java.lang.ObjectConfiguration class for anIoUringIoHandler, managing the settings for aRingBufferand its io_uring file descriptor.Option Map
These options are used exclusively during the initialization of theIoUringIoHandlerto configure the associated io_uring instance.The
IoUringIoHandlerConfigclass provides the following configurable options:Available Configuration Options Setter Method Description setRingSize(int)Sets the size of the submission queue for the io_uring instance.
If you want to submit a large number of io_uring requests at once, it is recommended to properly configure this option. The default value is 4096, which is sufficient for most scenarios.setMaxBoundedWorker(int)Defines the maximum number of bounded io_uring worker threads.
If you extend io_uring-related file operations based on Netty, it is recommended to properly configure this option. For more details, refer to thesetMaxUnboundedWorker(int)Defines the maximum number of unbounded io_uring worker threads.
If you use FileRegion to perform `sendfile` operations in io_uring, it is recommended to properly configure this option as otherwise you might end up with ansetCqSize(int)Sets the size of the completionQueue queue for the io_uring instance.
If your current kernel supports some multishot variants (such as IORING_RECV_MULTISHOT, IORING_ACCEPT_MULTISHOT) or IORING_RECVSEND_BUNDLE, and you want to handle more CQEs in a single syscall it is recommended to properly configure this option. The default value is twice the ring size, which is sufficient for most scenarios.setBufferRingConfig(io.netty.channel.uring.IoUringBufferRingConfig...)Adds a buffer ring configuration to the list of buffer ring configurations. It will be used to register the buffer ring for the io_uring instance. setSingleIssuer(boolean)Enable or disable the use of IORING_SETUP_SINGLE_ISSUER.
-
-
Constructor Summary
Constructors Constructor Description IoUringIoHandlerConfig()
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description java.util.List<IoUringBufferRingConfig>getBufferRingConfigs()Get the list of buffer ring configurations.intgetCqSize()Return the size of the io_uring cqe.intgetMaxBoundedWorker()Return the maximum number of bounded iowq worker threads.intgetMaxUnboundedWorker()Return the maximum number of unbounded iowq worker threads.intgetRingSize()Return the ring size of the io_uring instance.IoUringIoHandlerConfigsetBufferRingConfig(IoUringBufferRingConfig... ringConfig)Add a buffer ring configuration to the list of buffer ring configurations.IoUringIoHandlerConfigsetCqSize(int cqSize)Set the size of the io_uring cqe.IoUringIoHandlerConfigsetMaxBoundedWorker(int maxBoundedWorker)Set the maximum number of bounded iowq worker threads.IoUringIoHandlerConfigsetMaxUnboundedWorker(int maxUnboundedWorker)Set the maximum number of unbounded iowq worker threads.IoUringIoHandlerConfigsetRingSize(int ringSize)Set the ring size of the io_uring instance.IoUringIoHandlerConfigsetSingleIssuer(boolean singleIssuer)Set ifIORING_SETUP_SINGLE_ISSUERshould be used when setup the ring.
-
-
-
Method Detail
-
getRingSize
public int getRingSize()
Return the ring size of the io_uring instance.- Returns:
- the ring size of the io_uring instance.
-
getCqSize
public int getCqSize()
Return the size of the io_uring cqe.- Returns:
- the cq size of the io_uring.
-
getMaxBoundedWorker
public int getMaxBoundedWorker()
Return the maximum number of bounded iowq worker threads.- Returns:
- the maximum number of bounded iowq worker threads.
-
getMaxUnboundedWorker
public int getMaxUnboundedWorker()
Return the maximum number of unbounded iowq worker threads.- Returns:
- the maximum number of unbounded iowq worker threads.
-
setRingSize
public IoUringIoHandlerConfig setRingSize(int ringSize)
Set the ring size of the io_uring instance.- Parameters:
ringSize- the ring size of the io_uring instance.- Returns:
- reference to this, so the API can be used fluently
-
setCqSize
public IoUringIoHandlerConfig setCqSize(int cqSize)
Set the size of the io_uring cqe.- Parameters:
cqSize- the size of the io_uring cqe.- Returns:
- reference to this, so the API can be used fluently
- Throws:
java.lang.IllegalArgumentException- if cqSize is less than ringSize, or not a power of 2
-
setMaxBoundedWorker
public IoUringIoHandlerConfig setMaxBoundedWorker(int maxBoundedWorker)
Set the maximum number of bounded iowq worker threads.- Parameters:
maxBoundedWorker- the maximum number of bounded iowq worker threads, or 0 for the Linux kernel default- Returns:
- reference to this, so the API can be used fluently
-
setMaxUnboundedWorker
public IoUringIoHandlerConfig setMaxUnboundedWorker(int maxUnboundedWorker)
Set the maximum number of unbounded iowq worker threads.- Parameters:
maxUnboundedWorker- the maximum number of unbounded iowq worker threads, of 0 for the Linux kernel default- Returns:
- reference to this, so the API can be used fluently
-
setBufferRingConfig
public IoUringIoHandlerConfig setBufferRingConfig(IoUringBufferRingConfig... ringConfig)
Add a buffer ring configuration to the list of buffer ring configurations. EachIoUringBufferRingConfigmust have a differentIoUringBufferRingConfig.bufferGroupId().- Parameters:
ringConfig- the buffer ring configuration to append.- Returns:
- reference to this, so the API can be used fluently
-
setSingleIssuer
public IoUringIoHandlerConfig setSingleIssuer(boolean singleIssuer)
Set ifIORING_SETUP_SINGLE_ISSUERshould be used when setup the ring. This istrueby default for performance reasons but also means that theThreadthat is used to drive theIoHandlercan never change. If you want the flexibility to change theThread, to for example make use of theAutoScalingEventExecutorChooserFactoryit's possible to not useIORING_SETUP_SINGLE_ISSUER. This will trade scalibility / flexibility and performance.- Parameters:
singleIssuer-trueifIORING_SETUP_SINGLE_ISSUERshould be used,falseotherwise- Returns:
- reference to this, so the API can be used fluently
-
getBufferRingConfigs
public java.util.List<IoUringBufferRingConfig> getBufferRingConfigs()
Get the list of buffer ring configurations.- Returns:
- the copy of buffer ring configurations.
-
-