aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorRichard Purdie <richard.purdie@linuxfoundation.org>2020-02-17 16:18:25 +0000
committerRichard Purdie <richard.purdie@linuxfoundation.org>2020-02-18 13:58:53 +0000
commitd411b097d810c386d35dc561f8812bb3f35c9a36 (patch)
tree1a65a03fc399a908f922a9338312aba6de5894e7
parentaa770081d7d3ff678b18117a4b4e9b3da09b72be (diff)
downloadbitbake-contrib-d411b097d810c386d35dc561f8812bb3f35c9a36.tar.gz
cooker/siggen: Empty siggen cache during parsing
When parsing recipes its apparent the memory usage of bitbake rises linearly with number of recipes parsed. It shouldn't. Using tracemalloc (thanks for the tip Joshua Lock) it was clear that the dependency information left behind in siggen was the culprit. Add a new method to allow us to drop this information. We don't need it after the recipe has been parsed and hashes calculated (at runtime its different but only the currently executing task would be in memory). This should give signficant memory usage improvements for bitbake and that in turn should help speed on more constrained systems, as well as when used in multiconfig environments. Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
-rw-r--r--lib/bb/cooker.py3
-rw-r--r--lib/bb/siggen.py11
2 files changed, 13 insertions, 1 deletions
diff --git a/lib/bb/cooker.py b/lib/bb/cooker.py
index 77d18a5d0..cfac91bae 100644
--- a/lib/bb/cooker.py
+++ b/lib/bb/cooker.py
@@ -1934,7 +1934,8 @@ class Parser(multiprocessing.Process):
except IndexError:
break
result = self.parse(*job)
-
+ # Clear the siggen cache after parsing to control memory usage, its huge
+ bb.parse.siggen.postparsing_clean_cache()
try:
self.results.put(result, timeout=0.25)
except queue.Full:
diff --git a/lib/bb/siggen.py b/lib/bb/siggen.py
index 3e2a85fc8..9c299d45e 100644
--- a/lib/bb/siggen.py
+++ b/lib/bb/siggen.py
@@ -48,6 +48,9 @@ class SignatureGenerator(object):
def get_unihash(self, task):
return self.taskhash[task]
+ def postparsing_clean_cache(self):
+ return
+
def get_taskhash(self, fn, task, deps, dataCache):
return "0"
@@ -152,6 +155,14 @@ class SignatureGeneratorBasic(SignatureGenerator):
for task in taskdeps:
d.setVar("BB_BASEHASH_task-%s" % task, self.basehash[fn + "." + task])
+ def postparsing_clean_cache(self):
+ #
+ # After parsing we can remove some things from memory to reduce our memory footprint
+ #
+ self.gendeps = {}
+ self.lookupcache = {}
+ self.taskdeps = {}
+
def rundep_check(self, fn, recipename, task, dep, depname, dataCache):
# Return True if we should keep the dependency, False to drop it
# We only manipulate the dependencies for packages not in the whitelist