summaryrefslogtreecommitdiff
path: root/buildstream/_scheduler
diff options
context:
space:
mode:
authorTristan Van Berkom <tristan.vanberkom@codethink.co.uk>2018-09-10 16:14:51 +0900
committerTristan Van Berkom <tristan.vanberkom@codethink.co.uk>2018-09-10 16:53:56 +0900
commitcbfddc13ebe6a9be3cfe4bf62e9b996c45c5dcdc (patch)
treec76512420852f677463dbe1aa07371aa62226fa5 /buildstream/_scheduler
parent791f7ddad656ce67022225a43c28927e3887b3a9 (diff)
downloadbuildstream-cbfddc13ebe6a9be3cfe4bf62e9b996c45c5dcdc.tar.gz
element.py: Remove _get_artifact_size()
There is no justification to hold onto this state here. Instead, just make `Element._assemble()` return the size of the artifact it cached, and localize handling of that return value in the BuildQueue implementation where the value is observed.
Diffstat (limited to 'buildstream/_scheduler')
-rw-r--r--buildstream/_scheduler/jobs/elementjob.py3
-rw-r--r--buildstream/_scheduler/queues/buildqueue.py31
2 files changed, 16 insertions, 18 deletions
diff --git a/buildstream/_scheduler/jobs/elementjob.py b/buildstream/_scheduler/jobs/elementjob.py
index 36527794e..b3318302a 100644
--- a/buildstream/_scheduler/jobs/elementjob.py
+++ b/buildstream/_scheduler/jobs/elementjob.py
@@ -109,14 +109,11 @@ class ElementJob(Job):
data = {}
workspace = self._element._get_workspace()
- artifact_size = self._element._get_artifact_size()
artifacts = self._element._get_artifact_cache()
cache_size = artifacts.compute_cache_size()
if workspace is not None:
data['workspace'] = workspace.to_dict()
- if artifact_size is not None:
- data['artifact_size'] = artifact_size
data['cache_size'] = cache_size
return data
diff --git a/buildstream/_scheduler/queues/buildqueue.py b/buildstream/_scheduler/queues/buildqueue.py
index 6eb919082..8f593fea7 100644
--- a/buildstream/_scheduler/queues/buildqueue.py
+++ b/buildstream/_scheduler/queues/buildqueue.py
@@ -67,8 +67,7 @@ class BuildQueue(Queue):
return super().enqueue(to_queue)
def process(self, element):
- element._assemble()
- return element._get_unique_id()
+ return element._assemble()
def status(self, element):
# state of dependencies may have changed, recalculate element state
@@ -87,18 +86,20 @@ class BuildQueue(Queue):
return QueueStatus.READY
- def _check_cache_size(self, job, element):
- if not job.child_data:
- return
+ def _check_cache_size(self, job, element, artifact_size):
- artifact_size = job.child_data.get('artifact_size', False)
+ # After completing a build job, add the artifact size
+ # as returned from Element._assemble() to the estimated
+ # artifact cache size
+ #
+ cache = element._get_artifact_cache()
+ cache.add_artifact_size(artifact_size)
- if artifact_size:
- cache = element._get_artifact_cache()
- cache.add_artifact_size(artifact_size)
-
- if cache.get_approximate_cache_size() > cache.cache_quota:
- self._scheduler.check_cache_size()
+ # If the estimated size outgrows the quota, ask the scheduler
+ # to queue a job to actually check the real cache size.
+ #
+ if cache.get_approximate_cache_size() > cache.cache_quota:
+ self._scheduler.check_cache_size()
def done(self, job, element, result, success):
@@ -106,8 +107,8 @@ class BuildQueue(Queue):
# Inform element in main process that assembly is done
element._assemble_done()
- # This has to be done after _assemble_done, such that the
- # element may register its cache key as required
- self._check_cache_size(job, element)
+ # This has to be done after _assemble_done, such that the
+ # element may register its cache key as required
+ self._check_cache_size(job, element, result)
return True