cache: Drop broken/unused code
PATCH 1/2 cache: Drop broken/unused code
Some parts of functions in Cache() were broken and unused, there was also a totally unused function. This was historical as a result of the cooker parsing process needing to handle cached entries in the main thread but parsing actions in seperate processes.
Document the way it works, update the function name to be clear about what it now does and drop the old code which was unused.
--- lib/bb/cache.py | 54 +++++++++++++++--------------------------------- lib/bb/cooker.py | 4 ++-- 2 files changed, 19 insertions(+), 39 deletions(-)
lib/bb/cache.py +17 -37
@@ -280,7 +280,11 @@ def variant2virtual(realfn, variant): return "mc:" + elems[1] + ":" + realfn return "virtual:" + variant + ":" + realfn - +# +# Cooker calls cacheValid on its recipe list, then either calls loadCached +# from it's main thread or parse from separate processes to generate an up to +# date cache +# class Cache(object): """ BitBake Cache implementation
@@ -447,43 +451,19 @@ class Cache(object): return infos - def load(self, filename, appends): + def loadCached(self, filename, appends): """Obtain the recipe information for the specified filename, - using cached values if available, otherwise parsing. - - Note that if it does parse to obtain the info, it will not - automatically add the information to the cache or to your - CacheData. Use the add or add_info method to do so after - running this, or use loadData instead.""" - cached = self.cacheValid(filename, appends) - if cached: - infos = [] - # info_array item is a list of [CoreRecipeInfo, XXXRecipeInfo] - info_array = self.depends_cache[filename] - for variant in info_array[0].variants: - virtualfn = variant2virtual(filename, variant) - infos.append((virtualfn, self.depends_cache[virtualfn])) - else: - return self.parse(filename, appends, configdata, self.caches_array) - - return cached, infos - - def loadData(self, fn, appends, cacheData): - """Load the recipe info for the specified filename, - parsing and adding to the cache if necessary, and adding - the recipe information to the supplied CacheData instance.""" - skipped, virtuals = 0, 0 - - cached, infos = self.load(fn, appends) - for virtualfn, info_array in infos: - if info_array[0].skipped: - self.logger.debug("Skipping %s: %s", virtualfn, info_array[0].skipreason) - skipped += 1 - else: - self.add_info(virtualfn, info_array, cacheData, not cached) - virtuals += 1 - - return cached, skipped, virtuals + using cached values. + """ + + infos = [] + # info_array item is a list of [CoreRecipeInfo, XXXRecipeInfo] + info_array = self.depends_cache[filename] + for variant in info_array[0].variants: + virtualfn = variant2virtual(filename, variant) + infos.append((virtualfn, self.depends_cache[virtualfn])) + + return infos def cacheValid(self, fn, appends): """
lib/bb/cooker.py +2 -2
@@ -2287,8 +2287,8 @@ class CookerParser(object): def load_cached(self): for mc, cache, filename, appends in self.fromcache: - cached, infos = cache.load(filename, appends) - yield not cached, mc, infos + infos = cache.loadCached(filename, appends) + yield False, mc, infos def parse_generator(self): empty = False
Signature · 1 line
2.34.1
PATCH 2/2 cache: Drop unused function
At this point users appear to all cann add_info directly. Failing to do that means the file dependency tracking code isn't active so would cause problems. Therefore drop the unused function.
--- lib/bb/cache.py | 12 ------------ 1 file changed, 12 deletions(-)
lib/bb/cache.py +0 -12
@@ -649,18 +649,6 @@ class Cache(object): self.cacheclean = False self.depends_cache[filename] = info_array - def add(self, file_name, data, cacheData, parsed=None): - """ - Save data we need into the cache - """ - - realfn = virtualfn2realfn(file_name)[0] - - info_array = [] - for cache_class in self.caches_array: - info_array.append(cache_class(realfn, data)) - self.add_info(file_name, info_array, cacheData, parsed) - class MulticonfigCache(Mapping): def __init__(self, databuilder, data_hash, caches_array): def progress(p):
Signature · 1 line
2.34.1
RE: [bitbake-devel] [PATCH 2/2] cache: Drop unused function
Quoted 7 lines
-----Original Message-----
From: [email protected] <[email protected]> On Behalf Of Richard Purdie
Sent: den 16 november 2022 13:21
To: [email protected]
Subject: [bitbake-devel] [PATCH 2/2] cache: Drop unused functionAt this point users appear to all cann
add_infodirectly. Failing
Change "cann" to "call".
Quoted 32 lines
to do that means the file dependency tracking code isn't active so would cause problems. Therefore drop the unused function.
Signed-off-by Richard Purdie <[email protected]>--- lib/bb/cache.py | 12 ------------ 1 file changed, 12 deletions(-)lib/bb/cache.py +0
-13@@ -649,18 +649,6 @@ class Cache(object): self.cacheclean = False self.depends_cache[filename] = info_array - def add(self, file_name, data, cacheData, parsed=None): - """ - Save data we need into the cache - """ - - realfn = virtualfn2realfn(file_name)[0] - - info_array = [] - for cache_class in self.caches_array: - info_array.append(cache_class(realfn, data)) - self.add_info(file_name, info_array, cacheData, parsed) - class MulticonfigCache(Mapping): def __init__(self, databuilder, data_hash, caches_array): def progress(p): --
Quoted 1 line
2.34.1
//Peter