From 08d5efa54fa9103d1659c60b94b7585df54864be Mon Sep 17 00:00:00 2001 From: Weijia Jiang Date: Wed, 27 Dec 2023 20:20:40 +0800 Subject: [PATCH] feat: reduce the impact of CPU bound tasks on the overall runtime scheduling delay --- tokio/src/runtime/scheduler/multi_thread/worker.rs | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/tokio/src/runtime/scheduler/multi_thread/worker.rs b/tokio/src/runtime/scheduler/multi_thread/worker.rs index 313e2ea68f7..ba09df96424 100644 --- a/tokio/src/runtime/scheduler/multi_thread/worker.rs +++ b/tokio/src/runtime/scheduler/multi_thread/worker.rs @@ -917,6 +917,13 @@ impl Core { .shared .idle .unpark_worker_by_id(&worker.handle.shared, worker.index); + + // Since this worker is awakened with tasks, it cannot be responsible for + // polling the driver for a certain period of time. + // Therefore, we ensure that at least one worker is designated to poll the driver here. + // This is for avoid significant delays in driver event processing, + // as discussed in https://github.com/tokio-rs/tokio/issues/4730. + worker.handle.notify_parked_local(); return true; }