summaryrefslogtreecommitdiffstats
path: root/bitbake/lib/bb/cooker.py
diff options
context:
space:
mode:
authorJoshua Watt <JPEWhacker@gmail.com>2020-06-05 22:15:30 -0500
committerRichard Purdie <richard.purdie@linuxfoundation.org>2020-06-10 12:30:01 +0100
commitf8163c22f46551f81fd8cb74856d021a46cc0d65 (patch)
treea0fdc2d88dc6e526f4defd4b4cb7603276bd5d25 /bitbake/lib/bb/cooker.py
parentb9fdb6a4261754459a01f9689010a38922fe0c8a (diff)
downloadpoky-f8163c22f46551f81fd8cb74856d021a46cc0d65.tar.gz
bitbake: bitbake: cache: Use multiconfig aware caches
Splits the parsing cache to maintain one cache per multiconfig instead of one global cache. This is necessary now that the files and appends can vary for each multiconfig. A bb.cache.MulticonfigCache dictionary-like proxy object is created instead of a single bb.cache.Cache object. This object will create and properly initialize bb.cache.Cache object for each multiconfig, and each of these caches has a dedicated cache file with a name based on the multiconfig. (Bitbake rev: 5272f2489586479880ae8d046dfcdbe0963ee5bb) Signed-off-by: Joshua Watt <JPEWhacker@gmail.com> Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
Diffstat (limited to 'bitbake/lib/bb/cooker.py')
-rw-r--r--bitbake/lib/bb/cooker.py42
1 files changed, 25 insertions, 17 deletions
diff --git a/bitbake/lib/bb/cooker.py b/bitbake/lib/bb/cooker.py
index 8f45233c8d..50526d52b2 100644
--- a/bitbake/lib/bb/cooker.py
+++ b/bitbake/lib/bb/cooker.py
@@ -541,8 +541,8 @@ class BBCooker:
541 541
542 if fn: 542 if fn:
543 try: 543 try:
544 bb_cache = bb.cache.Cache(self.databuilder, self.data_hash, self.caches_array) 544 bb_caches = bb.cache.MulticonfigCache(self.databuilder, self.data_hash, self.caches_array)
545 envdata = bb_cache.loadDataFull(fn, self.collections[mc].get_file_appends(fn)) 545 envdata = bb_caches[mc].loadDataFull(fn, self.collections[mc].get_file_appends(fn))
546 except Exception as e: 546 except Exception as e:
547 parselog.exception("Unable to read %s", fn) 547 parselog.exception("Unable to read %s", fn)
548 raise 548 raise
@@ -1328,9 +1328,9 @@ class BBCooker:
1328 self.buildSetVars() 1328 self.buildSetVars()
1329 self.reset_mtime_caches() 1329 self.reset_mtime_caches()
1330 1330
1331 bb_cache = bb.cache.Cache(self.databuilder, self.data_hash, self.caches_array) 1331 bb_caches = bb.cache.MulticonfigCache(self.databuilder, self.data_hash, self.caches_array)
1332 1332
1333 infos = bb_cache.parse(fn, self.collections[mc].get_file_appends(fn)) 1333 infos = bb_caches[mc].parse(fn, self.collections[mc].get_file_appends(fn))
1334 infos = dict(infos) 1334 infos = dict(infos)
1335 1335
1336 fn = bb.cache.realfn2virtual(fn, cls, mc) 1336 fn = bb.cache.realfn2virtual(fn, cls, mc)
@@ -1968,7 +1968,7 @@ class Parser(multiprocessing.Process):
1968 except queue.Full: 1968 except queue.Full:
1969 pending.append(result) 1969 pending.append(result)
1970 1970
1971 def parse(self, filename, appends): 1971 def parse(self, mc, cache, filename, appends):
1972 try: 1972 try:
1973 origfilter = bb.event.LogHandler.filter 1973 origfilter = bb.event.LogHandler.filter
1974 # Record the filename we're parsing into any events generated 1974 # Record the filename we're parsing into any events generated
@@ -1982,7 +1982,7 @@ class Parser(multiprocessing.Process):
1982 bb.event.set_class_handlers(self.handlers.copy()) 1982 bb.event.set_class_handlers(self.handlers.copy())
1983 bb.event.LogHandler.filter = parse_filter 1983 bb.event.LogHandler.filter = parse_filter
1984 1984
1985 return True, self.bb_cache.parse(filename, appends) 1985 return True, mc, cache.parse(filename, appends)
1986 except Exception as exc: 1986 except Exception as exc:
1987 tb = sys.exc_info()[2] 1987 tb = sys.exc_info()[2]
1988 exc.recipe = filename 1988 exc.recipe = filename
@@ -2016,16 +2016,16 @@ class CookerParser(object):
2016 self.current = 0 2016 self.current = 0
2017 self.process_names = [] 2017 self.process_names = []
2018 2018
2019 self.bb_cache = bb.cache.Cache(self.cfgbuilder, self.cfghash, cooker.caches_array) 2019 self.bb_caches = bb.cache.MulticonfigCache(self.cfgbuilder, self.cfghash, cooker.caches_array)
2020 self.fromcache = set() 2020 self.fromcache = set()
2021 self.willparse = set() 2021 self.willparse = set()
2022 for mc in self.cooker.multiconfigs: 2022 for mc in self.cooker.multiconfigs:
2023 for filename in self.mcfilelist[mc]: 2023 for filename in self.mcfilelist[mc]:
2024 appends = self.cooker.collections[mc].get_file_appends(filename) 2024 appends = self.cooker.collections[mc].get_file_appends(filename)
2025 if not self.bb_cache.cacheValid(filename, appends): 2025 if not self.bb_caches[mc].cacheValid(filename, appends):
2026 self.willparse.add((filename, appends)) 2026 self.willparse.add((mc, self.bb_caches[mc], filename, appends))
2027 else: 2027 else:
2028 self.fromcache.add((filename, appends)) 2028 self.fromcache.add((mc, self.bb_caches[mc], filename, appends))
2029 2029
2030 self.total = len(self.fromcache) + len(self.willparse) 2030 self.total = len(self.fromcache) + len(self.willparse)
2031 self.toparse = len(self.willparse) 2031 self.toparse = len(self.willparse)
@@ -2043,7 +2043,6 @@ class CookerParser(object):
2043 if self.toparse: 2043 if self.toparse:
2044 bb.event.fire(bb.event.ParseStarted(self.toparse), self.cfgdata) 2044 bb.event.fire(bb.event.ParseStarted(self.toparse), self.cfgdata)
2045 def init(): 2045 def init():
2046 Parser.bb_cache = self.bb_cache
2047 bb.utils.set_process_name(multiprocessing.current_process().name) 2046 bb.utils.set_process_name(multiprocessing.current_process().name)
2048 multiprocessing.util.Finalize(None, bb.codeparser.parser_cache_save, exitpriority=1) 2047 multiprocessing.util.Finalize(None, bb.codeparser.parser_cache_save, exitpriority=1)
2049 multiprocessing.util.Finalize(None, bb.fetch.fetcher_parse_save, exitpriority=1) 2048 multiprocessing.util.Finalize(None, bb.fetch.fetcher_parse_save, exitpriority=1)
@@ -2099,7 +2098,11 @@ class CookerParser(object):
2099 else: 2098 else:
2100 process.join() 2099 process.join()
2101 2100
2102 sync = threading.Thread(target=self.bb_cache.sync) 2101 def sync_caches():
2102 for c in self.bb_caches.values():
2103 c.sync()
2104
2105 sync = threading.Thread(target=sync_caches)
2103 sync.start() 2106 sync.start()
2104 multiprocessing.util.Finalize(None, sync.join, exitpriority=-100) 2107 multiprocessing.util.Finalize(None, sync.join, exitpriority=-100)
2105 bb.codeparser.parser_cache_savemerge() 2108 bb.codeparser.parser_cache_savemerge()
@@ -2116,8 +2119,8 @@ class CookerParser(object):
2116 print("Processed parsing statistics saved to %s" % (pout)) 2119 print("Processed parsing statistics saved to %s" % (pout))
2117 2120
2118 def load_cached(self): 2121 def load_cached(self):
2119 for mc, filename, appends in self.fromcache: 2122 for mc, cache, filename, appends in self.fromcache:
2120 cached, infos = self.bb_cache.load(mc, filename, appends) 2123 cached, infos = cache.load(filename, appends)
2121 yield not cached, mc, infos 2124 yield not cached, mc, infos
2122 2125
2123 def parse_generator(self): 2126 def parse_generator(self):
@@ -2196,8 +2199,13 @@ class CookerParser(object):
2196 if info_array[0].skipped: 2199 if info_array[0].skipped:
2197 self.skipped += 1 2200 self.skipped += 1
2198 self.cooker.skiplist[virtualfn] = SkippedPackage(info_array[0]) 2201 self.cooker.skiplist[virtualfn] = SkippedPackage(info_array[0])
2199 (fn, cls, mc) = bb.cache.virtualfn2realfn(virtualfn) 2202 (fn, cls, fnmc) = bb.cache.virtualfn2realfn(virtualfn)
2200 self.bb_cache.add_info(virtualfn, info_array, self.cooker.recipecaches[mc], 2203
2204 if fnmc == mc:
2205 cache = self.cooker.recipecaches[mc]
2206 else:
2207 cache = None
2208 self.bb_caches[mc].add_info(virtualfn, info_array, cache,
2201 parsed=parsed, watcher = self.cooker.add_filewatch) 2209 parsed=parsed, watcher = self.cooker.add_filewatch)
2202 return True 2210 return True
2203 2211
@@ -2207,6 +2215,6 @@ class CookerParser(object):
2207 to_reparse.add((mc, filename, self.cooker.collections[mc].get_file_appends(filename))) 2215 to_reparse.add((mc, filename, self.cooker.collections[mc].get_file_appends(filename)))
2208 2216
2209 for mc, filename, appends in to_reparse: 2217 for mc, filename, appends in to_reparse:
2210 infos = self.bb_cache.parse(filename, appends) 2218 infos = self.bb_caches[mc].parse(filename, appends)
2211 for vfn, info_array in infos: 2219 for vfn, info_array in infos:
2212 self.cooker.recipecaches[mc].add_from_recipeinfo(vfn, info_array) 2220 self.cooker.recipecaches[mc].add_from_recipeinfo(vfn, info_array)