Attempt at keeping workers busy

This commit is contained in:
Brandon Rozek 2025-04-09 10:59:02 -04:00
parent 806309b1ae
commit cb00a82c67

View file

@ -174,10 +174,24 @@ if __name__ == "__main__":
if done_parsing: if done_parsing:
continue continue
# NOTE: We should attempt to maintain a decent amount
# of work in the task queue so that workers stay busy
task_queue_size: Optional[int] = None
try:
task_queue_size = task_queue.qsize()
except NotImplementedError:
# On MacOS this isn't implemented
pass
num_new_tasks = 1
if task_queue_size is not None and task_queue_size < num_cpu * 2:
num_new_tasks = (num_cpu * 2) - task_queue_size
for _ in range(num_new_tasks):
added = add_to_queue(solutions, task_queue, num_cpu) added = add_to_queue(solutions, task_queue, num_cpu)
if not added: if not added:
done_parsing = True done_parsing = True
break
print(f"Tested {num_tested} models, {num_has_vsp} of which satisfy VSP") print(f"Tested {num_tested} models, {num_has_vsp} of which satisfy VSP")