diff options
author | Jürg Billeter <j@bitron.ch> | 2019-11-19 21:06:36 +0100 |
---|---|---|
committer | Jürg Billeter <j@bitron.ch> | 2019-11-20 16:42:10 +0100 |
commit | da165c5bd7d3965b10e07495fb0f4af419706792 (patch) | |
tree | 2efba8f00c6658eb2b209af00515eebd64e66bb5 | |
parent | 7ed8f86401e1344c470058383852f0c9e7b70d16 (diff) | |
download | buildstream-da165c5bd7d3965b10e07495fb0f4af419706792.tar.gz |
WIP: element.py: Optimize fetch_done() and assemble_done()
-rw-r--r-- | src/buildstream/_scheduler/queues/buildqueue.py | 3 | ||||
-rw-r--r-- | src/buildstream/_scheduler/queues/fetchqueue.py | 2 | ||||
-rw-r--r-- | src/buildstream/element.py | 32 |
3 files changed, 22 insertions, 15 deletions
diff --git a/src/buildstream/_scheduler/queues/buildqueue.py b/src/buildstream/_scheduler/queues/buildqueue.py index d98b49476..5cbd5af57 100644 --- a/src/buildstream/_scheduler/queues/buildqueue.py +++ b/src/buildstream/_scheduler/queues/buildqueue.py @@ -23,6 +23,7 @@ from datetime import timedelta from . import Queue, QueueStatus from ..resources import ResourceType from ..._message import MessageType +from ..jobs import JobStatus # A queue which assembles elements @@ -80,7 +81,7 @@ class BuildQueue(Queue): def done(self, job, element, result, status): # Inform element in main process that assembly is done - element._assemble_done() + element._assemble_done(status is JobStatus.OK) def register_pending_element(self, element): # Set a "buildable" callback for an element not yet ready diff --git a/src/buildstream/_scheduler/queues/fetchqueue.py b/src/buildstream/_scheduler/queues/fetchqueue.py index 4f38f377a..bc2960fbb 100644 --- a/src/buildstream/_scheduler/queues/fetchqueue.py +++ b/src/buildstream/_scheduler/queues/fetchqueue.py @@ -69,7 +69,7 @@ class FetchQueue(Queue): if status is JobStatus.FAIL: return - element._fetch_done() + element._fetch_done(status is JobStatus.OK, fetch_original=self._should_fetch_original) # Successful fetch, we must be CACHED or in the sourcecache if self._should_fetch_original: diff --git a/src/buildstream/element.py b/src/buildstream/element.py index de15ef06e..8865deca2 100644 --- a/src/buildstream/element.py +++ b/src/buildstream/element.py @@ -1635,17 +1635,20 @@ class Element(Plugin): # # This will result in updating the element state. # - def _assemble_done(self): + def _assemble_done(self, successful): assert self.__assemble_scheduled self.__assemble_scheduled = False self.__assemble_done = True - # Artifact may have a cached success now. - if self.__strict_artifact: - self.__strict_artifact.reset_cached() - if self.__artifact: - self.__artifact.reset_cached() + if successful: + self.__artifact._cached = True + self.__cached_successfully = True + else: + if self.__strict_artifact: + self.__strict_artifact.reset_cached() + if self.__artifact: + self.__artifact.reset_cached() # When we're building in non-strict mode, we may have # assembled everything to this point without a strong cache @@ -1804,7 +1807,7 @@ class Element(Plugin): pass # ensure we have cache keys - self._assemble_done() + self.__update_cache_key_non_strict() with self.timed_activity("Caching artifact"): artifact_size = self.__artifact.cache(rootdir, sandbox_build_dir, collectvdir, buildresult, publicdata) @@ -1824,15 +1827,18 @@ class Element(Plugin): # # Indicates that fetching the sources for this element has been done. # - def _fetch_done(self): + def _fetch_done(self, successful, *, fetch_original): # We are not updating the state recursively here since fetching can # never end up in updating them. - # Fetching changes the source state from RESOLVED to CACHED - # Fetching cannot change the source state from INCONSISTENT to CACHED because - # we prevent fetching when it's INCONSISTENT. - # Therefore, only the source state will change. - self.__update_source_state() + if successful and not fetch_original: + self.__source_cached = True + else: + # Fetching changes the source state from RESOLVED to CACHED + # Fetching cannot change the source state from INCONSISTENT to CACHED because + # we prevent fetching when it's INCONSISTENT. + # Therefore, only the source state will change. + self.__update_source_state() # _pull_pending() # |