runqueue: Optimise holdoff task handling
PATCH 1/3 runqueue: Optimise holdoff task handling
We don't need to process the holdoff task list until we're executing tasks which saves some data manipulation, at the cost of some data structures not being correct at all times. This saves significant amounts of time in various profile charts of larger builds.
Signed-off-by Richard Purdie <[email protected]>
--- lib/bb/runqueue.py | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-)
lib/bb/runqueue.py +10 -2
@@ -1711,6 +1711,7 @@ class RunQueueExecute: self.stampcache = {} self.holdoff_tasks = set() + self.holdoff_need_update = True self.sqdone = False self.stats = RunQueueStats(len(self.rqdata.runtaskentries))
@@ -2057,6 +2058,8 @@ class RunQueueExecute: self.rq.state = runQueueComplete return True + self.update_holdofftasks() + if self.cooker.configuration.setsceneonly: task = None else:
@@ -2194,6 +2197,9 @@ class RunQueueExecute: return taskdepdata def update_holdofftasks(self): + + if not self.holdoff_need_update: + return self.holdoff_tasks = set() for tid in self.rqdata.runq_setscene_tids:
@@ -2205,6 +2211,8 @@ class RunQueueExecute: if dep not in self.runq_complete: self.holdoff_tasks.add(dep) + self.holdoff_need_update = False + def process_possible_migrations(self): changed = set()
@@ -2324,7 +2332,7 @@ class RunQueueExecute: self.sqdone = False if changed: - self.update_holdofftasks() + self.holdoff_need_update = True def scenequeue_updatecounters(self, task, fail=False):
@@ -2373,7 +2381,7 @@ class RunQueueExecute: self.tasks_covered = covered self.tasks_notcovered = notcovered - self.update_holdofftasks() + self.holdoff_need_update = True def sq_task_completeoutright(self, task): """
Signature · 1 line
2.20.1
PATCH 2/3 runqueue: Further optimise holdoff tasks
There are other data structures which can be reprocessed at the same time as holdoff_tasks, further improving build efficiency in various places.
Signed-off-by Richard Purdie <[email protected]>
--- lib/bb/runqueue.py | 49 +++++++++++++++++++++++----------------------- 1 file changed, 25 insertions(+), 24 deletions(-)
lib/bb/runqueue.py +25 -24
@@ -2040,6 +2040,8 @@ class RunQueueExecute: if self.can_start_task(): return True + self.update_holdofftasks() + if not self.sq_live and not self.sqdone and not self.sq_deferred and not self.updated_taskhash_queue and not self.holdoff_tasks: logger.info("Setscene tasks completed")
@@ -2058,8 +2060,6 @@ class RunQueueExecute: self.rq.state = runQueueComplete return True - self.update_holdofftasks() - if self.cooker.configuration.setsceneonly: task = None else:
@@ -2200,6 +2200,29 @@ class RunQueueExecute: if not self.holdoff_need_update: return + + notcovered = set(self.scenequeue_notcovered) + notcovered |= self.cantskip + for tid in self.scenequeue_notcovered: + notcovered |= self.sqdata.sq_covered_tasks[tid] + notcovered |= self.sqdata.unskippable.difference(self.rqdata.runq_setscene_tids) + notcovered.intersection_update(self.tasks_scenequeue_done) + + covered = set(self.scenequeue_covered) + for tid in self.scenequeue_covered: + covered |= self.sqdata.sq_covered_tasks[tid] + covered.difference_update(notcovered) + covered.intersection_update(self.tasks_scenequeue_done) + + for tid in notcovered | covered: + if len(self.rqdata.runtaskentries[tid].depends) == 0: + self.setbuildable(tid) + elif self.rqdata.runtaskentries[tid].depends.issubset(self.runq_complete): + self.setbuildable(tid) + + self.tasks_covered = covered + self.tasks_notcovered = notcovered + self.holdoff_tasks = set() for tid in self.rqdata.runq_setscene_tids:
@@ -2359,28 +2382,6 @@ class RunQueueExecute: new.add(dep) next = new - notcovered = set(self.scenequeue_notcovered) - notcovered |= self.cantskip - for tid in self.scenequeue_notcovered: - notcovered |= self.sqdata.sq_covered_tasks[tid] - notcovered |= self.sqdata.unskippable.difference(self.rqdata.runq_setscene_tids) - notcovered.intersection_update(self.tasks_scenequeue_done) - - covered = set(self.scenequeue_covered) - for tid in self.scenequeue_covered: - covered |= self.sqdata.sq_covered_tasks[tid] - covered.difference_update(notcovered) - covered.intersection_update(self.tasks_scenequeue_done) - - for tid in notcovered | covered: - if len(self.rqdata.runtaskentries[tid].depends) == 0: - self.setbuildable(tid) - elif self.rqdata.runtaskentries[tid].depends.issubset(self.runq_complete): - self.setbuildable(tid) - - self.tasks_covered = covered - self.tasks_notcovered = notcovered - self.holdoff_need_update = True def sq_task_completeoutright(self, task):
Signature · 1 line
2.20.1
PATCH 3/3 runqueue: Optimise build_taskdepdata slightly
In reply to Richard PurdieRather than repeatedly calling mc_from_tid() do this in the parent, removing around a million function calls. Takes time spent in this function from 40s to 36s.
Signed-off-by Richard Purdie <[email protected]>
--- lib/bb/runqueue.py | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-)
lib/bb/runqueue.py +6 -6
@@ -2160,12 +2160,11 @@ class RunQueueExecute: return True - def filtermcdeps(self, task, deps): + def filtermcdeps(self, task, mc, deps): ret = set() - mainmc = mc_from_tid(task) for dep in deps: - mc = mc_from_tid(dep) - if mc != mainmc: + thismc = mc_from_tid(dep) + if thismc != mc: continue ret.add(dep) return ret
@@ -2174,9 +2173,10 @@ class RunQueueExecute: # as most code can't handle them def build_taskdepdata(self, task): taskdepdata = {} + mc = mc_from_tid(task) next = self.rqdata.runtaskentries[task].depends.copy() next.add(task) - next = self.filtermcdeps(task, next) + next = self.filtermcdeps(task, mc, next) while next: additional = [] for revdep in next:
@@ -2186,7 +2186,7 @@ class RunQueueExecute: provides = self.rqdata.dataCaches[mc].fn_provides[taskfn] taskhash = self.rqdata.runtaskentries[revdep].hash unihash = self.rqdata.runtaskentries[revdep].unihash - deps = self.filtermcdeps(task, deps) + deps = self.filtermcdeps(task, mc, deps) taskdepdata[revdep] = [pn, taskname, fn, deps, provides, taskhash, unihash] for revdep2 in deps: if revdep2 not in taskdepdata:
Signature · 1 line
2.20.1