diff options
author | James Ennis <james.ennis@codethink.co.uk> | 2019-07-12 14:12:27 +0100 |
---|---|---|
committer | James Ennis <james.ennis@codethink.co.uk> | 2019-07-12 16:03:06 +0100 |
commit | ca0942fb068f2c0315a902a922d27779c73fec57 (patch) | |
tree | f7456cb951120a4cc16de9eec46407b40ef88f86 | |
parent | 444da8d0230a2471d9cd684ab83902d9b859e845 (diff) | |
download | buildstream-jennis/update_ready_for_runtime.tar.gz |
element.py: Introduce __cached_successfullyjennis/update_ready_for_runtime
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.py | 14 |
1 files changed, 13 insertions, 1 deletions
diff --git a/src/buildstream/element.py b/src/buildstream/element.py index 51a143113..f9014a839 100644 --- a/src/buildstream/element.py +++ b/src/buildstream/element.py @@ -228,6 +228,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 @@ -1118,11 +1119,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(): # |