siggen: Drop client pool support
PATCH 1/3 siggen: Drop client pool support
Drops support for client pools, since batching support in the client code has proven to be much more effective
Signed-off-by Joshua Watt <[email protected]>
--- bitbake/lib/bb/siggen.py | 53 ++++++++++++---------------------------- 1 file changed, 15 insertions(+), 38 deletions(-)
bitbake/lib/bb/siggen.py +15 -38
@@ -540,7 +540,7 @@ 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 + # exist are always queried 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()
@@ -558,11 +558,11 @@ class SignatureGeneratorUniHashMixIn(object): super().__init__(data) def get_taskdata(self): - return (self.server, self.method, self.extramethod, self.max_parallel, self.username, self.password, self.env) + super().get_taskdata() + return (self.server, self.method, self.extramethod, self.username, self.password, self.env) + super().get_taskdata() def set_taskdata(self, data): - self.server, self.method, self.extramethod, self.max_parallel, self.username, self.password, self.env = data[:7] - super().set_taskdata(data[7:]) + self.server, self.method, self.extramethod, self.username, self.password, self.env = data[:6] + super().set_taskdata(data[6:]) def get_hashserv_creds(self): if self.username and self.password:
@@ -595,13 +595,6 @@ class SignatureGeneratorUniHashMixIn(object): self._client = hashserv.create_client(self.server, **self.get_hashserv_creds()) yield self._client - @contextmanager - def client_pool(self): - with self._client_env(): - if getattr(self, '_client_pool', None) is None: - self._client_pool = hashserv.client.ClientPool(self.server, self.max_parallel, **self.get_hashserv_creds()) - yield self._client_pool - def reset(self, data): self.__close_clients() return super().reset(data)
@@ -686,15 +679,10 @@ class SignatureGeneratorUniHashMixIn(object): 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 - with self.client() as client: - uncached_result = { - key: client.unihash_exists(value) for key, value in uncached_query.items() - } - else: - with self.client_pool() as client_pool: - uncached_result = client_pool.unihashes_exist(uncached_query) + with self.client() as client: + uncached_result = { + key: client.unihash_exists(value) for key, value in uncached_query.items() + } for key, exists in uncached_result.items(): if exists:
@@ -712,32 +700,20 @@ class SignatureGeneratorUniHashMixIn(object): unihash """ result = {} - queries = {} - query_result = {} + query_tids = [] for tid in tids: unihash = self.get_cached_unihash(tid) if unihash: result[tid] = unihash else: - queries[tid] = (self._get_method(tid), self.taskhash[tid]) - - if len(queries) == 0: - return result + query_tids.append(tid) - if self.max_parallel <= 1 or len(queries) <= 1: - # No parallelism required. Make the query using a single client + if query_tids: with self.client() as client: - keys = list(queries.keys()) - unihashes = client.get_unihash_batch(queries[k] for k in keys) + unihashes = client.get_unihash_batch((self._get_method(tid), self.taskhash[tid]) for tid in query_tids) - for idx, k in enumerate(keys): - query_result[k] = unihashes[idx] - else: - with self.client_pool() as client_pool: - query_result = client_pool.get_unihashes(queries) - - for tid, unihash in query_result.items(): + for idx, tid in enumerate(query_tids): # In the absence of being able to discover a unique hash from the # server, make it be equivalent to the taskhash. The unique "hash" only # really needs to be a unique string (not even necessarily a hash), but
@@ -752,6 +728,8 @@ class SignatureGeneratorUniHashMixIn(object): # to the server, there is a better chance that they will agree on # the unique hash. taskhash = self.taskhash[tid] + unihash = unihashes[idx] + if unihash: # A unique hash equal to the taskhash is not very interesting, # so it is reported it at debug level 2. If they differ, that
@@ -898,7 +876,6 @@ class SignatureGeneratorTestEquivHash(SignatureGeneratorUniHashMixIn, SignatureG super().init_rundepcheck(data) self.server = data.getVar('BB_HASHSERVE') self.method = "sstate_output_hash" - self.max_parallel = 1 def clean_checksum_file_path(file_checksum_tuple): f, cs = file_checksum_tuple
Signature · 1 line
2.43.2
PATCH 2/3 asyncrpc: Remove ClientPool
Batching support on the client side has proven to be a much more effective way of dealing with server latency than multiple client connections and is also much nicer on the server, so drop the client pool support from asyncrpc and the hash server
Signed-off-by Joshua Watt <[email protected]>
--- bitbake/lib/bb/asyncrpc/__init__.py | 2 +- bitbake/lib/bb/asyncrpc/client.py | 76 +------------------------- bitbake/lib/hashserv/client.py | 80 ---------------------------- bitbake/lib/hashserv/tests.py | 82 ----------------------------- 4 files changed, 2 insertions(+), 238 deletions(-)
bitbake/lib/bb/asyncrpc/__init__.py +1 -1
@@ -5,7 +5,7 @@ # -from .client import AsyncClient, Client, ClientPool +from .client import AsyncClient, Client from .serv import AsyncServer, AsyncServerConnection from .connection import DEFAULT_MAX_CHUNK from .exceptions import (
bitbake/lib/bb/asyncrpc/client.py +1 -75
85 lines not on this page · raw message
bitbake/lib/hashserv/client.py +0 -80
83 lines not on this page · raw message
bitbake/lib/hashserv/tests.py +0 -82
100 lines not on this page · raw message
Signature · 1 line
2.43.2
PATCH 3/3 siggen: Batch unihash_exists checks
In reply to Joshua WattSimilar to looking up unihashes, use the batch API when checking if a unihash exists to speed up lookups
Signed-off-by Joshua Watt <[email protected]>
--- bitbake/lib/bb/siggen.py | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-)
bitbake/lib/bb/siggen.py +7 -7
@@ -671,20 +671,20 @@ class SignatureGeneratorUniHashMixIn(object): if len(query) == 0: return {} - uncached_query = {} + query_keys = [] result = {} for key, unihash in query.items(): if unihash in self.unihash_exists_cache: result[key] = True else: - uncached_query[key] = unihash + query_keys.append(key) - with self.client() as client: - uncached_result = { - key: client.unihash_exists(value) for key, value in uncached_query.items() - } + if query_keys: + with self.client() as client: + query_result = client.unihash_exists_batch(query[k] for k in query_keys) - for key, exists in uncached_result.items(): + for idx, key in enumerate(query_keys): + exists = query_result[idx] if exists: self.unihash_exists_cache.add(query[key]) result[key] = exists
Signature · 1 line
2.43.2