Skip to contentSkip to conversation

[2.10][PATCH 0/3] Patch review

bitbake Steve Sakoman 1 participant 4 messages Dec 4, 2024

lore
Share & tools
lore
#0 lore raw

Please review this set of changes for styhead/2.10 and have comments back by end of day Friday. December 6

Passed a-full on autobuilder:

https://valkyrie.yoctoproject.org/#/builders/29/builds/583

The following changes since commit 9602a684568910fd333ffce907fa020ad3661c26:

fetch2: use persist_data context managers (2024-11-28 13:59:46 +0000)

are available in the Git repository at:

https://git.openembedded.org/bitbake-contrib stable/2.10-nut
https://git.openembedded.org/bitbake-contrib/log/?h=stable/2.10-nut

Richard Purdie (3):
runqueue: Fix performance of multiconfigs with large overlap
runqueue: Optimise setscene loop processing
runqueue: Fix scenetask processing performance issue

 lib/bb/runqueue.py | 22 +++++++++++++++++-----
 1 file changed, 17 insertions(+), 5 deletions(-)
Signature · 1 line
2.34.1
#1 lore raw

[bitbake][styhead][2.10][PATCH 3/3] runqueue: Fix scenetask processing performance issue

From: Richard Purdie <[email protected]>

Analysis shows that "bitbake core-image-ptest-all" spends a lot of time in scenequeue_updatecounters and much of it is rebuilding a set which doens't change. Reorder the code to avoid that performance glitch.

(cherry picked from commit 923c19b9713e398d8e66e6d4422dfd4c18a03486)
---
 lib/bb/runqueue.py | 6 +++++-
 1 file changed, 5 insertions(+), 1 deletion(-)
lib/bb/runqueue.py +5 -1
index b34e2d560..7f95140c4 100644
@@ -2756,8 +2756,12 @@ class RunQueueExecute:
                 logger.debug2("%s was unavailable and is a hard dependency of %s so skipping" % (task, dep))
                 self.sq_task_failoutright(dep)
                 continue
+
+        # For performance, only compute allcovered once if needed
+        if self.sqdata.sq_deps[task]:
+            allcovered = self.scenequeue_covered | self.scenequeue_notcovered
         for dep in sorted(self.sqdata.sq_deps[task]):
-            if self.sqdata.sq_revdeps[dep].issubset(self.scenequeue_covered | self.scenequeue_notcovered):
+            if self.sqdata.sq_revdeps[dep].issubset(allcovered):
                 if dep not in self.sq_buildable:
                     self.sq_buildable.add(dep)
 
Signature · 1 line
2.34.1
#2 lore raw

[bitbake][styhead][2.10][PATCH 1/3] runqueue: Fix performance of multiconfigs with large overlap

In reply to Steve Sakoman

From: Richard Purdie <[email protected]>

There have been complaints about the performance of large multiconfig builds for a while. The key missing data point was that the builds needed to have large overlaps in sstate objects. This can be simulated by building the same things with just different TMPDIRs. In runqueue/bitbake terms this equates to large numbers of deferred tasks.

The issue is that the expensive checks in the setscene loop were hit every time through runqueue's execute function before the check on deferred tasks. This leads to task execution starvation as that only happens once per iteration.

Move the skip check earlier in the function which speeds things up enormously and should improve performance of such builds for users.

(cherry picked from commit 9c6c506757f2b3e28c8b20513b45da6b4659c95f)
---
 lib/bb/runqueue.py | 6 ++++--
 1 file changed, 4 insertions(+), 2 deletions(-)
lib/bb/runqueue.py +4 -2
index 3462ed445..9f3abff85 100644
@@ -2195,6 +2195,9 @@ class RunQueueExecute:
             # Find the next setscene to run
             for nexttask in self.sorted_setscene_tids:
                 if nexttask in self.sq_buildable and nexttask not in self.sq_running and self.sqdata.stamps[nexttask] not in self.build_stamps.values() and nexttask not in self.sq_harddep_deferred:
+                    if nexttask in self.sq_deferred and self.sq_deferred[nexttask] not in self.runq_complete:
+                        # Skip deferred tasks quickly before the 'expensive' tests below - this is key to performant multiconfig builds
+                        continue
                     if nexttask not in self.sqdata.unskippable and self.sqdata.sq_revdeps[nexttask] and \
                             nexttask not in self.sq_needed_harddeps and \
                             self.sqdata.sq_revdeps[nexttask].issubset(self.scenequeue_covered) and \
@@ -2224,8 +2227,7 @@ class RunQueueExecute:
                         if t in self.runq_running and t not in self.runq_complete:
                             continue
                     if nexttask in self.sq_deferred:
-                        if self.sq_deferred[nexttask] not in self.runq_complete:
-                            continue
+                        # Deferred tasks that were still deferred were skipped above so we now need to process
                         logger.debug("Task %s no longer deferred" % nexttask)
                         del self.sq_deferred[nexttask]
                         valid = self.rq.validate_hashes(set([nexttask]), self.cooker.data, 0, False, summary=False)
Signature · 1 line
2.34.1
#3 lore raw

[bitbake][styhead][2.10][PATCH 2/3] runqueue: Optimise setscene loop processing

In reply to Steve Sakoman

From: Richard Purdie <[email protected]>

Rather than looping through things we looped through on the previous execution, start looping where we left off for setscene processing. This gives speed improvements depending on the kind of build being executed.

(cherry picked from commit 00f4d932e3af0eeb333339cbe942010fc76dee0f)
---
 lib/bb/runqueue.py | 10 ++++++++--
 1 file changed, 8 insertions(+), 2 deletions(-)
lib/bb/runqueue.py +8 -2
index 9f3abff85..b34e2d560 100644
@@ -14,6 +14,7 @@ import os
 import sys
 import stat
 import errno
+import itertools
 import logging
 import re
 import bb
@@ -2189,11 +2190,16 @@ class RunQueueExecute:
         if not hasattr(self, "sorted_setscene_tids"):
             # Don't want to sort this set every execution
             self.sorted_setscene_tids = sorted(self.rqdata.runq_setscene_tids)
+            # Resume looping where we left off when we returned to feed the mainloop
+            self.setscene_tids_generator = itertools.cycle(self.rqdata.runq_setscene_tids)
 
         task = None
         if not self.sqdone and self.can_start_task():
-            # Find the next setscene to run
-            for nexttask in self.sorted_setscene_tids:
+            loopcount = 0
+            # Find the next setscene to run, exit the loop when we've processed all tids or found something to execute
+            while loopcount < len(self.rqdata.runq_setscene_tids):
+                loopcount += 1
+                nexttask = next(self.setscene_tids_generator)
                 if nexttask in self.sq_buildable and nexttask not in self.sq_running and self.sqdata.stamps[nexttask] not in self.build_stamps.values() and nexttask not in self.sq_harddep_deferred:
                     if nexttask in self.sq_deferred and self.sq_deferred[nexttask] not in self.runq_complete:
                         # Skip deferred tasks quickly before the 'expensive' tests below - this is key to performant multiconfig builds
Signature · 1 line
2.34.1