Skip to content

feat(driver,executor,runtime)!: remove notify-always#902

Open
Berrysoft wants to merge 14 commits intocompio-rs:masterfrom
Berrysoft:dev/remove-notify-always
Open

feat(driver,executor,runtime)!: remove notify-always#902
Berrysoft wants to merge 14 commits intocompio-rs:masterfrom
Berrysoft:dev/remove-notify-always

Conversation

@Berrysoft
Copy link
Copy Markdown
Member

@Berrysoft Berrysoft commented May 1, 2026

Closes #895

Previously, we don't wake the driver if the waker is on the same thread, because we assume that if Waker::wake_by_ref is called, the thread is not waiting for the driver. However, this is not always true:

  • If the waker is woken in a signal handler, the driver might be interrupted. But polling crate handles EINTR and loops internally.
  • If the driver is not polled by the runtime, but rather some other kernel mechanisms, e.g., the windows backend of winio.

So I added the "notify-always" flag, making things even more complicated.

Actually we don't have to optimize it on the runtime side. We want to optimize it because it is heavy to notify the driver, so we only need to insert a bool flag beside the driver, and check it when woken.

As the bool flag is tightly coupled with the control flow, I have to repeat the logic 3 times...

UPDATE: I also removed the OptWaker, because actually it is useless. If the waker is woken, the driver will be notified, and we don't have to deal with it separately.

@Berrysoft Berrysoft requested a review from Copilot May 1, 2026 09:58
@Berrysoft Berrysoft self-assigned this May 1, 2026
@Berrysoft Berrysoft added package: driver Related to compio-driver package: runtime Related to compio-runtime breaking change package: executor Related to compio-executor labels May 1, 2026
@github-actions github-actions Bot added the enhancement New feature or request label May 1, 2026
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR removes the notify-always feature flag and reworks wake/notify behavior so drivers are always eligible to be notified, while attempting to de-duplicate expensive driver notifications inside each driver implementation.

Changes:

  • Removed the notify-always feature wiring across compio, compio-runtime, and compio-executor.
  • Removed the runtime-side OptWaker optimization and switched Runtime::block_on back to using the driver waker directly.
  • Added driver-side de-duplication (AtomicBool awake) for wake notifications in polling / io-uring / IOCP drivers.

Reviewed changes

Copilot reviewed 12 out of 12 changed files in this pull request and generated 2 comments.

Show a summary per file
File Description
compio/Cargo.toml Removes top-level notify-always feature exposure.
compio-runtime/src/waker/opt.rs Deletes OptWaker implementation (optimized same-thread wake avoidance).
compio-runtime/src/waker/mod.rs Drops the opt module + public re-export.
compio-runtime/src/lib.rs Removes Runtime::opt_waker and uses the driver waker directly in block_on.
compio-runtime/Cargo.toml Removes notify-always feature.
compio-executor/src/task/local.rs Always wakes the configured waker when locally scheduling a task.
compio-executor/src/lib.rs Updates ExecutorConfig docs by removing notify-always references (but doc intent now needs adjustment).
compio-executor/Cargo.toml Removes notify-always feature.
compio-driver/src/sys/driver/poll/mod.rs Adds awake flag to de-duplicate Poller::notify() calls while driver is active.
compio-driver/src/sys/driver/iour/notify.rs Adds awake flag to de-duplicate eventfd writes.
compio-driver/src/sys/driver/iour/mod.rs Sets/clears notifier awake state around CQ processing.
compio-driver/src/sys/driver/iocp/mod.rs Adds awake flag to de-duplicate IOCP wake posting.
Comments suppressed due to low confidence (2)

compio-runtime/src/waker/mod.rs:6

  • Removing the opt waker module and its public re-exports (OptWaker) is a breaking change for compio-runtime's public API. If this is intentional, it should be called out explicitly (e.g., changelog/release notes) or replaced with an alternative API so downstream crates aren’t silently broken.
//! Waker related utilities.

mod ext;

pub(crate) use ext::*;

compio-runtime/src/lib.rs:204

  • Runtime::block_on no longer uses OptWaker/reset() to track same-thread wakes. Given the public API removals, please ensure the new driver-side wake de-duplication preserves the previous wake/liveness guarantees (especially around transitions into poll() when no tasks remain), and consider adding a regression test for the scenario that originally motivated OptWaker.
    /// Block on the future till it completes.
    pub fn block_on<F: Future>(&self, future: F) -> F::Output {
        self.enter(|| {
            let waker = self.waker();
            let mut context = Context::from_waker(&waker);
            let mut future = std::pin::pin!(future);
            loop {
                if let Poll::Ready(result) = future.as_mut().poll(&mut context) {
                    self.run();
                    return result;
                }
                // We always want to reset the waker here.
                let remaining_tasks = self.run();
                if remaining_tasks {
                    self.poll_with(Some(Duration::ZERO));
                } else {
                    self.poll();
                }
            }

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread compio-executor/src/lib.rs Outdated
Comment thread compio-driver/src/sys/driver/iour/mod.rs Outdated
@abh1nav10
Copy link
Copy Markdown
Contributor

Hi @Berrysoft ! I think Release on the store and AcqRel on swap will not suffice to ensure that cross-thread wake-ups will indeed see the flag to be false if it was false as store is not an RMW operation. I think there needs to be a total order and thus SeqCst.

@Berrysoft
Copy link
Copy Markdown
Member Author

Thanks! @abh1nav10

@Berrysoft Berrysoft requested a review from George-Miao May 1, 2026 15:29
@Berrysoft Berrysoft added this to the v0.19 milestone May 1, 2026
@Berrysoft Berrysoft force-pushed the dev/remove-notify-always branch 2 times, most recently from b9a0686 to 00fbd71 Compare May 1, 2026 17:37
@Berrysoft Berrysoft force-pushed the dev/remove-notify-always branch from 00fbd71 to 204bd0a Compare May 1, 2026 18:23
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 13 out of 13 changed files in this pull request and generated 7 comments.


💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread compio-driver/src/sys/driver/iocp/mod.rs
Comment thread compio-runtime/src/lib.rs Outdated
Comment thread compio-runtime/src/lib.rs
Comment thread compio-executor/src/lib.rs Outdated
Comment thread compio-driver/src/sys/driver/poll/mod.rs
Comment thread compio-driver/src/sys/driver/iour/notify.rs
Comment thread compio-driver/src/sys/driver/iour/mod.rs
@Berrysoft Berrysoft changed the title feat(driver,executor,runtime): remove notify-always feat(driver,executor,runtime)!: remove notify-always May 1, 2026
@Berrysoft
Copy link
Copy Markdown
Member Author

It finally works:)

@Berrysoft Berrysoft requested a review from fantix May 4, 2026 19:07
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

breaking change enhancement New feature or request package: driver Related to compio-driver package: executor Related to compio-executor package: runtime Related to compio-runtime

Projects

None yet

Development

Successfully merging this pull request may close these issues.

signal: doesn't wakeup the polling driver

3 participants