Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 18 additions & 0 deletions compio-driver/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -545,6 +545,7 @@ pub struct ProactorBuilder {
capacity: u32,
pool_builder: ThreadPoolBuilder,
sqpoll_idle: Option<Duration>,
sqpoll_cpu_affinity: Option<u32>,
cqsize: Option<u32>,
coop_taskrun: bool,
taskrun_flag: bool,
Expand Down Expand Up @@ -574,6 +575,7 @@ impl ProactorBuilder {
capacity: 1024,
pool_builder: ThreadPoolBuilder::new(),
sqpoll_idle: None,
sqpoll_cpu_affinity: None,
cqsize: None,
coop_taskrun: false,
taskrun_flag: false,
Expand Down Expand Up @@ -660,6 +662,22 @@ impl ProactorBuilder {
self
}

/// Set CPU affinity for the `io-uring` SQPOLL thread when SQPOLL is
/// enabled.
///
/// This is only applied when SQPOLL is enabled with
/// [`sqpoll_idle`](Self::sqpoll_idle).
///
/// # Notes
///
/// - Only effective when the `io-uring` feature is enabled
/// - `cpu` must be less than the number of cpus in the system, otherwise it
/// will return an error when building the proactor.
pub fn sqpoll_cpu_affinity(&mut self, cpu: u32) -> &mut Self {
Comment thread
Berrysoft marked this conversation as resolved.
Outdated
self.sqpoll_cpu_affinity = Some(cpu);
self
}

/// Optimize performance for most cases, especially compio is a single
/// thread runtime.
///
Expand Down
3 changes: 3 additions & 0 deletions compio-driver/src/sys/driver/iour/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,9 @@ impl Driver {
let mut io_uring_builder = IoUring::builder();
if let Some(sqpoll_idle) = builder.sqpoll_idle {
io_uring_builder.setup_sqpoll(sqpoll_idle.as_millis() as _);
if let Some(cpu) = builder.sqpoll_cpu_affinity {
io_uring_builder.setup_sqpoll_cpu(cpu);
}
}
if builder.coop_taskrun {
io_uring_builder.setup_coop_taskrun();
Expand Down