summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAngelos Evripiotis <jevripiotis@bloomberg.net>2019-03-13 16:28:22 +0000
committerAngelos Evripiotis <jevripiotis@bloomberg.net>2019-03-21 10:21:02 +0000
commitcf6eebcc5cd45cdca5f3255d62ee5f0ef6ad305a (patch)
tree17bd3593b67a5503dee2c8fe9266e3ce2b81399d
parent9809ebf5df8fd531aac297e965fcb30275d6faf6 (diff)
downloadbuildstream-aevri/you_only_write_once.tar.gz
cleanupjob, cascache: don't write cache size twiceaevri/you_only_write_once
In CleanupJob, don't write the same size update to the cache size file twice. The update received in the 'update-cache-size' message has already been written during ArtifactCache.clean(). This means that we now only do one (write temp file + move into place) for every artifact that we remove, and from one process at a time. In later work we might reconsider the number of temp files we create.
-rw-r--r--buildstream/_cas/cascache.py6
-rw-r--r--buildstream/_scheduler/jobs/cleanupjob.py4
2 files changed, 6 insertions, 4 deletions
diff --git a/buildstream/_cas/cascache.py b/buildstream/_cas/cascache.py
index 1755a9e61..7ea8c3259 100644
--- a/buildstream/_cas/cascache.py
+++ b/buildstream/_cas/cascache.py
@@ -1104,13 +1104,15 @@ class CASQuota:
#
# Args:
# cache_size (int): The size to set.
+ # write_to_disk (bool): Whether to write the value to disk.
#
- def set_cache_size(self, cache_size):
+ def set_cache_size(self, cache_size, *, write_to_disk=True):
assert cache_size is not None
self._cache_size = cache_size
- self._write_cache_size(self._cache_size)
+ if write_to_disk:
+ self._write_cache_size(self._cache_size)
# full()
#
diff --git a/buildstream/_scheduler/jobs/cleanupjob.py b/buildstream/_scheduler/jobs/cleanupjob.py
index 9610d53f8..3ea1daa04 100644
--- a/buildstream/_scheduler/jobs/cleanupjob.py
+++ b/buildstream/_scheduler/jobs/cleanupjob.py
@@ -38,14 +38,14 @@ class CleanupJob(Job):
# Update the cache size in the main process as we go,
# this provides better feedback in the UI.
if message_type == 'update-cache-size':
- self._casquota.set_cache_size(message)
+ self._casquota.set_cache_size(message, write_to_disk=False)
return True
return False
def parent_complete(self, status, result):
if status == JobStatus.OK:
- self._casquota.set_cache_size(result)
+ self._casquota.set_cache_size(result, write_to_disk=False)
if self._complete_cb:
self._complete_cb(status, result)