[bitbake-devel,13/26] runqueue: Fold remains of the scenequeue setup into RunQueueExecute

Submitted by Richard Purdie on July 10, 2019, 11:54 p.m. | Patch ID: 162962

Details

Message ID 20190710235420.23825-13-richard.purdie@linuxfoundation.org
State Accepted
Commit ad30a16cd30f9eab0224eb271f98f9a24516b621
Headers show

Commit Message

Richard Purdie July 10, 2019, 11:54 p.m.
Also move the scheduler init over, apart for the builtable tasks part which need
to remain called later.

Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
---
 lib/bb/runqueue.py | 89 ++++++++++++++++++++++------------------------
 1 file changed, 42 insertions(+), 47 deletions(-)

Patch hide | download patch | download mbox

diff --git a/lib/bb/runqueue.py b/lib/bb/runqueue.py
index a19fb61fe7..46146466fc 100644
--- a/lib/bb/runqueue.py
+++ b/lib/bb/runqueue.py
@@ -196,6 +196,11 @@  class RunQueueScheduler(object):
         if self.rq.can_start_task():
             return self.next_buildable_task()
 
+    def initbuildable(self):
+        for tid in self.rqdata.runtaskentries:
+            if tid in self.rq.runq_buildable:
+                self.buildable.append(tid)
+
     def newbuildable(self, task):
         self.buildable.append(task)
 
@@ -1451,7 +1456,14 @@  class RunQueue:
             self.start_worker()
             self.rqdata.init_progress_reporter.next_stage()
             self.rqexe = RunQueueExecute(self)
-            start_scenequeue_tasks(self.rqexe)
+
+            # If we don't have any setscene functions, skip execution
+            if len(self.rqdata.runq_setscene_tids) == 0:
+                self.rqdata.init_progress_reporter.finish()
+                self.state = runQueueRunInit
+            else:
+                logger.info('Executing SetScene Tasks')
+                self.state = runQueueSceneRun
 
         if self.state is runQueueSceneRun:
             retval = self.rqexe.sq_execute()
@@ -1461,11 +1473,7 @@  class RunQueue:
                 self.state = runQueueComplete
 
         if self.state is runQueueRunInit:
-            # Just in case we didn't setscene
-            self.rqdata.init_progress_reporter.finish()
             logger.info("Executing RunQueue Tasks")
-            if not self.rqexe:
-                self.rqexe = RunQueueExecute(self)
             start_runqueue_tasks(self.rqexe)
             self.state = runQueueRunning
 
@@ -1690,7 +1698,7 @@  def process_setscene_whitelist(rq, rqdata, stampcache, sched, rqex):
     def check_norun_task(tid, showerror=False):
         (mc, fn, taskname, taskfn) = split_tid_mcfn(tid)
         # Ignore covered tasks
-        if tid in rq.scenequeue_covered:
+        if tid in rqex.scenequeue_covered:
             return False
         # Ignore stamped tasks
         if rq.check_stamp_task(tid, taskname, cache=stampcache):
@@ -1765,6 +1773,24 @@  class RunQueueExecute:
         if self.number_tasks <= 0:
              bb.fatal("Invalid BB_NUMBER_THREADS %s" % self.number_tasks)
 
+        self.scenequeue_covered = set()
+        self.scenequeue_notcovered = set()
+        self.scenequeue_notneeded = set()
+
+        if len(self.rqdata.runq_setscene_tids) > 0:
+            self.sqdata = SQData()
+            build_scenequeue_data(self.sqdata, self.rqdata, self.rq, self.cooker, self.stampcache, self)
+
+        schedulers = self.get_schedulers()
+        for scheduler in schedulers:
+            if self.scheduler == scheduler.name:
+                self.sched = scheduler(self, self.rqdata)
+                logger.debug(1, "Using runqueue scheduler '%s'", scheduler.name)
+                break
+        else:
+            bb.fatal("Invalid scheduler '%s'.  Available schedulers: %s" %
+                     (self.scheduler, ", ".join(obj.name for obj in schedulers)))
+
     def runqueue_process_waitpid(self, task, status):
 
         # self.build_stamps[pid] may not exist when use shared work directory.
@@ -1937,7 +1963,7 @@  class RunQueueExecute:
         if task is not None:
             (mc, fn, taskname, taskfn) = split_tid_mcfn(task)
 
-            if task in self.rq.scenequeue_covered:
+            if task in self.scenequeue_covered:
                 logger.debug(2, "Setscene covered task %s", task)
                 self.task_skip(task, "covered")
                 return True
@@ -2194,10 +2220,7 @@  class RunQueueExecute:
         #        revdeps = self.sqdata.sq_revdeps[tid]
         #        bb.warn("Found we didn't run %s %s %s" % (tid, buildable, str(revdeps)))
 
-        self.rq.scenequeue_covered = self.scenequeue_covered
-        self.rq.scenequeue_notcovered = self.scenequeue_notcovered
-
-        logger.debug(1, 'We can skip tasks %s', "\n".join(sorted(self.rq.scenequeue_covered)))
+        logger.debug(1, 'We can skip tasks %s', "\n".join(sorted(self.scenequeue_covered)))
 
         self.rq.state = runQueueRunInit
 
@@ -2479,29 +2502,28 @@  def build_scenequeue_data(sqdata, rqdata, rq, cooker, stampcache, sqrq):
                 sqdata.outrightfail.append(tid)
 
 def start_runqueue_tasks(rqexec):
-
         # Mark initial buildable tasks
         for tid in rqexec.rqdata.runtaskentries:
             if len(rqexec.rqdata.runtaskentries[tid].depends) == 0:
                 rqexec.runq_buildable.add(tid)
-            if len(rqexec.rqdata.runtaskentries[tid].revdeps) > 0 and rqexec.rqdata.runtaskentries[tid].revdeps.issubset(rqexec.rq.scenequeue_covered):
-                rqexec.rq.scenequeue_covered.add(tid)
+            if len(rqexec.rqdata.runtaskentries[tid].revdeps) > 0 and rqexec.rqdata.runtaskentries[tid].revdeps.issubset(rqexec.scenequeue_covered):
+                rqexec.scenequeue_covered.add(tid)
 
         found = True
         while found:
             found = False
             for tid in rqexec.rqdata.runtaskentries:
-                if tid in rqexec.rq.scenequeue_covered:
+                if tid in rqexec.scenequeue_covered:
                     continue
                 logger.debug(1, 'Considering %s: %s' % (tid, str(rqexec.rqdata.runtaskentries[tid].revdeps)))
 
-                if len(rqexec.rqdata.runtaskentries[tid].revdeps) > 0 and rqexec.rqdata.runtaskentries[tid].revdeps.issubset(rqexec.rq.scenequeue_covered):
-                    if tid in rqexec.rq.scenequeue_notcovered:
+                if len(rqexec.rqdata.runtaskentries[tid].revdeps) > 0 and rqexec.rqdata.runtaskentries[tid].revdeps.issubset(rqexec.scenequeue_covered):
+                    if tid in rqexec.scenequeue_notcovered:
                         continue
                     found = True
-                    rqexec.rq.scenequeue_covered.add(tid)
+                    rqexec.scenequeue_covered.add(tid)
 
-        logger.debug(1, 'Skip list %s', sorted(rqexec.rq.scenequeue_covered))
+        logger.debug(1, 'Skip list %s', sorted(rqexec.scenequeue_covered))
 
         for task in self.rq.scenequeue_notcovered:
             logger.debug(1, 'Not skipping task %s', task)
@@ -2514,35 +2536,8 @@  def start_runqueue_tasks(rqexec):
                     target_pairs.append((fn, taskname))
 
             event.fire(bb.event.StampUpdate(target_pairs, rqexec.rqdata.dataCaches[mc].stamp), rqexec.cfgData)
+        rqexec.sched.initbuildable()
 
-        schedulers = rqexec.get_schedulers()
-        for scheduler in schedulers:
-            if rqexec.scheduler == scheduler.name:
-                rqexec.sched = scheduler(rqexec, rqexec.rqdata)
-                logger.debug(1, "Using runqueue scheduler '%s'", scheduler.name)
-                break
-        else:
-            bb.fatal("Invalid scheduler '%s'.  Available schedulers: %s" %
-                     (rqexec.scheduler, ", ".join(obj.name for obj in schedulers)))
-
-def start_scenequeue_tasks(rqexec):
-        rqexec.scenequeue_covered = set()
-        rqexec.scenequeue_notcovered = set()
-        rqexec.scenequeue_notneeded = set()
-
-        # If we don't have any setscene functions, skip this step
-        if len(rqexec.rqdata.runq_setscene_tids) == 0:
-            rqexec.rq.scenequeue_covered = set()
-            rqexec.rq.scenequeue_notcovered = set()
-            rqexec.rq.state = runQueueRunInit
-            return
-
-        rqexec.sqdata = SQData()
-        build_scenequeue_data(rqexec.sqdata, rqexec.rqdata, rqexec.rq, rqexec.cooker, rqexec.stampcache, rqexec)
-
-        logger.info('Executing SetScene Tasks')
-
-        rqexec.rq.state = runQueueSceneRun
 
 class TaskFailure(Exception):
     """