Skip to content

Commit

Permalink
uphold latency requirement when submitting blocking operations
Browse files Browse the repository at this point in the history
If a user submits a blocking operation from a latency-sensitive queue,
the blocking thread should unconditionally wake the executor to trigger
a preemption. This is the same principle that applies to foreign
wakes.
  • Loading branch information
HippoBaro committed Jan 14, 2022
1 parent 33eebf2 commit 2570c51
Showing 1 changed file with 10 additions and 2 deletions.
12 changes: 10 additions & 2 deletions glommio/src/sys/blocking.rs
Original file line number Diff line number Diff line change
Expand Up @@ -108,6 +108,7 @@ impl TryFrom<BlockingThreadResult> for std::io::Result<usize> {

pub(super) struct BlockingThreadReq {
op: BlockingThreadOp,
latency_sensitive: bool,
id: u64,
}

Expand Down Expand Up @@ -137,7 +138,7 @@ impl BlockingThread {
if tx.send(resp).is_err() {
panic!("failed to send response");
}
reactor_sleep_notifier.notify(false);
reactor_sleep_notifier.notify(el.latency_sensitive);
}
}))
}
Expand Down Expand Up @@ -191,7 +192,14 @@ impl BlockingThreadPool {
let id = self.requests.get();
self.requests.set(id.overflowing_add(1).0);

let req = BlockingThreadReq { op, id };
let req = BlockingThreadReq {
op,
id,
latency_sensitive: matches!(
source.borrow().io_requirements.latency_req,
crate::Latency::Matters(_)
),
};

self.tx.send(req).map_err(|_| {
io::Error::new(
Expand Down

0 comments on commit 2570c51

Please sign in to comment.