Skip to content

Commit ca9b2dd

Browse files
authored
Merge pull request #257 from Sherlock-Holo/iouring_sqpoll
feat(driver): add io-uring sqpoll support
2 parents 7591e47 + bc8fea9 commit ca9b2dd

File tree

3 files changed

+21
-1
lines changed

3 files changed

+21
-1
lines changed

compio-driver/src/iour/mod.rs

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -82,7 +82,11 @@ impl Driver {
8282
instrument!(compio_log::Level::TRACE, "new", ?builder);
8383
trace!("new iour driver");
8484
let notifier = Notifier::new()?;
85-
let mut inner = IoUring::builder().build(builder.capacity)?;
85+
let mut io_uring_builder = IoUring::builder();
86+
if let Some(sqpoll_idle) = builder.sqpoll_idle {
87+
io_uring_builder.setup_sqpoll(sqpoll_idle.as_millis() as _);
88+
}
89+
let mut inner = io_uring_builder.build(builder.capacity)?;
8690
#[allow(clippy::useless_conversion)]
8791
unsafe {
8892
inner

compio-driver/src/lib.rs

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -401,6 +401,7 @@ impl ThreadPoolBuilder {
401401
pub struct ProactorBuilder {
402402
capacity: u32,
403403
pool_builder: ThreadPoolBuilder,
404+
sqpoll_idle: Option<Duration>,
404405
}
405406

406407
impl Default for ProactorBuilder {
@@ -415,6 +416,7 @@ impl ProactorBuilder {
415416
Self {
416417
capacity: 1024,
417418
pool_builder: ThreadPoolBuilder::new(),
419+
sqpoll_idle: None,
418420
}
419421
}
420422

@@ -465,6 +467,19 @@ impl ProactorBuilder {
465467
self.pool_builder.create_or_reuse()
466468
}
467469

470+
/// Set `io-uring` sqpoll idle milliseconds, when `sqpoll_idle` is set,
471+
/// io-uring sqpoll feature will be enabled
472+
///
473+
/// # Notes
474+
///
475+
/// - Only effective when the `io-uring` feature is enabled
476+
/// - `idle` must >= 1ms, otherwise will set sqpoll idle 0ms
477+
/// - `idle` will be rounded down
478+
pub fn sqpoll_idle(&mut self, idle: Duration) -> &mut Self {
479+
self.sqpoll_idle = Some(idle);
480+
self
481+
}
482+
468483
/// Build the [`Proactor`].
469484
pub fn build(&self) -> io::Result<Proactor> {
470485
Proactor::with_builder(self)

compio-signal/src/lib.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@
1717
#![cfg_attr(feature = "once_cell_try", feature(once_cell_try))]
1818
#![cfg_attr(feature = "lazy_cell", feature(lazy_cell))]
1919
#![warn(missing_docs)]
20+
#![allow(stable_features)]
2021

2122
#[cfg(windows)]
2223
pub mod windows;

0 commit comments

Comments
 (0)