diff options
author | Alexander Kanavin <alex.kanavin@gmail.com> | 2019-01-23 17:17:43 +0100 |
---|---|---|
committer | Richard Purdie <richard.purdie@linuxfoundation.org> | 2019-01-26 13:39:37 +0000 |
commit | 411e2b7047b04edb9065f84d96cc7d14224c5032 (patch) | |
tree | 296d49c9b77ec64faf931a3e867773fe0cea8db1 /meta | |
parent | 58232c6df8619e715a2f1d5532b9b535b3dbe343 (diff) | |
download | poky-411e2b7047b04edb9065f84d96cc7d14224c5032.tar.gz |
lib/oe/reciputils.py: parallelize upstream version checks
Previously this was done via bitbake tasks, and when this
was rewritten to a for loop, performance sufered significantly:
from 90 seconds to about 12 minutes for oe-core. This change
restores the previous run time, and makes it possible
to perform such checks with command line utilities in an
interactive way.
Implementation note: we have to create a copy of the recipe
data, as Tinfoil API can't be used from multiple threads
and only allows one process to access the data at a time.
(From OE-Core rev: b1d01911fa2a0a4945da071d66fb50e9f14ded81)
Signed-off-by: Alexander Kanavin <alex.kanavin@gmail.com>
Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
Diffstat (limited to 'meta')
-rw-r--r-- | meta/lib/oe/recipeutils.py | 77 |
1 files changed, 56 insertions, 21 deletions
diff --git a/meta/lib/oe/recipeutils.py b/meta/lib/oe/recipeutils.py index 39d3de4bb1..92c0f65257 100644 --- a/meta/lib/oe/recipeutils.py +++ b/meta/lib/oe/recipeutils.py | |||
@@ -1020,8 +1020,54 @@ def get_recipe_upstream_version(rd): | |||
1020 | 1020 | ||
1021 | return ru | 1021 | return ru |
1022 | 1022 | ||
1023 | def _get_recipe_upgrade_status(data): | ||
1024 | uv = get_recipe_upstream_version(data) | ||
1025 | |||
1026 | pn = data.getVar('PN') | ||
1027 | cur_ver = uv['current_version'] | ||
1028 | |||
1029 | upstream_version_unknown = data.getVar('UPSTREAM_VERSION_UNKNOWN') | ||
1030 | if not uv['version']: | ||
1031 | status = "UNKNOWN" if upstream_version_unknown else "UNKNOWN_BROKEN" | ||
1032 | else: | ||
1033 | cmp = vercmp_string(uv['current_version'], uv['version']) | ||
1034 | if cmp == -1: | ||
1035 | status = "UPDATE" if not upstream_version_unknown else "KNOWN_BROKEN" | ||
1036 | elif cmp == 0: | ||
1037 | status = "MATCH" if not upstream_version_unknown else "KNOWN_BROKEN" | ||
1038 | else: | ||
1039 | status = "UNKNOWN" if upstream_version_unknown else "UNKNOWN_BROKEN" | ||
1040 | |||
1041 | next_ver = uv['version'] if uv['version'] else "N/A" | ||
1042 | revision = uv['revision'] if uv['revision'] else "N/A" | ||
1043 | maintainer = data.getVar('RECIPE_MAINTAINER') | ||
1044 | no_upgrade_reason = data.getVar('RECIPE_NO_UPDATE_REASON') | ||
1045 | |||
1046 | return (pn, status, cur_ver, next_ver, maintainer, revision, no_upgrade_reason) | ||
1047 | |||
1023 | def get_recipe_upgrade_status(recipes=None): | 1048 | def get_recipe_upgrade_status(recipes=None): |
1024 | pkgs_list = [] | 1049 | pkgs_list = [] |
1050 | data_copy_list = [] | ||
1051 | copy_vars = ('SRC_URI', | ||
1052 | 'PV', | ||
1053 | 'GITDIR', | ||
1054 | 'DL_DIR', | ||
1055 | 'PN', | ||
1056 | 'CACHE', | ||
1057 | 'PERSISTENT_DIR', | ||
1058 | 'BB_URI_HEADREVS', | ||
1059 | 'UPSTREAM_CHECK_COMMITS', | ||
1060 | 'UPSTREAM_CHECK_GITTAGREGEX', | ||
1061 | 'UPSTREAM_CHECK_REGEX', | ||
1062 | 'UPSTREAM_CHECK_URI', | ||
1063 | 'UPSTREAM_VERSION_UNKNOWN', | ||
1064 | 'RECIPE_MAINTAINER', | ||
1065 | 'RECIPE_NO_UPDATE_REASON', | ||
1066 | 'RECIPE_UPSTREAM_VERSION', | ||
1067 | 'RECIPE_UPSTREAM_DATE', | ||
1068 | 'CHECK_DATE', | ||
1069 | ) | ||
1070 | |||
1025 | with bb.tinfoil.Tinfoil() as tinfoil: | 1071 | with bb.tinfoil.Tinfoil() as tinfoil: |
1026 | tinfoil.prepare(config_only=False) | 1072 | tinfoil.prepare(config_only=False) |
1027 | 1073 | ||
@@ -1043,28 +1089,17 @@ def get_recipe_upgrade_status(recipes=None): | |||
1043 | bb.note(" Skip package %s as upstream check unreliable" % pn) | 1089 | bb.note(" Skip package %s as upstream check unreliable" % pn) |
1044 | continue | 1090 | continue |
1045 | 1091 | ||
1046 | uv = get_recipe_upstream_version(data) | 1092 | data_copy = bb.data.init() |
1047 | 1093 | for var in copy_vars: | |
1048 | pn = data.getVar('PN') | 1094 | data_copy.setVar(var, data.getVar(var)) |
1049 | cur_ver = uv['current_version'] | 1095 | for k in data: |
1050 | 1096 | if k.startswith('SRCREV'): | |
1051 | upstream_version_unknown = data.getVar('UPSTREAM_VERSION_UNKNOWN') | 1097 | data_copy.setVar(k, data.getVar(k)) |
1052 | if not uv['version']: | ||
1053 | status = "UNKNOWN" if upstream_version_unknown else "UNKNOWN_BROKEN" | ||
1054 | else: | ||
1055 | cmp = vercmp_string(uv['current_version'], uv['version']) | ||
1056 | if cmp == -1: | ||
1057 | status = "UPDATE" if not upstream_version_unknown else "KNOWN_BROKEN" | ||
1058 | elif cmp == 0: | ||
1059 | status = "MATCH" if not upstream_version_unknown else "KNOWN_BROKEN" | ||
1060 | else: | ||
1061 | status = "UNKNOWN" if upstream_version_unknown else "UNKNOWN_BROKEN" | ||
1062 | 1098 | ||
1063 | next_ver = uv['version'] if uv['version'] else "N/A" | 1099 | data_copy_list.append(data_copy) |
1064 | revision = uv['revision'] if uv['revision'] else "N/A" | ||
1065 | maintainer = data.getVar('RECIPE_MAINTAINER') | ||
1066 | no_upgrade_reason = data.getVar('RECIPE_NO_UPDATE_REASON') | ||
1067 | 1100 | ||
1068 | pkgs_list.append((pn, status, cur_ver, next_ver, maintainer, revision, no_upgrade_reason)) | 1101 | from concurrent.futures import ProcessPoolExecutor |
1102 | with ProcessPoolExecutor(max_workers=utils.cpu_count()) as executor: | ||
1103 | pkgs_list = executor.map(_get_recipe_upgrade_status, data_copy_list) | ||
1069 | 1104 | ||
1070 | return pkgs_list | 1105 | return pkgs_list |