LoadScope scheduler: Sort scopes by number of tests to assign biggest scopes first (#778)

Follow up to # 632.

---------

Co-authored-by: Jörg Kohlsdorf <joerg@cornershopapp.com>
This commit is contained in:
Henk-Jaap Wagenaar
2023-11-21 14:32:29 +00:00
committed by GitHub
parent f36ea25cb5
commit 3fe877bc6d
3 changed files with 25 additions and 1 deletions

View File

@@ -350,11 +350,18 @@ class LoadScopeScheduling:
return
# Determine chunks of work (scopes)
unsorted_workqueue = OrderedDict()
for nodeid in self.collection:
scope = self._split_scope(nodeid)
work_unit = self.workqueue.setdefault(scope, default=OrderedDict())
work_unit = unsorted_workqueue.setdefault(scope, default=OrderedDict())
work_unit[nodeid] = False
# Insert tests scopes into work queue ordered by number of tests.
for scope, nodeids in sorted(
unsorted_workqueue.items(), key=lambda item: -len(item[1])
):
self.workqueue[scope] = nodeids
# Avoid having more workers than work
extra_nodes = len(self.nodes) - len(self.workqueue)