summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJürg Billeter <j@bitron.ch>2019-02-12 07:08:18 +0000
committerJürg Billeter <j@bitron.ch>2019-02-12 07:08:18 +0000
commit86a9048a587f67fbb562f1188f9d04db0c220f75 (patch)
treed5d4de215fd0cbec5bb0997ca185160d77443eb1
parent0816b8b19297cbefd4273d9694d0463fcad0a848 (diff)
parent8b9e1d24a6210bc0945f8c39f1dd8be42b9ca53b (diff)
downloadbuildstream-86a9048a587f67fbb562f1188f9d04db0c220f75.tar.gz
Merge branch 'juerg/buffer-size' into 'master'
Increase read buffer size to improve performance See merge request BuildStream/buildstream!1142
-rw-r--r--buildstream/_cas/cascache.py6
-rw-r--r--buildstream/utils.py2
2 files changed, 5 insertions, 3 deletions
diff --git a/buildstream/_cas/cascache.py b/buildstream/_cas/cascache.py
index 5a6251815..9d7a121f4 100644
--- a/buildstream/_cas/cascache.py
+++ b/buildstream/_cas/cascache.py
@@ -35,6 +35,8 @@ from .._exceptions import CASCacheError
from .casremote import BlobNotFound, _CASBatchRead, _CASBatchUpdate
+_BUFFER_SIZE = 65536
+
# A CASCache manages a CAS repository as specified in the Remote Execution API.
#
@@ -371,7 +373,7 @@ class CASCache():
with contextlib.ExitStack() as stack:
if path is not None and link_directly:
tmp = stack.enter_context(open(path, 'rb'))
- for chunk in iter(lambda: tmp.read(4096), b""):
+ for chunk in iter(lambda: tmp.read(_BUFFER_SIZE), b""):
h.update(chunk)
else:
tmp = stack.enter_context(utils._tempnamedfile(dir=self.tmpdir))
@@ -380,7 +382,7 @@ class CASCache():
if path:
with open(path, 'rb') as f:
- for chunk in iter(lambda: f.read(4096), b""):
+ for chunk in iter(lambda: f.read(_BUFFER_SIZE), b""):
h.update(chunk)
tmp.write(chunk)
else:
diff --git a/buildstream/utils.py b/buildstream/utils.py
index 76f95637e..b739ca658 100644
--- a/buildstream/utils.py
+++ b/buildstream/utils.py
@@ -235,7 +235,7 @@ def sha256sum(filename):
try:
h = hashlib.sha256()
with open(filename, "rb") as f:
- for chunk in iter(lambda: f.read(4096), b""):
+ for chunk in iter(lambda: f.read(65536), b""):
h.update(chunk)
except OSError as e: