Skip to content

Apache DataFusion SQL Query Engine

Avoid sleeping between tasks (#698)

Daniël Heres63727df03472
diff --git a/ballista/rust/executor/src/execution_loop.rs b/ballista/rust/executor/src/execution_loop.rs
index 17a8d8c200..17f6e4dd5d 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<TaskStatus> =
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<PollWorkResult>,
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;
+ }
}
}