summaryrefslogtreecommitdiffstats
path: root/bitbake
diff options
context:
space:
mode:
authorRobert Yang <liezhi.yang@windriver.com>2020-09-09 04:55:20 -0700
committerRichard Purdie <richard.purdie@linuxfoundation.org>2020-09-10 13:49:21 +0100
commitf738ed43e93eaf971615ef5105ece567f280c85e (patch)
treeb51ce9ee8ec5948af22e1a3dbc3127b711279bf3 /bitbake
parentf543535e3ca4d86bee10801450dc22f3b5382b4c (diff)
downloadpoky-f738ed43e93eaf971615ef5105ece567f280c85e.tar.gz
bitbake: utils.py: get_file_layer(): Improve performance
The following code costs a lot of time when there are lot of layers and recipes: for collection in collections: collection_res[collection] = d.getVar('BBFILE_PATTERN_%s' % collection) or '' My build has more than 100 layers and 3000 recipes, which calls d.getVar() 300K (3000 * 100) times and makes 'bitbake-layers show-recipes' very slow, add a keyword argument to get_file_layer() can fix the problem, it can save about 90% time in my build (6min -> 40s). (Bitbake rev: f08a6601c9bb09622855d62e1cedb92fafd2f71d) Signed-off-by: Robert Yang <liezhi.yang@windriver.com> Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
Diffstat (limited to 'bitbake')
-rw-r--r--bitbake/lib/bb/utils.py12
-rw-r--r--bitbake/lib/bblayers/query.py12
2 files changed, 19 insertions, 5 deletions
diff --git a/bitbake/lib/bb/utils.py b/bitbake/lib/bb/utils.py
index b7e2c9218b..d6afa21542 100644
--- a/bitbake/lib/bb/utils.py
+++ b/bitbake/lib/bb/utils.py
@@ -1457,14 +1457,20 @@ def edit_bblayers_conf(bblayers_conf, add, remove, edit_cb=None):
1457 1457
1458 return (notadded, notremoved) 1458 return (notadded, notremoved)
1459 1459
1460 1460def get_collection_res(d):
1461def get_file_layer(filename, d):
1462 """Determine the collection (as defined by a layer's layer.conf file) containing the specified file"""
1463 collections = (d.getVar('BBFILE_COLLECTIONS') or '').split() 1461 collections = (d.getVar('BBFILE_COLLECTIONS') or '').split()
1464 collection_res = {} 1462 collection_res = {}
1465 for collection in collections: 1463 for collection in collections:
1466 collection_res[collection] = d.getVar('BBFILE_PATTERN_%s' % collection) or '' 1464 collection_res[collection] = d.getVar('BBFILE_PATTERN_%s' % collection) or ''
1467 1465
1466 return collection_res
1467
1468
1469def get_file_layer(filename, d, collection_res={}):
1470 """Determine the collection (as defined by a layer's layer.conf file) containing the specified file"""
1471 if not collection_res:
1472 collection_res = get_collection_res(d)
1473
1468 def path_to_layer(path): 1474 def path_to_layer(path):
1469 # Use longest path so we handle nested layers 1475 # Use longest path so we handle nested layers
1470 matchlen = 0 1476 matchlen = 0
diff --git a/bitbake/lib/bblayers/query.py b/bitbake/lib/bblayers/query.py
index ee2db0efed..f5e3c84747 100644
--- a/bitbake/lib/bblayers/query.py
+++ b/bitbake/lib/bblayers/query.py
@@ -21,6 +21,10 @@ def plugin_init(plugins):
21 21
22 22
23class QueryPlugin(LayerPlugin): 23class QueryPlugin(LayerPlugin):
24 def __init__(self):
25 super(QueryPlugin, self).__init__()
26 self.collection_res = {}
27
24 def do_show_layers(self, args): 28 def do_show_layers(self, args):
25 """show current configured layers.""" 29 """show current configured layers."""
26 logger.plain("%s %s %s" % ("layer".ljust(20), "path".ljust(40), "priority")) 30 logger.plain("%s %s %s" % ("layer".ljust(20), "path".ljust(40), "priority"))
@@ -222,7 +226,6 @@ skipped recipes will also be listed, with a " (skipped)" suffix.
222 multilayer = True 226 multilayer = True
223 if prov[0] != pref[0]: 227 if prov[0] != pref[0]:
224 same_ver = False 228 same_ver = False
225
226 if (multilayer or not show_overlayed_only) and (same_ver or not show_same_ver_only): 229 if (multilayer or not show_overlayed_only) and (same_ver or not show_same_ver_only):
227 if not items_listed: 230 if not items_listed:
228 logger.plain('=== %s ===' % title) 231 logger.plain('=== %s ===' % title)
@@ -243,8 +246,13 @@ skipped recipes will also be listed, with a " (skipped)" suffix.
243 else: 246 else:
244 return '?' 247 return '?'
245 248
249 def get_collection_res(self):
250 if not self.collection_res:
251 self.collection_res = bb.utils.get_collection_res(self.tinfoil.config_data)
252 return self.collection_res
253
246 def get_file_layerdir(self, filename): 254 def get_file_layerdir(self, filename):
247 layer = bb.utils.get_file_layer(filename, self.tinfoil.config_data) 255 layer = bb.utils.get_file_layer(filename, self.tinfoil.config_data, self.get_collection_res())
248 return self.bbfile_collections.get(layer, None) 256 return self.bbfile_collections.get(layer, None)
249 257
250 def remove_layer_prefix(self, f): 258 def remove_layer_prefix(self, f):