diff options
author | Joshua Watt <JPEWhacker@gmail.com> | 2024-02-18 15:59:52 -0700 |
---|---|---|
committer | Richard Purdie <richard.purdie@linuxfoundation.org> | 2024-02-19 11:53:15 +0000 |
commit | 7e2479109b40ce82507f73b4f935903f7f79fb06 (patch) | |
tree | 76ff0b47be9929b99f0ea3d733447ce49dc7a167 | |
parent | 6faf48c09a4003a31b32e450779fb8ac9cc5e946 (diff) | |
download | bitbake-7e2479109b40ce82507f73b4f935903f7f79fb06.tar.gz |
siggen: Add parallel unihash exist API
Adds API to query if unihashes are known to the server in parallel
Signed-off-by: Joshua Watt <JPEWhacker@gmail.com>
Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
-rw-r--r-- | lib/bb/siggen.py | 32 |
1 files changed, 32 insertions, 0 deletions
diff --git a/lib/bb/siggen.py b/lib/bb/siggen.py index e1a4fa2cd..3ab8431a0 100644 --- a/lib/bb/siggen.py +++ b/lib/bb/siggen.py @@ -530,6 +530,11 @@ class SignatureGeneratorBasicHash(SignatureGeneratorBasic): class SignatureGeneratorUniHashMixIn(object): def __init__(self, data): self.extramethod = {} + # NOTE: The cache only tracks hashes that exist. Hashes that don't + # exist are always queries from the server since it is possible for + # hashes to appear over time, but much less likely for them to + # disappear + self.unihash_exists_cache = set() super().__init__(data) def get_taskdata(self): @@ -620,6 +625,33 @@ class SignatureGeneratorUniHashMixIn(object): return method + def unihashes_exist(self, query): + if len(query) == 0: + return {} + + uncached_query = {} + result = {} + for key, unihash in query.items(): + if unihash in self.unihash_exists_cache: + result[key] = True + else: + uncached_query[key] = unihash + + if self.max_parallel <= 1 or len(uncached_query) <= 1: + # No parallelism required. Make the query serially with the single client + uncached_result = { + key: self.client().unihash_exists(value) for key, value in uncached_query.items() + } + else: + uncached_result = self.client_pool().unihashes_exist(uncached_query) + + for key, exists in uncached_result.items(): + if exists: + self.unihash_exists_cache.add(query[key]) + result[key] = exists + + return result + def get_unihash(self, tid): return self.get_unihashes([tid])[tid] |