summaryrefslogtreecommitdiffstats
path: root/bitbake/lib/bb/runqueue.py
diff options
context:
space:
mode:
authorRichard Purdie <richard.purdie@linuxfoundation.org>2021-11-02 09:02:15 +0000
committerRichard Purdie <richard.purdie@linuxfoundation.org>2021-11-03 10:12:42 +0000
commit34e4eebc32c4836fc40098e90b17c00f51398967 (patch)
tree20f3ba43c0341cbed8b454c92d60e0fc326b9d50 /bitbake/lib/bb/runqueue.py
parent791d6e63be09b361dd3397707a0507399b9a9ce7 (diff)
downloadpoky-34e4eebc32c4836fc40098e90b17c00f51398967.tar.gz
bitbake: lib/bb: Fix string concatination potential performance issues
Python scales badly when concatinating strings in loops. Most of these references aren't problematic but at least one (in data.py) is probably a performance issue as the issue is compounded as strings become large. The way to handle this in python is to create lists which don't reconstruct all the objects when appending to them. We may as well fix all the references since it stops them being copy/pasted into something problematic in the future. This patch was based on issues highligthted by a report from AWS Codeguru. (Bitbake rev: d654139a833127b16274dca0ccbbab7e3bb33ed0) Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
Diffstat (limited to 'bitbake/lib/bb/runqueue.py')
-rw-r--r--bitbake/lib/bb/runqueue.py37
1 files changed, 19 insertions, 18 deletions
diff --git a/bitbake/lib/bb/runqueue.py b/bitbake/lib/bb/runqueue.py
index 87c00462c1..774cdbca0b 100644
--- a/bitbake/lib/bb/runqueue.py
+++ b/bitbake/lib/bb/runqueue.py
@@ -1061,12 +1061,12 @@ class RunQueueData:
1061 seen_pn.append(pn) 1061 seen_pn.append(pn)
1062 else: 1062 else:
1063 bb.fatal("Multiple versions of %s are due to be built (%s). Only one version of a given PN should be built in any given build. You likely need to set PREFERRED_VERSION_%s to select the correct version or don't depend on multiple versions." % (pn, " ".join(prov_list[prov]), pn)) 1063 bb.fatal("Multiple versions of %s are due to be built (%s). Only one version of a given PN should be built in any given build. You likely need to set PREFERRED_VERSION_%s to select the correct version or don't depend on multiple versions." % (pn, " ".join(prov_list[prov]), pn))
1064 msg = "Multiple .bb files are due to be built which each provide %s:\n %s" % (prov, "\n ".join(prov_list[prov])) 1064 msgs = ["Multiple .bb files are due to be built which each provide %s:\n %s" % (prov, "\n ".join(prov_list[prov]))]
1065 # 1065 #
1066 # Construct a list of things which uniquely depend on each provider 1066 # Construct a list of things which uniquely depend on each provider
1067 # since this may help the user figure out which dependency is triggering this warning 1067 # since this may help the user figure out which dependency is triggering this warning
1068 # 1068 #
1069 msg += "\nA list of tasks depending on these providers is shown and may help explain where the dependency comes from." 1069 msgs.append("\nA list of tasks depending on these providers is shown and may help explain where the dependency comes from.")
1070 deplist = {} 1070 deplist = {}
1071 commondeps = None 1071 commondeps = None
1072 for provfn in prov_list[prov]: 1072 for provfn in prov_list[prov]:
@@ -1086,12 +1086,12 @@ class RunQueueData:
1086 commondeps &= deps 1086 commondeps &= deps
1087 deplist[provfn] = deps 1087 deplist[provfn] = deps
1088 for provfn in deplist: 1088 for provfn in deplist:
1089 msg += "\n%s has unique dependees:\n %s" % (provfn, "\n ".join(deplist[provfn] - commondeps)) 1089 msgs.append("\n%s has unique dependees:\n %s" % (provfn, "\n ".join(deplist[provfn] - commondeps)))
1090 # 1090 #
1091 # Construct a list of provides and runtime providers for each recipe 1091 # Construct a list of provides and runtime providers for each recipe
1092 # (rprovides has to cover RPROVIDES, PACKAGES, PACKAGES_DYNAMIC) 1092 # (rprovides has to cover RPROVIDES, PACKAGES, PACKAGES_DYNAMIC)
1093 # 1093 #
1094 msg += "\nIt could be that one recipe provides something the other doesn't and should. The following provider and runtime provider differences may be helpful." 1094 msgs.append("\nIt could be that one recipe provides something the other doesn't and should. The following provider and runtime provider differences may be helpful.")
1095 provide_results = {} 1095 provide_results = {}
1096 rprovide_results = {} 1096 rprovide_results = {}
1097 commonprovs = None 1097 commonprovs = None
@@ -1118,16 +1118,16 @@ class RunQueueData:
1118 else: 1118 else:
1119 commonrprovs &= rprovides 1119 commonrprovs &= rprovides
1120 rprovide_results[provfn] = rprovides 1120 rprovide_results[provfn] = rprovides
1121 #msg += "\nCommon provides:\n %s" % ("\n ".join(commonprovs)) 1121 #msgs.append("\nCommon provides:\n %s" % ("\n ".join(commonprovs)))
1122 #msg += "\nCommon rprovides:\n %s" % ("\n ".join(commonrprovs)) 1122 #msgs.append("\nCommon rprovides:\n %s" % ("\n ".join(commonrprovs)))
1123 for provfn in prov_list[prov]: 1123 for provfn in prov_list[prov]:
1124 msg += "\n%s has unique provides:\n %s" % (provfn, "\n ".join(provide_results[provfn] - commonprovs)) 1124 msgs.append("\n%s has unique provides:\n %s" % (provfn, "\n ".join(provide_results[provfn] - commonprovs)))
1125 msg += "\n%s has unique rprovides:\n %s" % (provfn, "\n ".join(rprovide_results[provfn] - commonrprovs)) 1125 msgs.append("\n%s has unique rprovides:\n %s" % (provfn, "\n ".join(rprovide_results[provfn] - commonrprovs)))
1126 1126
1127 if self.warn_multi_bb: 1127 if self.warn_multi_bb:
1128 logger.verbnote(msg) 1128 logger.verbnote("".join(msgs))
1129 else: 1129 else:
1130 logger.error(msg) 1130 logger.error("".join(msgs))
1131 1131
1132 self.init_progress_reporter.next_stage() 1132 self.init_progress_reporter.next_stage()
1133 1133
@@ -1935,7 +1935,7 @@ class RunQueueExecute:
1935 self.stats.taskFailed() 1935 self.stats.taskFailed()
1936 self.failed_tids.append(task) 1936 self.failed_tids.append(task)
1937 1937
1938 fakeroot_log = "" 1938 fakeroot_log = []
1939 if fakerootlog and os.path.exists(fakerootlog): 1939 if fakerootlog and os.path.exists(fakerootlog):
1940 with open(fakerootlog) as fakeroot_log_file: 1940 with open(fakerootlog) as fakeroot_log_file:
1941 fakeroot_failed = False 1941 fakeroot_failed = False
@@ -1945,12 +1945,12 @@ class RunQueueExecute:
1945 fakeroot_failed = True 1945 fakeroot_failed = True
1946 if 'doing new pid setup and server start' in line: 1946 if 'doing new pid setup and server start' in line:
1947 break 1947 break
1948 fakeroot_log = line + fakeroot_log 1948 fakeroot_log.append(line)
1949 1949
1950 if not fakeroot_failed: 1950 if not fakeroot_failed:
1951 fakeroot_log = None 1951 fakeroot_log = []
1952 1952
1953 bb.event.fire(runQueueTaskFailed(task, self.stats, exitcode, self.rq, fakeroot_log=fakeroot_log), self.cfgData) 1953 bb.event.fire(runQueueTaskFailed(task, self.stats, exitcode, self.rq, fakeroot_log=("".join(fakeroot_log) or None)), self.cfgData)
1954 1954
1955 if self.rqdata.taskData[''].abort: 1955 if self.rqdata.taskData[''].abort:
1956 self.rq.state = runQueueCleanUp 1956 self.rq.state = runQueueCleanUp
@@ -2608,12 +2608,13 @@ class RunQueueExecute:
2608 pn = self.rqdata.dataCaches[mc].pkg_fn[taskfn] 2608 pn = self.rqdata.dataCaches[mc].pkg_fn[taskfn]
2609 if not check_setscene_enforce_whitelist(pn, taskname, self.rqdata.setscenewhitelist): 2609 if not check_setscene_enforce_whitelist(pn, taskname, self.rqdata.setscenewhitelist):
2610 if tid in self.rqdata.runq_setscene_tids: 2610 if tid in self.rqdata.runq_setscene_tids:
2611 msg = 'Task %s.%s attempted to execute unexpectedly and should have been setscened' % (pn, taskname) 2611 msg = ['Task %s.%s attempted to execute unexpectedly and should have been setscened' % (pn, taskname)]
2612 else: 2612 else:
2613 msg = 'Task %s.%s attempted to execute unexpectedly' % (pn, taskname) 2613 msg = ['Task %s.%s attempted to execute unexpectedly' % (pn, taskname)]
2614 for t in self.scenequeue_notcovered: 2614 for t in self.scenequeue_notcovered:
2615 msg = msg + "\nTask %s, unihash %s, taskhash %s" % (t, self.rqdata.runtaskentries[t].unihash, self.rqdata.runtaskentries[t].hash) 2615 msg.append("\nTask %s, unihash %s, taskhash %s" % (t, self.rqdata.runtaskentries[t].unihash, self.rqdata.runtaskentries[t].hash))
2616 logger.error(msg + '\nThis is usually due to missing setscene tasks. Those missing in this build were: %s' % pprint.pformat(self.scenequeue_notcovered)) 2616 msg.append('\nThis is usually due to missing setscene tasks. Those missing in this build were: %s' % pprint.pformat(self.scenequeue_notcovered))
2617 logger.error("".join(msg))
2617 return True 2618 return True
2618 return False 2619 return False
2619 2620