mirror of
https://git.yoctoproject.org/poky
synced 2026-06-01 13:09:50 +00:00
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>
This commit is contained in:
committed by
Richard Purdie
parent
f543535e3c
commit
f738ed43e9
@@ -1457,14 +1457,20 @@ def edit_bblayers_conf(bblayers_conf, add, remove, edit_cb=None):
|
|||||||
|
|
||||||
return (notadded, notremoved)
|
return (notadded, notremoved)
|
||||||
|
|
||||||
|
def get_collection_res(d):
|
||||||
def get_file_layer(filename, d):
|
|
||||||
"""Determine the collection (as defined by a layer's layer.conf file) containing the specified file"""
|
|
||||||
collections = (d.getVar('BBFILE_COLLECTIONS') or '').split()
|
collections = (d.getVar('BBFILE_COLLECTIONS') or '').split()
|
||||||
collection_res = {}
|
collection_res = {}
|
||||||
for collection in collections:
|
for collection in collections:
|
||||||
collection_res[collection] = d.getVar('BBFILE_PATTERN_%s' % collection) or ''
|
collection_res[collection] = d.getVar('BBFILE_PATTERN_%s' % collection) or ''
|
||||||
|
|
||||||
|
return collection_res
|
||||||
|
|
||||||
|
|
||||||
|
def get_file_layer(filename, d, collection_res={}):
|
||||||
|
"""Determine the collection (as defined by a layer's layer.conf file) containing the specified file"""
|
||||||
|
if not collection_res:
|
||||||
|
collection_res = get_collection_res(d)
|
||||||
|
|
||||||
def path_to_layer(path):
|
def path_to_layer(path):
|
||||||
# Use longest path so we handle nested layers
|
# Use longest path so we handle nested layers
|
||||||
matchlen = 0
|
matchlen = 0
|
||||||
|
|||||||
@@ -21,6 +21,10 @@ def plugin_init(plugins):
|
|||||||
|
|
||||||
|
|
||||||
class QueryPlugin(LayerPlugin):
|
class QueryPlugin(LayerPlugin):
|
||||||
|
def __init__(self):
|
||||||
|
super(QueryPlugin, self).__init__()
|
||||||
|
self.collection_res = {}
|
||||||
|
|
||||||
def do_show_layers(self, args):
|
def do_show_layers(self, args):
|
||||||
"""show current configured layers."""
|
"""show current configured layers."""
|
||||||
logger.plain("%s %s %s" % ("layer".ljust(20), "path".ljust(40), "priority"))
|
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.
|
|||||||
multilayer = True
|
multilayer = True
|
||||||
if prov[0] != pref[0]:
|
if prov[0] != pref[0]:
|
||||||
same_ver = False
|
same_ver = False
|
||||||
|
|
||||||
if (multilayer or not show_overlayed_only) and (same_ver or not show_same_ver_only):
|
if (multilayer or not show_overlayed_only) and (same_ver or not show_same_ver_only):
|
||||||
if not items_listed:
|
if not items_listed:
|
||||||
logger.plain('=== %s ===' % title)
|
logger.plain('=== %s ===' % title)
|
||||||
@@ -243,8 +246,13 @@ skipped recipes will also be listed, with a " (skipped)" suffix.
|
|||||||
else:
|
else:
|
||||||
return '?'
|
return '?'
|
||||||
|
|
||||||
|
def get_collection_res(self):
|
||||||
|
if not self.collection_res:
|
||||||
|
self.collection_res = bb.utils.get_collection_res(self.tinfoil.config_data)
|
||||||
|
return self.collection_res
|
||||||
|
|
||||||
def get_file_layerdir(self, filename):
|
def get_file_layerdir(self, filename):
|
||||||
layer = bb.utils.get_file_layer(filename, self.tinfoil.config_data)
|
layer = bb.utils.get_file_layer(filename, self.tinfoil.config_data, self.get_collection_res())
|
||||||
return self.bbfile_collections.get(layer, None)
|
return self.bbfile_collections.get(layer, None)
|
||||||
|
|
||||||
def remove_layer_prefix(self, f):
|
def remove_layer_prefix(self, f):
|
||||||
|
|||||||
Reference in New Issue
Block a user