[bitbake-devel,08/26] runqueue: Merge stats handling together for setscene/real tasks

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

Details

Message ID 20190710235420.23825-8-richard.purdie@linuxfoundation.org
State Accepted
Commit 32f39bbd5d3b7394689da9ba05be2c15b4523b27
Headers show

Commit Message

Richard Purdie July 10, 2019, 11:54 p.m.
Use a seperate stats class for scenequeue tasks and move the setup
into the base class. Update references accordingly.

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

Patch hide | download patch | download mbox

diff --git a/lib/bb/runqueue.py b/lib/bb/runqueue.py
index c512920a6d..7de27ec315 100644
--- a/lib/bb/runqueue.py
+++ b/lib/bb/runqueue.py
@@ -1748,6 +1748,9 @@  class RunQueueExecute:
 
         self.stampcache = {}
 
+        self.stats = RunQueueStats(len(self.rqdata.runtaskentries))
+        self.sq_stats = RunQueueStats(len(self.rqdata.runq_setscene_tids))
+
         for mc in rq.worker:
             rq.worker[mc].pipe.setrunqueueexec(self)
         for mc in rq.fakeworker:
@@ -1802,8 +1805,9 @@  class RunQueueExecute:
     def finish(self):
         self.rq.state = runQueueCleanUp
 
-        if self.stats.active > 0:
-            bb.event.fire(runQueueExitWait(self.stats.active), self.cfgData)
+        active = self.stats.active + self.sq_stats.active
+        if active > 0:
+            bb.event.fire(runQueueExitWait(active), self.cfgData)
             self.rq.read_workers()
             return self.rq.active_fds()
 
@@ -1831,7 +1835,8 @@  class RunQueueExecute:
         return valid
 
     def can_start_task(self):
-        can_start = self.stats.active < self.number_tasks
+        active = self.stats.active + self.sq_stats.active
+        can_start = active < self.number_tasks
         return can_start
 
 class RunQueueExecuteDummy(RunQueueExecute):
@@ -1847,8 +1852,6 @@  class RunQueueExecuteTasks(RunQueueExecute):
     def __init__(self, rq):
         RunQueueExecute.__init__(self, rq)
 
-        self.stats = RunQueueStats(len(self.rqdata.runtaskentries))
-
         self.stampcache = {}
 
         # Mark initial buildable tasks
@@ -2347,8 +2350,6 @@  class RunQueueExecuteScenequeue(RunQueueExecute):
             rq.state = runQueueRunInit
             return
 
-        self.stats = RunQueueStats(len(self.rqdata.runq_setscene_tids))
-
         self.sqdata = SQData()
         build_scenequeue_data(self.sqdata, self.rqdata, self.rq, self.cooker, self.stampcache, self)
 
@@ -2390,13 +2391,13 @@  class RunQueueExecuteScenequeue(RunQueueExecute):
                 self.rq.state = runQueueCleanUp
 
     def sq_task_complete(self, task):
-        self.stats.taskCompleted()
-        bb.event.fire(sceneQueueTaskCompleted(task, self.stats, self.rq), self.cfgData)
+        self.sq_stats.taskCompleted()
+        bb.event.fire(sceneQueueTaskCompleted(task, self.sq_stats, self.rq), self.cfgData)
         self.sq_task_completeoutright(task)
 
     def sq_task_fail(self, task, result):
-        self.stats.taskFailed()
-        bb.event.fire(sceneQueueTaskFailed(task, self.stats, result, self), self.cfgData)
+        self.sq_stats.taskFailed()
+        bb.event.fire(sceneQueueTaskFailed(task, self.sq_stats, result, self), self.cfgData)
         self.scenequeue_notcovered.add(task)
         self.scenequeue_updatecounters(task, True)
         self.sq_check_taskfail(task)
@@ -2404,8 +2405,8 @@  class RunQueueExecuteScenequeue(RunQueueExecute):
     def sq_task_failoutright(self, task):
         self.sq_running.add(task)
         self.sq_buildable.add(task)
-        self.stats.taskSkipped()
-        self.stats.taskCompleted()
+        self.sq_stats.taskSkipped()
+        self.sq_stats.taskCompleted()
         self.scenequeue_notcovered.add(task)
         self.scenequeue_updatecounters(task, True)
 
@@ -2413,8 +2414,8 @@  class RunQueueExecuteScenequeue(RunQueueExecute):
         self.sq_running.add(task)
         self.sq_buildable.add(task)
         self.sq_task_completeoutright(task)
-        self.stats.taskSkipped()
-        self.stats.taskCompleted()
+        self.sq_stats.taskSkipped()
+        self.sq_stats.taskCompleted()
 
     def sq_execute(self):
         """
@@ -2469,7 +2470,7 @@  class RunQueueExecuteScenequeue(RunQueueExecute):
                 self.sq_task_failoutright(task)
                 return True
 
-            startevent = sceneQueueTaskStarted(task, self.stats, self.rq)
+            startevent = sceneQueueTaskStarted(task, self.sq_stats, self.rq)
             bb.event.fire(startevent, self.cfgData)
 
             taskdepdata = self.sq_build_taskdepdata(task)
@@ -2490,11 +2491,11 @@  class RunQueueExecuteScenequeue(RunQueueExecute):
             self.build_stamps2.append(self.build_stamps[task])
             self.sq_running.add(task)
             self.sq_live.add(task)
-            self.stats.taskActive()
+            self.sq_stats.taskActive()
             if self.can_start_task():
                 return True
 
-        if self.stats.active > 0:
+        if self.sq_stats.active > 0:
             self.rq.read_workers()
             return self.rq.active_fds()
 
@@ -2511,7 +2512,7 @@  class RunQueueExecuteScenequeue(RunQueueExecute):
 
         self.rq.state = runQueueRunInit
 
-        completeevent = sceneQueueComplete(self.stats, self.rq)
+        completeevent = sceneQueueComplete(self.sq_stats, self.rq)
         bb.event.fire(completeevent, self.cfgData)
 
         return True