summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJames Ennis <james.ennis@codethink.co.uk>2019-07-12 14:12:27 +0100
committerbst-marge-bot <marge-bot@buildstream.build>2019-07-16 09:13:39 +0000
commita163b64a5da7a58092eb4f04020e5fc520d5f75b (patch)
treed7b6dbaea2e7c2502fc783780335bf3fca6ce5df
parent452fdce3d0f80e1fec671237c97d7e43b0773d5f (diff)
downloadbuildstream-a163b64a5da7a58092eb4f04020e5fc520d5f75b.tar.gz
element.py: Introduce __cached_successfully
Currently Element._cached_success() will call two functions to determine whether an Element is already cached. Now, we set __cached_successfully to True once we determine that the Element is cached for the first time. This will then short-circuit upon (very frequent) future calls.
-rw-r--r--src/buildstream/element.py14
1 files changed, 13 insertions, 1 deletions
diff --git a/src/buildstream/element.py b/src/buildstream/element.py
index a08ec571c..5856f3241 100644
--- a/src/buildstream/element.py
+++ b/src/buildstream/element.py
@@ -229,6 +229,7 @@ class Element(Plugin):
self.__assemble_done = False # Element is assembled
self.__tracking_scheduled = False # Sources are scheduled to be tracked
self.__pull_done = False # Whether pull was attempted
+ self.__cached_successfully = None # If the Element is known to be successfully cached
self.__splits = None # Resolved regex objects for computing split domains
self.__whitelist_regex = None # Resolved regex object to check if file is allowed to overlap
self.__staged_sources_directory = None # Location where Element.stage_sources() was called
@@ -1073,11 +1074,22 @@ class Element(Plugin):
# the artifact cache and the element assembled successfully
#
def _cached_success(self):
+ # FIXME: _cache() and _cached_success() should be converted to
+ # push based functions where we only update __cached_successfully
+ # once we know this has changed. This will allow us to cheaply check
+ # __cached_successfully instead of calling _cached_success()
+ if self.__cached_successfully:
+ return True
+
if not self._cached():
return False
success, _, _ = self._get_build_result()
- return success
+ if success:
+ self.__cached_successfully = True
+ return True
+ else:
+ return False
# _cached_failure():
#