summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJürg Billeter <j@bitron.ch>2018-09-24 10:03:36 +0100
committerJürg Billeter <j@bitron.ch>2018-09-25 09:01:51 +0000
commit7d199322b79f9282eda9c0a16a61c8e9c18eb7a0 (patch)
treeb73b3025a78e47aea4b67fc6e5c7c37b54684b1c
parentb199afe6f11c6b0049934c2846f489cbb5622fa2 (diff)
downloadbuildstream-7d199322b79f9282eda9c0a16a61c8e9c18eb7a0.tar.gz
_artifactcache/cascache.py: Increase payload size limit for uploads
gRPC can handle 1 MiB payloads. Increase size limit from 64 KiB to speed up uploads.`
-rw-r--r--buildstream/_artifactcache/cascache.py9
1 files changed, 7 insertions, 2 deletions
diff --git a/buildstream/_artifactcache/cascache.py b/buildstream/_artifactcache/cascache.py
index d28af2d0d..1b1d63775 100644
--- a/buildstream/_artifactcache/cascache.py
+++ b/buildstream/_artifactcache/cascache.py
@@ -44,6 +44,11 @@ from .._exceptions import ArtifactError
from . import ArtifactCache
+# The default limit for gRPC messages is 4 MiB.
+# Limit payload to 1 MiB to leave sufficient headroom for metadata.
+_MAX_PAYLOAD_BYTES = 1024 * 1024
+
+
# A CASCache manages artifacts in a CAS repository as specified in the
# Remote Execution API.
#
@@ -942,12 +947,12 @@ class CASCache(ArtifactCache):
finished = False
remaining = digest.size_bytes
while not finished:
- chunk_size = min(remaining, 64 * 1024)
+ chunk_size = min(remaining, _MAX_PAYLOAD_BYTES)
remaining -= chunk_size
request = bytestream_pb2.WriteRequest()
request.write_offset = offset
- # max. 64 kB chunks
+ # max. _MAX_PAYLOAD_BYTES chunks
request.data = instream.read(chunk_size)
request.resource_name = resname
request.finish_write = remaining <= 0