From c581be947d605ccc1a7cdce0f959273d71325984 Mon Sep 17 00:00:00 2001 From: andrew Date: Fri, 9 Jun 2023 02:59:42 -0400 Subject: [PATCH 1/5] Fix error in select_workload() Cross-engine play broke this, by saving the test into the table, instead of test.id --- OpenBench/utils.py | 9 +++------ 1 file changed, 3 insertions(+), 6 deletions(-) diff --git a/OpenBench/utils.py b/OpenBench/utils.py index 96c3536..e4e089f 100644 --- a/OpenBench/utils.py +++ b/OpenBench/utils.py @@ -549,13 +549,10 @@ def test_maps_onto_thread_count(test, threads, ncutechess, hyperthreads): def select_workload(machine, tests, variance=0.25): - # For reference for later - test_ids = [test.id for test in tests] - # Determine how many threads are assigned to each workload - table = { test : 0 for test in tests } + table = { test.id : 0 for test in tests } for m in getRecentMachines(): - if m.workload in test_ids and m != machine: + if m.workload in table and m != machine: table[m.workload] = table[m.workload] + m.info['concurrency'] # Find the tests most deserving of resources currently @@ -563,7 +560,7 @@ def select_workload(machine, tests, variance=0.25): lowest_idxs = [i for i, r in enumerate(ratios) if r == min(ratios)] # Machine is out of date; or there is an unassigned test - if machine.workload not in test_ids or min(ratios) == 0: + if machine.workload not in table or min(ratios) == 0: return tests[random.choice(lowest_idxs)] # No test has less than (1-variance)% of its deserved resources, and From c148505e001505621add81411de641d273ece4b1 Mon Sep 17 00:00:00 2001 From: andrew Date: Fri, 9 Jun 2023 03:01:25 -0400 Subject: [PATCH 2/5] Fix misnamed field in models.py for Test --- OpenBench/models.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/OpenBench/models.py b/OpenBench/models.py index f52ef68..0a274f5 100644 --- a/OpenBench/models.py +++ b/OpenBench/models.py @@ -141,7 +141,7 @@ class Test(Model): updated = DateTimeField(auto_now=True) def __str__(self): - return '{0} vs {1} @ {2}'.format(self.dev.name, self.base.name, self.dev_timecontrol) + return '{0} vs {1} @ {2}'.format(self.dev.name, self.base.name, self.dev_time_control) class LogEvent(Model): From 6c749c93168a9a32d6aa70422d1e92119d2c9989 Mon Sep 17 00:00:00 2001 From: andrew Date: Fri, 9 Jun 2023 03:06:20 -0400 Subject: [PATCH 3/5] More fixes to select_workload() More bugs from converting Machine's workload from a key to an integer --- OpenBench/utils.py | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/OpenBench/utils.py b/OpenBench/utils.py index e4e089f..633337b 100644 --- a/OpenBench/utils.py +++ b/OpenBench/utils.py @@ -550,13 +550,13 @@ def test_maps_onto_thread_count(test, threads, ncutechess, hyperthreads): def select_workload(machine, tests, variance=0.25): # Determine how many threads are assigned to each workload - table = { test.id : 0 for test in tests } + table = { test.id : { 'cores' : 0, 'throughput' : test.throughput } for test in tests } for m in getRecentMachines(): if m.workload in table and m != machine: - table[m.workload] = table[m.workload] + m.info['concurrency'] + table[m.workload]['cores'] += m.info['concurrency'] # Find the tests most deserving of resources currently - ratios = [table[test] / test.throughput for test in tests] + ratios = [table[x]['cores'] / table[x]['throughput'] for x in table] lowest_idxs = [i for i, r in enumerate(ratios) if r == min(ratios)] # Machine is out of date; or there is an unassigned test @@ -565,7 +565,7 @@ def select_workload(machine, tests, variance=0.25): # No test has less than (1-variance)% of its deserved resources, and # therefore we may have this machine repeat its existing workload again - ideal_ratio = sum(table.values()) / sum([x.throughput for x in tests]) + ideal_ratio = sum([x['cores'] for x in table]) / sum([x['throughput'] for x in table]) if min(ratios) / ideal_ratio > 1 - variance: return OpenBench.models.Test.objects(id=machine.workload) From 345b9bfd6ad67a3ed1cbb77be6b387d66db59f8d Mon Sep 17 00:00:00 2001 From: andrew Date: Fri, 9 Jun 2023 03:09:23 -0400 Subject: [PATCH 4/5] Final fix for select_workload() --- OpenBench/utils.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/OpenBench/utils.py b/OpenBench/utils.py index 633337b..7c62508 100644 --- a/OpenBench/utils.py +++ b/OpenBench/utils.py @@ -565,7 +565,7 @@ def select_workload(machine, tests, variance=0.25): # No test has less than (1-variance)% of its deserved resources, and # therefore we may have this machine repeat its existing workload again - ideal_ratio = sum([x['cores'] for x in table]) / sum([x['throughput'] for x in table]) + ideal_ratio = sum([x['cores'] for x in table.values()]) / sum([x['throughput'] for x in table.values()]) if min(ratios) / ideal_ratio > 1 - variance: return OpenBench.models.Test.objects(id=machine.workload) From bf15be1e1f4279f80660f0aa1f191f774a4ebc52 Mon Sep 17 00:00:00 2001 From: andrew Date: Fri, 9 Jun 2023 03:10:09 -0400 Subject: [PATCH 5/5] Final fix for select_workload() --- OpenBench/utils.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/OpenBench/utils.py b/OpenBench/utils.py index 7c62508..dbbd8ec 100644 --- a/OpenBench/utils.py +++ b/OpenBench/utils.py @@ -567,7 +567,7 @@ def select_workload(machine, tests, variance=0.25): # therefore we may have this machine repeat its existing workload again ideal_ratio = sum([x['cores'] for x in table.values()]) / sum([x['throughput'] for x in table.values()]) if min(ratios) / ideal_ratio > 1 - variance: - return OpenBench.models.Test.objects(id=machine.workload) + return OpenBench.models.Test.objects.get(id=machine.workload) # Fallback to simply doing the least attention given test return tests[random.choice(lowest_idxs)]