diff options
author | Benjamin Schubert <ben.c.schubert@gmail.com> | 2019-01-04 23:01:27 +0000 |
---|---|---|
committer | Benjamin Schubert <ben.c.schubert@gmail.com> | 2019-01-15 11:37:14 +0000 |
commit | 2d82468af9f7c486c5f53e4ec71b3a21f386e72c (patch) | |
tree | 9d5c9878290bc8e69d8d2258826a2c6c48874c3e | |
parent | 006370af1cf5eb1e9dc4a088077ffc498b20e66c (diff) | |
download | buildstream-2d82468af9f7c486c5f53e4ec71b3a21f386e72c.tar.gz |
buildqueue: only update state of direct reverse dependencies
Previously, we would update the state of all elements in the pipeline,
everytime an element in the queue would change state.
This is inefficient. We know that the only impacted elements will
be the direct build reverse dependencies. We can therefore, by recording
the direct build reverse dependencies, only update those and reduce
the time we spend updating states.
-rw-r--r-- | buildstream/_scheduler/queues/buildqueue.py | 7 | ||||
-rw-r--r-- | buildstream/element.py | 2 |
2 files changed, 6 insertions, 3 deletions
diff --git a/buildstream/_scheduler/queues/buildqueue.py b/buildstream/_scheduler/queues/buildqueue.py index 9d8e7182b..7b3a8e51f 100644 --- a/buildstream/_scheduler/queues/buildqueue.py +++ b/buildstream/_scheduler/queues/buildqueue.py @@ -71,9 +71,6 @@ class BuildQueue(Queue): return element._assemble() def status(self, element): - # state of dependencies may have changed, recalculate element state - element._update_state() - if not element._is_required(): # Artifact is not currently required but it may be requested later. # Keep it in the queue. @@ -109,6 +106,10 @@ class BuildQueue(Queue): # Inform element in main process that assembly is done element._assemble_done() + # Update the state of all reverse dependencies + for reverse_dependency in element.reverse_build_dependencies: + reverse_dependency._update_state() + # This has to be done after _assemble_done, such that the # element may register its cache key as required # diff --git a/buildstream/element.py b/buildstream/element.py index c5fbf772c..a1a9abac1 100644 --- a/buildstream/element.py +++ b/buildstream/element.py @@ -197,6 +197,7 @@ class Element(Plugin): self.__runtime_dependencies = [] # Direct runtime dependency Elements self.__build_dependencies = [] # Direct build dependency Elements + self.reverse_build_dependencies = [] # Direct reverse build dependency Elements self.__sources = [] # List of Sources self.__weak_cache_key = None # Our cached weak cache key self.__strict_cache_key = None # Our cached cache key for strict builds @@ -930,6 +931,7 @@ class Element(Plugin): for meta_dep in meta.build_dependencies: dependency = Element._new_from_meta(meta_dep) element.__build_dependencies.append(dependency) + dependency.reverse_build_dependencies.append(element) return element |