From 60a3fa633a33e315c1439a9f2436fcdb48da62ae Mon Sep 17 00:00:00 2001 From: Matthias Beyer Date: Thu, 4 Mar 2021 14:08:10 +0100 Subject: Remove relative speed setting, select endpoint by utilization instead This patch removes the "speed" setting from the configuration, which was introduced to set a relative speed for each endpoint, with the idea that the scheduler then would select a faster node preferably. Instead, the utilization of an endpoint is now calculated (number of running jobs vs allowed maximum jobs on the endpoint), and the endpoint with lower utilization is selected. Signed-off-by: Matthias Beyer --- src/endpoint/configured.rs | 7 +++++++ src/endpoint/scheduler.rs | 4 +++- 2 files changed, 10 insertions(+), 1 deletion(-) (limited to 'src/endpoint') diff --git a/src/endpoint/configured.rs b/src/endpoint/configured.rs index bbaaec6..ba1c54e 100644 --- a/src/endpoint/configured.rs +++ b/src/endpoint/configured.rs @@ -234,6 +234,13 @@ impl Endpoint { pub fn running_jobs(&self) -> usize { self.running_jobs.load(std::sync::atomic::Ordering::Relaxed) } + + /// Super non-scientific utilization calculation for the endpoint + pub fn utilization(&self) -> f64 { + let max_jobs = self.num_max_jobs() as f64; + let run_jobs = self.running_jobs() as f64; + 100.0 / max_jobs * run_jobs + } } pub struct EndpointHandle(Arc); diff --git a/src/endpoint/scheduler.rs b/src/endpoint/scheduler.rs index 4f49034..34a79d7 100644 --- a/src/endpoint/scheduler.rs +++ b/src/endpoint/scheduler.rs @@ -110,7 +110,9 @@ impl EndpointScheduler { trace!("Endpoint {} considered for scheduling job: {}", ep.name(), r); r }) - .sorted_by(|ep1, ep2| ep1.running_jobs().cmp(&ep2.running_jobs())) + .sorted_by(|ep1, ep2| { + ep1.utilization().partial_cmp(&ep2.utilization()).unwrap_or(std::cmp::Ordering::Equal) + }) .next(); if let Some(endpoint) = ep { -- cgit v1.2.3