From 50b7e7a9e11f1abdf9dd7828f6b70235cfdf373d Mon Sep 17 00:00:00 2001 From: Hippolyte Barraud Date: Fri, 14 Jan 2022 01:13:54 +0100 Subject: [PATCH] uphold latency requirement when submitting blocking operations 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. --- glommio/src/sys/blocking.rs | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/glommio/src/sys/blocking.rs b/glommio/src/sys/blocking.rs index 17c541fbb..00b9656c6 100644 --- a/glommio/src/sys/blocking.rs +++ b/glommio/src/sys/blocking.rs @@ -108,6 +108,7 @@ impl TryFrom for std::io::Result { pub(super) struct BlockingThreadReq { op: BlockingThreadOp, + latency_sensitive: bool, id: u64, } @@ -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); } })) } @@ -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(