aboutsummaryrefslogtreecommitdiffstats
path: root/lib/bb/runqueue.py
diff options
context:
space:
mode:
authorRichard Purdie <richard.purdie@linuxfoundation.org>2019-08-13 20:14:49 +0100
committerRichard Purdie <richard.purdie@linuxfoundation.org>2019-08-14 14:41:36 +0100
commit3bcf9ad4964b7e42d1a02ce231e9db42a81ead2a (patch)
tree4e60fdbb98be2428d60b91a168bfd864d4a1aa1f /lib/bb/runqueue.py
parentfdee640c26750b852eb68f5c80437377aa300ed8 (diff)
downloadbitbake-3bcf9ad4964b7e42d1a02ce231e9db42a81ead2a.tar.gz
runqueue: Fix next_buildable_task performance problem
Looking at the profile information, a lot of time is being spent in next_buildable_task. This is probably due to the generator expressions not working well with the empty test. The easiest way to improve things is to switch to using set manipulations. We also don't need to update self.buildable the way the original code did as we don't rely on that anywhere. Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
Diffstat (limited to 'lib/bb/runqueue.py')
-rw-r--r--lib/bb/runqueue.py12
1 files changed, 7 insertions, 5 deletions
diff --git a/lib/bb/runqueue.py b/lib/bb/runqueue.py
index 9acad7af8..3bcbaee12 100644
--- a/lib/bb/runqueue.py
+++ b/lib/bb/runqueue.py
@@ -133,7 +133,7 @@ class RunQueueScheduler(object):
self.prio_map = [self.rqdata.runtaskentries.keys()]
- self.buildable = []
+ self.buildable = set()
self.skip_maxthread = {}
self.stamps = {}
for tid in self.rqdata.runtaskentries:
@@ -148,8 +148,10 @@ class RunQueueScheduler(object):
"""
Return the id of the first task we find that is buildable
"""
- self.buildable = [x for x in self.buildable if x not in self.rq.runq_running]
- buildable = [x for x in self.buildable if (x in self.rq.tasks_covered or x in self.rq.tasks_notcovered) and x not in self.rq.holdoff_tasks]
+ buildable = set(self.buildable)
+ buildable.difference_update(self.rq.runq_running)
+ buildable.difference_update(self.rq.holdoff_tasks)
+ buildable.intersection_update(self.rq.tasks_covered | self.rq.tasks_notcovered)
if not buildable:
return None
@@ -167,7 +169,7 @@ class RunQueueScheduler(object):
skip_buildable[rtaskname] = 1
if len(buildable) == 1:
- tid = buildable[0]
+ tid = buildable.pop()
taskname = taskname_from_tid(tid)
if taskname in skip_buildable and skip_buildable[taskname] >= int(self.skip_maxthread[taskname]):
return None
@@ -204,7 +206,7 @@ class RunQueueScheduler(object):
return self.next_buildable_task()
def newbuildable(self, task):
- self.buildable.append(task)
+ self.buildable.add(task)
def removebuildable(self, task):
self.buildable.remove(task)