diff mbox series

siggen/cache: Optionally allow adding siggen hash data to the bitbake cache

Message ID 20221201231131.1212052-1-richard.purdie@linuxfoundation.org
State Accepted, archived
Commit 0736a8a03da8b774fafbd28f746bef4705378049
Headers show
Series siggen/cache: Optionally allow adding siggen hash data to the bitbake cache | expand

Commit Message

Richard Purdie Dec. 1, 2022, 11:11 p.m. UTC
Being able to track siggen hash construction data can be useful for cache
debugging. For now, add an extra cache class which contains this information.
It can be enabled in the same way as the hob data cache through a feature flag
to cooker. This allows us to experiment with the data without carrying larger
patches around and ultimately may allow use to have a hash mismatch debugging
mode that is more easily enabled.

Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
---
 lib/bb/cache.py  | 25 +++++++++++++++++++++++++
 lib/bb/cooker.py | 10 +++++-----
 lib/bb/siggen.py |  4 ++++
 3 files changed, 34 insertions(+), 5 deletions(-)
diff mbox series

Patch

diff --git a/lib/bb/cache.py b/lib/bb/cache.py
index e1214d6ad2..436a5d2256 100644
--- a/lib/bb/cache.py
+++ b/lib/bb/cache.py
@@ -238,6 +238,31 @@  class CoreRecipeInfo(RecipeInfoCommon):
         cachedata.fakerootlogs[fn] = self.fakerootlogs
         cachedata.extradepsfunc[fn] = self.extradepsfunc
 
+
+class SiggenRecipeInfo(RecipeInfoCommon):
+    __slots__ = ()
+
+    classname = "SiggenRecipeInfo"
+    cachefile = "bb_cache_" + classname +".dat"
+    # we don't want to show this information in graph files so don't set cachefields
+    #cachefields = []
+
+    def __init__(self, filename, metadata):
+        self.siggen_gendeps = metadata.getVar("__siggen_gendeps", False)
+        self.siggen_varvals = metadata.getVar("__siggen_varvals", False)
+        self.siggen_taskdeps = metadata.getVar("__siggen_taskdeps", False)
+
+    @classmethod
+    def init_cacheData(cls, cachedata):
+        cachedata.siggen_taskdeps = {}
+        cachedata.siggen_gendeps = {}
+        cachedata.siggen_varvals = {}
+
+    def add_cacheData(self, cachedata, fn):
+        cachedata.siggen_gendeps[fn] = self.siggen_gendeps
+        cachedata.siggen_varvals[fn] = self.siggen_varvals
+        cachedata.siggen_taskdeps[fn] = self.siggen_taskdeps
+
 def virtualfn2realfn(virtualfn):
     """
     Convert a virtual file name to a real one + the associated subclass keyword
diff --git a/lib/bb/cooker.py b/lib/bb/cooker.py
index 5a5ba7fb70..4be95dd7fb 100644
--- a/lib/bb/cooker.py
+++ b/lib/bb/cooker.py
@@ -80,7 +80,7 @@  class SkippedPackage:
 
 
 class CookerFeatures(object):
-    _feature_list = [HOB_EXTRA_CACHES, BASEDATASTORE_TRACKING, SEND_SANITYEVENTS] = list(range(3))
+    _feature_list = [HOB_EXTRA_CACHES, BASEDATASTORE_TRACKING, SEND_SANITYEVENTS, RECIPE_SIGGEN_INFO] = list(range(4))
 
     def __init__(self):
         self._features=set()
@@ -367,12 +367,12 @@  class BBCooker:
         if CookerFeatures.BASEDATASTORE_TRACKING in self.featureset:
             self.enableDataTracking()
 
-        all_extra_cache_names = []
+        caches_name_array = ['bb.cache:CoreRecipeInfo']
         # We hardcode all known cache types in a single place, here.
         if CookerFeatures.HOB_EXTRA_CACHES in self.featureset:
-            all_extra_cache_names.append("bb.cache_extra:HobRecipeInfo")
-
-        caches_name_array = ['bb.cache:CoreRecipeInfo'] + all_extra_cache_names
+            caches_name_array.append("bb.cache_extra:HobRecipeInfo")
+        if CookerFeatures.RECIPE_SIGGEN_INFO in self.featureset:
+            caches_name_array.append("bb.cache:SiggenRecipeInfo")
 
         # At least CoreRecipeInfo will be loaded, so caches_array will never be empty!
         # This is the entry point, no further check needed!
diff --git a/lib/bb/siggen.py b/lib/bb/siggen.py
index 34b71d596a..3731cd6b69 100644
--- a/lib/bb/siggen.py
+++ b/lib/bb/siggen.py
@@ -252,6 +252,10 @@  class SignatureGeneratorBasic(SignatureGenerator):
             basehashes[task] = self.basehash[fn + ":" + task]
 
         d.setVar("__siggen_basehashes", basehashes)
+        d.setVar("__siggen_gendeps", self.gendeps[fn])
+        d.setVar("__siggen_varvals", self.lookupcache[fn])
+        d.setVar("__siggen_taskdeps", self.taskdeps[fn])
+
 
     def postparsing_clean_cache(self):
         #