From 1e99ab180b753602430b4566d77276cf1d2d012c Mon Sep 17 00:00:00 2001 From: "Heres, Daniel" Date: Thu, 8 Jul 2021 19:55:03 +0200 Subject: [PATCH] Avoid sleeping between tasks --- ballista/rust/executor/src/execution_loop.rs | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/ballista/rust/executor/src/execution_loop.rs b/ballista/rust/executor/src/execution_loop.rs index 17a8d8c2002a..17f6e4dd5d35 100644 --- a/ballista/rust/executor/src/execution_loop.rs +++ b/ballista/rust/executor/src/execution_loop.rs @@ -49,6 +49,10 @@ pub async fn poll_loop( let task_status: Vec = sample_tasks_status(&mut task_status_receiver).await; + // Keeps track of whether we received task in last iteration + // to avoid going in sleep mode between polling + let mut active_job = false; + let poll_work_result: anyhow::Result< tonic::Response, tonic::Status, @@ -73,14 +77,18 @@ pub async fn poll_loop( task, ) .await; + active_job = true; + } else { + active_job = false; } } Err(error) => { warn!("Executor registration failed. If this continues to happen the executor might be marked as dead by the scheduler. Error: {}", error); } } - - tokio::time::sleep(Duration::from_millis(250)).await; + if !active_job { + tokio::time::sleep(Duration::from_millis(100)).await; + } } }