This is an automated email from the ASF dual-hosted git repository. juergbi pushed a commit to branch juerg/uploadtree in repository https://gitbox.apache.org/repos/asf/buildstream.git
commit 7ada4fe5860d734cfdb6390ed3522f049b21a15f Author: Jürg Billeter <[email protected]> AuthorDate: Fri Oct 18 17:37:03 2024 +0200 cascache.py: Use `UploadTree` with `storage-service`, if available Cache query is currently relatively slow when `storage-service` is enabled as the tree traversals are handled by Python code. Calling `UploadTree` moves that logic to buildbox-casd, which is much faster, especially if many CPU cores/threads are available. --- src/buildstream/_cas/cascache.py | 17 ++++++++++++++--- 1 file changed, 14 insertions(+), 3 deletions(-) diff --git a/src/buildstream/_cas/cascache.py b/src/buildstream/_cas/cascache.py index 747bd2150..6ffb7313d 100644 --- a/src/buildstream/_cas/cascache.py +++ b/src/buildstream/_cas/cascache.py @@ -153,9 +153,20 @@ class CASCache: raise CASCacheError("Unsupported buildbox-casd version: FetchTree unimplemented") from e raise - # Check whether everything is available in the remote cache. - missing_blobs = self.missing_blobs_for_directory(digest, remote=self._default_remote) - return not missing_blobs + # Make sure everything is available in the remote cache (storage-service) + request = local_cas_pb2.UploadTreeRequest() + request.root_digest.CopyFrom(digest) + try: + local_cas.UploadTree(request) + return True + except grpc.RpcError as e: + if e.code() == grpc.StatusCode.NOT_FOUND: + return False + if e.code() == grpc.StatusCode.UNIMPLEMENTED: + # Fallback path if buildbox-casd is too old to support UploadTree + missing_blobs = self.missing_blobs_for_directory(digest, remote=self._default_remote) + return not missing_blobs + raise # checkout(): #
