From 19bb5ce6c81cd425533995e5a40e3a9fbf7ffb33 Mon Sep 17 00:00:00 2001 From: andrew Date: Wed, 31 Jan 2024 20:46:15 -0500 Subject: [PATCH] Improve worker assignment algorithm If a handful of tests are present, its possible for one test to get multiple times more resources than is fair, without making any other tests be considered unbalacned. IE, the one test steals a small amount of resources from all other tests. Fix this by bounding the definition of balance as +- 25%, instead of having a one-sided bound. Also, when computing ratios, compute them as if the machine we are assigning has been assigned to each test. Ie, the ratios IF the worker is assigned to the specific test. Likewise, the fair ratio should account for this machine's threads. --- OpenBench/workloads/get_workload.py | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/OpenBench/workloads/get_workload.py b/OpenBench/workloads/get_workload.py index 34fa429..32356cb 100644 --- a/OpenBench/workloads/get_workload.py +++ b/OpenBench/workloads/get_workload.py @@ -68,19 +68,20 @@ def select_workload(machine): for id, data in worker_dist.items(): data['throughput'] = data['throughput'] / engine_freq[data['engine']] - # Step 4: Compute the Resource Ratios for each of the workloads + # Step 4: Compute the Resource Ratios for each of the workloads, if we were assigned for id, data in worker_dist.items(): - data['ratio'] = data['threads'] / data['throughput'] + data['ratio'] = (data['threads'] + machine.info['concurrency']) / data['throughput'] - # Step 5: Compute the idealized "Fair-Ratio" + # Step 5: Compute the idealized "Fair-Ratio" once our machine is added min_ratio = min(x['ratio'] for x in worker_dist.values()) - thread_sum = sum(x['threads'] for x in worker_dist.values()) + thread_sum = sum(x['threads'] for x in worker_dist.values()) + machine.info['concurrency'] throughput_sum = sum(x['throughput'] for x in worker_dist.values()) fair_ratio = thread_sum / throughput_sum - # Step 6: Repeat the same machine, if we are still at least 75% fair across the board + # Step 6: Repeat the same machine, if we are still within +- 25% fairness if machine.workload in worker_dist.keys(): - if thread_sum > 0 and min_ratio / fair_ratio > 0.75: + this_ratio = worker_dist[machine.workload]['ratio'] + if min_ratio / fair_ratio > 0.75 and this_ratio / fair_ratio < 1.25: return Test.objects.get(id=machine.workload) # Step 7: Pick a random test, amongst those who share the min_ratio, weighted by throughput