diff mbox series

[2/2] runqueue: Optimise performance of setscene task execution

Message ID 20240210230442.3633663-2-richard.purdie@linuxfoundation.org
State New
Headers show
Series [1/2] runqueue: Optimise taskname lookups in next_buildable_task | expand

Commit Message

Richard Purdie Feb. 10, 2024, 11:04 p.m. UTC
"time bitbake world -n" shows a lot of time being spent trying to execute the
setscene tasks when many of them are being skipped due to not being present.

The challenge is the "return True" back into the mainloop restarts the search
back at the start of the task list particularly when there are large numbers of
deferred tasks due to hard dependencies.

In this case we can use continue to continue within the list at the expense of
not returning so quickly to loop back through the main loop. This does significantly
improve performance in real world usage scenarios and we can probably afford the
potential loop starvation.

Thanks for the suggestion from Alexander Kanavin.

Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
---
 lib/bb/runqueue.py | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)
diff mbox series

Patch

diff --git a/lib/bb/runqueue.py b/lib/bb/runqueue.py
index 95cab5132f..85669b80ee 100644
--- a/lib/bb/runqueue.py
+++ b/lib/bb/runqueue.py
@@ -2204,7 +2204,9 @@  class RunQueueExecute:
                     if nexttask in self.sqdata.outrightfail:
                         logger.debug2('No package found, so skipping setscene task %s', nexttask)
                         self.sq_task_failoutright(nexttask)
-                        return True
+                        # Technically we should return True here but that would then start the task list back at the start
+                        # which is really bad for performance ("time bitbake world -n"). Instead, keep our place in the tasklist.
+                        continue
                     if nexttask in self.sqdata.unskippable:
                         logger.debug2("Setscene task %s is unskippable" % nexttask)
                     task = nexttask