Skip to contentSkip to conversation

data_smart: Handle hashing of datastores within datastores correctly

PATCH New Richard Purdie 1 participant 2 messages Apr 8, 2020

lore
Share & tools
lore
#0 lore raw

PATCH 1/2 data_smart: Handle hashing of datastores within datastores correctly

If there is a datastore within a datastore (e.g. BB_ORIGENV) then get-hash() doesn;t correclty handle the contents using the memory address instead of the contents.

This is a patch from [email protected] which addresses this problem. Its been low priority since we don't include BB_ORIGENV anywhere this would cause an issue as standard.

[YOCTO #12473]

---
 lib/bb/data_smart.py | 5 ++++-
 1 file changed, 4 insertions(+), 1 deletion(-)
lib/bb/data_smart.py +4 -1
index 70257ab7f8..7f1b6dcb4f 100644
@@ -1000,7 +1000,10 @@ class DataSmart(MutableMapping):
                 continue
 
             value = d.getVar(key, False) or ""
-            data.update({key:value})
+            if type(value) is type(self):
+                data.update({key:value.get_hash()})
+            else:
+                data.update({key:value})
 
             varflags = d.getVarFlags(key, internalflags = True)
             if not varflags:
Signature · 1 line
2.25.1
#1 lore raw

PATCH 2/2 cache: Fix performance problem with large numbers of source files

Some companies are using large numbers of patch files in SRC_URI. Rightly or wrongly that exposes a performance problem where the code does not handle the large string manipulations in a way which works efficienty in python.

This is a modified version of a patch from z00539568 <[email protected]@qq.com which addresses the performance problem. I modified it to use a more advanced regex, retain the "*" check and cache the regex.

[YOCTO #13824]

---
 lib/bb/cache.py | 22 ++++++++--------------
 1 file changed, 8 insertions(+), 14 deletions(-)
lib/bb/cache.py +8 -14
index a5aaf3b999..d1be83617b 100644
@@ -21,6 +21,7 @@ import logging
 import pickle
 from collections import defaultdict
 import bb.utils
+import re
 
 logger = logging.getLogger("BitBake.Cache")
 
@@ -369,6 +370,7 @@ class Cache(NoCache):
         self.data_fn = None
         self.cacheclean = True
         self.data_hash = data_hash
+        self.filelist_regex = re.compile(r'(?:(?<=:True)|(?<=:False))\s+')
 
         if self.cachedir in [None, '']:
             self.has_cache = False
@@ -607,20 +609,12 @@ class Cache(NoCache):
         if hasattr(info_array[0], 'file_checksums'):
             for _, fl in info_array[0].file_checksums.items():
                 fl = fl.strip()
-                while fl:
-                    # A .split() would be simpler but means spaces or colons in filenames would break
-                    a = fl.find(":True")
-                    b = fl.find(":False")
-                    if ((a < 0) and b) or ((b > 0) and (b < a)):
-                        f = fl[:b+6]
-                        fl = fl[b+7:]
-                    elif ((b < 0) and a) or ((a > 0) and (a < b)):
-                        f = fl[:a+5]
-                        fl = fl[a+6:]
-                    else:
-                        break
-                    fl = fl.strip()
-                    if "*" in f:
+                if not fl:
+                    continue
+                # Have to be careful about spaces and colons in filenames
+                flist = self.filelist_regex.split(fl)
+                for f in flist:
+                    if not f or "*" in f:
                         continue
                     f, exist = f.split(":")
                     if (exist == "True" and not os.path.exists(f)) or (exist == "False" and os.path.exists(f)):
Signature · 1 line
2.25.1