diff options
author | Robert Yang <liezhi.yang@windriver.com> | 2020-09-09 04:55:20 -0700 |
---|---|---|
committer | Richard Purdie <richard.purdie@linuxfoundation.org> | 2020-09-10 13:49:21 +0100 |
commit | f738ed43e93eaf971615ef5105ece567f280c85e (patch) | |
tree | b51ce9ee8ec5948af22e1a3dbc3127b711279bf3 /bitbake/lib/bb | |
parent | f543535e3ca4d86bee10801450dc22f3b5382b4c (diff) | |
download | poky-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/lib/bb')
-rw-r--r-- | bitbake/lib/bb/utils.py | 12 |
1 files changed, 9 insertions, 3 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 | 1460 | def get_collection_res(d): | |
1461 | def 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 | |||
1469 | def 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 |