mirror of
https://github.com/ansible/awx.git
synced 2026-03-19 18:07:33 -02:30
prefetch optimizations for task manager
* Prefetch all Jobs Types related instance group * Prefetch inventory updates inventory source. The attribute inventory_source.inventory_id is accessed when building the hash tables of the running tasks.
This commit is contained in:
@@ -46,11 +46,12 @@ class TaskManager():
|
|||||||
return False
|
return False
|
||||||
|
|
||||||
def get_tasks(self, status_list=('pending', 'waiting', 'running')):
|
def get_tasks(self, status_list=('pending', 'waiting', 'running')):
|
||||||
jobs = [j for j in Job.objects.filter(status__in=status_list)]
|
jobs = [j for j in Job.objects.filter(status__in=status_list).prefetch_related('instance_group')]
|
||||||
inventory_updates = [i for i in InventoryUpdate.objects.filter(status__in=status_list)]
|
inventory_updates_qs = InventoryUpdate.objects.filter(status__in=status_list).prefetch_related('inventory_source', 'instance_group')
|
||||||
project_updates = [p for p in ProjectUpdate.objects.filter(status__in=status_list)]
|
inventory_updates = [i for i in inventory_updates_qs]
|
||||||
system_jobs = [s for s in SystemJob.objects.filter(status__in=status_list)]
|
project_updates = [p for p in ProjectUpdate.objects.filter(status__in=status_list).prefetch_related('instance_group')]
|
||||||
ad_hoc_commands = [a for a in AdHocCommand.objects.filter(status__in=status_list)]
|
system_jobs = [s for s in SystemJob.objects.filter(status__in=status_list).prefetch_related('instance_group')]
|
||||||
|
ad_hoc_commands = [a for a in AdHocCommand.objects.filter(status__in=status_list).prefetch_related('instance_group')]
|
||||||
workflow_jobs = [w for w in WorkflowJob.objects.filter(status__in=status_list)]
|
workflow_jobs = [w for w in WorkflowJob.objects.filter(status__in=status_list)]
|
||||||
all_tasks = sorted(jobs + project_updates + inventory_updates + system_jobs + ad_hoc_commands + workflow_jobs,
|
all_tasks = sorted(jobs + project_updates + inventory_updates + system_jobs + ad_hoc_commands + workflow_jobs,
|
||||||
key=lambda task: task.created)
|
key=lambda task: task.created)
|
||||||
|
|||||||
Reference in New Issue
Block a user