Skip to main content

Config

Struct Config 

Source
pub struct Config {
Show 31 fields pub sq_entries: u32, pub sqpoll: bool, pub sqpoll_idle_ms: u32, pub sqpoll_cpu: Option<u32>, pub recv_buffer: RecvBufferConfig, pub udp_recv_buffer: RecvBufferConfig, pub registered_regions: Vec<MemoryRegion>, pub worker: WorkerConfig, pub backlog: i32, pub max_connections: u32, pub recv_accumulator_capacity: usize, pub send_copy_count: u16, pub send_copy_slot_size: u32, pub send_slab_slots: u16, pub flush_interval_us: u64, pub tick_timeout_us: u64, pub tls: Option<TlsConfig>, pub tls_client: Option<TlsClientConfig>, pub tcp_nodelay: bool, pub max_chain_length: u16, pub standalone_task_capacity: u32, pub timer_slots: u32, pub udp_bind: Vec<SocketAddr>, pub udp_send_slots: u16, pub nvme: Option<NvmeConfig>, pub direct_io: Option<DirectIoConfig>, pub fs: Option<FsConfig>, pub resolver_threads: usize, pub spawner_threads: usize, pub blocking_threads: usize, pub disk_io_threads: usize,
}
Expand description

Configuration for the io_uring driver.

Fields§

§sq_entries: u32

Number of SQ entries. CQ will be 4x this.

§sqpoll: bool

Enable SQPOLL mode (kernel-side submission polling).

§sqpoll_idle_ms: u32

SQPOLL idle timeout in milliseconds.

§sqpoll_cpu: Option<u32>

Pin SQPOLL kernel thread to this CPU core. Only meaningful when sqpoll=true.

§recv_buffer: RecvBufferConfig

Recv buffer configuration (provided buffer ring) for TCP multishot recv.

§udp_recv_buffer: RecvBufferConfig

Recv buffer configuration for UDP multishot recvmsg.

UDP uses a separate provided buffer ring from TCP so the two can be sized independently. Each buffer must fit an io_uring_recvmsg_out header (16 bytes) + sockaddr_storage (128 bytes) + the datagram payload. Default: 128 buffers × 2048 bytes (room for a standard-MTU datagram plus the multishot metadata); bump buffer_size if you expect jumbo datagrams.

bgid must differ from recv_buffer.bgid when UDP is in use.

§registered_regions: Vec<MemoryRegion>

User-registered memory regions (e.g., mmap’d storage arenas).

§worker: WorkerConfig

Worker/thread configuration.

§backlog: i32

TCP listen backlog.

§max_connections: u32

Maximum number of direct file descriptors (connections).

§recv_accumulator_capacity: usize

Initial capacity for per-connection recv accumulators.

§send_copy_count: u16

Number of copy-send pool slots. Each in-flight send() or copy part of a send_parts() call holds one slot until the kernel completes the send. Size this to cover your peak in-flight send count — exhaustion returns an error to the handler. Memory cost: send_copy_count * send_copy_slot_size.

§send_copy_slot_size: u32

Size of each copy-send pool slot in bytes. A single send() or the combined copy parts of one send_parts() call must fit in one slot.

§send_slab_slots: u16

Number of InFlightSendSlab slots for in-flight scatter-gather sends (i.e., send_parts() calls that include at least one guard). Each slot is held until all ZC notifications arrive.

§flush_interval_us: u64

Deadline-based flush interval in microseconds during CQE processing. When non-SQPOLL, if this many microseconds elapse since the last submit while processing a CQE batch, pending SQEs are flushed mid-iteration. 0 = disabled. Ignored when SQPOLL is active (kernel handles it).

§tick_timeout_us: u64

Maximum time in microseconds that submit_and_wait will block before returning to call on_tick. Prevents the event loop from stalling when there are no pending completions (e.g., client-only mode between phases). 0 = no timeout (block indefinitely until a CQE arrives). Default: 1000 (1ms).

§tls: Option<TlsConfig>

Optional TLS configuration. When set, all accepted connections use TLS.

§tls_client: Option<TlsClientConfig>

Optional TLS client configuration for outbound connect_tls() calls.

§tcp_nodelay: bool

Enable TCP_NODELAY on all connections (accepted and outbound).

§max_chain_length: u16

Maximum number of SQEs per IOSQE_IO_LINK chain. 0 disables chaining. When disabled, sends exceeding MAX_IOVECS fall back to sequential round-trips (one SQE at a time via on_send_complete). Default: 16.

§standalone_task_capacity: u32

Maximum number of standalone async tasks (not bound to connections) per worker. Used with spawn(). Default: 256.

§timer_slots: u32

Maximum number of concurrent timer slots per worker. Used by sleep() and timeout(). Default: 256.

§udp_bind: Vec<SocketAddr>

UDP bind addresses. Each worker creates its own socket with SO_REUSEPORT. Empty = no UDP sockets.

§udp_send_slots: u16

Number of concurrent in-flight UDP sends per socket. Each slot owns a pre-allocated sockaddr_storage + iovec + msghdr triple used to submit a sendmsg SQE; the slot is returned to the freelist on CQE. Exhaustion returns crate::error::UdpSendError::PoolExhausted. Default: 64.

§nvme: Option<NvmeConfig>

Optional NVMe passthrough configuration. When set, enables NVMe device management and IORING_OP_URING_CMD submission for direct NVMe I/O.

§direct_io: Option<DirectIoConfig>

Optional direct I/O configuration. When set, enables O_DIRECT file I/O via io_uring IORING_OP_READ / IORING_OP_WRITE, bypassing the page cache.

§fs: Option<FsConfig>

Optional buffered filesystem I/O configuration. When set, enables async file open/read/write/stat/rename/unlink/mkdir via io_uring.

§resolver_threads: usize

Number of dedicated DNS resolver threads. The resolver pool runs getaddrinfo on background threads, keeping blocking DNS isolated from the io_uring event loop.

0 = disabled (no resolver pool; resolve() will return an error). Default: 2.

§spawner_threads: usize

Number of dedicated process spawner threads. The spawner pool runs posix_spawnp + pidfd_open on background threads, keeping blocking process creation isolated from the io_uring event loop.

0 = disabled (no spawner pool; Command::spawn() will return an error). Default: 1.

§blocking_threads: usize

Number of dedicated blocking threads. The blocking pool runs user-provided closures on low-priority (SCHED_IDLE) background threads, keeping CPU-bound or blocking work isolated from the io_uring event loop.

0 = disabled (no blocking pool; spawn_blocking() will return an error). Default: 4.

§disk_io_threads: usize

Number of dedicated disk I/O threads (mio backend only). The disk I/O pool executes blocking filesystem syscalls (pread, pwrite, fsync, stat, rename, unlink, mkdir) on background threads, enabling async file I/O on non-Linux platforms.

0 = disabled (filesystem/direct I/O operations return Unsupported). Default: 2.

Implementations§

Source§

impl Config

Source

pub fn validate(&self) -> Result<(), Error>

Validate configuration values. Returns an error if any value is out of range.

Trait Implementations§

Source§

impl Clone for Config

Source§

fn clone(&self) -> Config

Returns a duplicate of the value. Read more
1.0.0 · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Default for Config

Source§

fn default() -> Self

Returns the “default value” for a type. Read more

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.