diff options
author | Matthias Beyer <matthias.beyer@atos.net> | 2021-03-04 14:08:10 +0100 |
---|---|---|
committer | Matthias Beyer <mail@beyermatthias.de> | 2021-03-04 14:30:25 +0100 |
commit | 60a3fa633a33e315c1439a9f2436fcdb48da62ae (patch) | |
tree | aa10ed05e61781d0ef25d098ad5567f613bdeeab /src/endpoint | |
parent | 248c28c0b882930908493af94f714ce4de3706ac (diff) |
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 <matthias.beyer@atos.net>
Diffstat (limited to 'src/endpoint')
-rw-r--r-- | src/endpoint/configured.rs | 7 | ||||
-rw-r--r-- | src/endpoint/scheduler.rs | 4 |
2 files changed, 10 insertions, 1 deletions
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<Endpoint>); 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 { |