Skip to content

Commit 6ee1fea

Browse files
committed
feat(driver): add support for single issuer and deferred task run in ProactorBuilder
1 parent d418e5f commit 6ee1fea

2 files changed

Lines changed: 37 additions & 0 deletions

File tree

compio-driver/src/lib.rs

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -547,8 +547,10 @@ pub struct ProactorBuilder {
547547
sqpoll_idle: Option<Duration>,
548548
sqpoll_cpu: Option<u32>,
549549
cqsize: Option<u32>,
550+
single_issuer: bool,
550551
coop_taskrun: bool,
551552
taskrun_flag: bool,
553+
defer_taskrun: bool,
552554
eventfd: Option<RawFd>,
553555
driver_type: Option<DriverType>,
554556
op_flags: OpCodeFlag,
@@ -577,8 +579,10 @@ impl ProactorBuilder {
577579
sqpoll_idle: None,
578580
sqpoll_cpu: None,
579581
cqsize: None,
582+
single_issuer: false,
580583
coop_taskrun: false,
581584
taskrun_flag: false,
585+
defer_taskrun: false,
582586
eventfd: None,
583587
driver_type: None,
584588
op_flags: OpCodeFlag::empty(),
@@ -678,6 +682,17 @@ impl ProactorBuilder {
678682
self
679683
}
680684

685+
/// Set the `io-uring` single issuer hint.
686+
///
687+
/// # Notes
688+
///
689+
/// - Available since Linux Kernel 6.0.
690+
/// - Only effective when the `io-uring` feature is enabled
691+
pub fn single_issuer(&mut self, enable: bool) -> &mut Self {
692+
self.single_issuer = enable;
693+
self
694+
}
695+
681696
/// Optimize performance for most cases, especially compio is a single
682697
/// thread runtime.
683698
///
@@ -706,6 +721,22 @@ impl ProactorBuilder {
706721
self
707722
}
708723

724+
/// Defer io-uring task work until the driver enters the kernel to wait for
725+
/// completions.
726+
///
727+
/// This is only applied when [`single_issuer`](Self::single_issuer) is
728+
/// enabled. The kernel requires `IORING_SETUP_SINGLE_ISSUER` for
729+
/// `IORING_SETUP_DEFER_TASKRUN`.
730+
///
731+
/// # Notes
732+
///
733+
/// - Available since Linux Kernel 6.1.
734+
/// - Only effective when the `io-uring` feature is enabled
735+
pub fn defer_taskrun(&mut self, enable: bool) -> &mut Self {
736+
self.defer_taskrun = enable;
737+
self
738+
}
739+
709740
/// Register an eventfd to io-uring.
710741
///
711742
/// # Notes

compio-driver/src/sys/driver/iour/mod.rs

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -73,6 +73,12 @@ impl Driver {
7373
io_uring_builder.setup_sqpoll_cpu(cpu);
7474
}
7575
}
76+
if builder.single_issuer {
77+
io_uring_builder.setup_single_issuer();
78+
if builder.defer_taskrun {
79+
io_uring_builder.setup_defer_taskrun();
80+
}
81+
}
7682
if builder.coop_taskrun {
7783
io_uring_builder.setup_coop_taskrun();
7884
}

0 commit comments

Comments
 (0)