new method for loading cache, an improment on incremental build
PATCH 1/1 new method for loading cache, an improment on incremental build
In our project,we have over 4000 patches and 300hundred bb's. Then loading cache in incremental build is very slow. I figured out that it is due to a problem algorithm in cache.py
And i have give out a improvement.
the old method is O(N^2) time complexity and new one is O(N)
poky-sumo-19.0.1/bitbake/lib/bb/cache.py +27 -20
@@ -610,31 +610,38 @@ class Cache(NoCache): fn, f) self.remove(fn) return False - + import re 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: - continue - f, exist = f.split(":") - if (exist == "True" and not os.path.exists(f)) or (exist == "False" and os.path.exists(f)): - logger.debug(2, "Cache: %s's file checksum list file %s changed", - fn, f) + flist=re.split(r'(:True|:False)',fl) + for i in range(len(flist)): + if ( ":True" == flist[i].strip() and not os.path.exists(flist[i-1].strip())) or ( ":False" == flist[i].strip() and os.path.exists(flist[i-1].strip())): + logger.error(2, "Cache: %s's file checksum list file %s changed", + fn, flist[i-1]) self.remove(fn) return False + #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: + #continue + #f, exist = f.split(":") + #if (exist == "True" and not os.path.exists(f)) or (exist == "False" and os.path.exists(f)): + #logger.debug(2, "Cache: %s's file checksum list file %s changed", + #fn, f) + #self.remove(fn) + #return False if appends != info_array[0].appends: logger.debug(2, "Cache: appends for %s changed", fn)