diff options
author | James Ennis <james.ennis@codethink.co.uk> | 2019-07-03 10:27:17 +0100 |
---|---|---|
committer | bst-marge-bot <marge-bot@buildstream.build> | 2019-07-16 09:13:39 +0000 |
commit | 6e2bd6a8020e2f4f4687cf573c5536661feb0f70 (patch) | |
tree | b6a7e023d2c92b67195db82b6d90d169e0325fbd | |
parent | 69d7d1a86931946dda2d2437035de32159532790 (diff) | |
download | buildstream-6e2bd6a8020e2f4f4687cf573c5536661feb0f70.tar.gz |
element.py: Remove update_state_recursively()
Now that __update_ready_for_runtime() and
__update_strict_cache_key_of_rdeps() have been introduced,
we no longer need to recursively update the state of elements
-rw-r--r-- | src/buildstream/element.py | 32 | ||||
-rw-r--r-- | src/buildstream/types.py | 50 |
2 files changed, 4 insertions, 78 deletions
diff --git a/src/buildstream/element.py b/src/buildstream/element.py index 453e6b3fa..41601f2bf 100644 --- a/src/buildstream/element.py +++ b/src/buildstream/element.py @@ -102,7 +102,7 @@ from .plugin import Plugin from .sandbox import SandboxFlags, SandboxCommandError from .sandbox._config import SandboxConfig from .sandbox._sandboxremote import SandboxRemote -from .types import Consistency, CoreWarnings, Scope, _KeyStrength, _UniquePriorityQueue +from .types import Consistency, CoreWarnings, Scope, _KeyStrength from ._artifact import Artifact from .storage.directory import Directory @@ -1199,10 +1199,6 @@ class Element(Plugin): if not context.get_strict(): self.__update_cache_key_non_strict() - if not self.__ready_for_runtime and self.__cache_key is not None and not self.__cache_keys_unstable: - self.__ready_for_runtime = all( - dep.__ready_for_runtime for dep in self.__runtime_dependencies) - # _get_display_key(): # # Returns cache keys for display purposes @@ -1266,7 +1262,7 @@ class Element(Plugin): self.__tracking_scheduled = False - self.__update_state_recursively() + self._update_state() # _track(): # @@ -1521,7 +1517,7 @@ class Element(Plugin): if self.__artifact: self.__artifact.reset_cached() - self.__update_state_recursively() + self._update_state() self._update_ready_for_runtime_and_cached() if self._get_workspace() and self._cached_success(): @@ -1783,7 +1779,7 @@ class Element(Plugin): if self.__cache_keys_unstable and self._cached_success(): self.__cache_keys_unstable = False - self.__update_state_recursively() + self._update_state() self._update_ready_for_runtime_and_cached() # _pull(): @@ -2960,26 +2956,6 @@ class Element(Plugin): self.__last_source_requires_previous_ix = last_requires_previous return self.__last_source_requires_previous_ix - # __update_state_recursively() - # - # Update the state of all reverse dependencies, recursively. - # - def __update_state_recursively(self): - queue = _UniquePriorityQueue() - queue.push(self._unique_id, self) - - while queue: - element = queue.pop() - - old_ready_for_runtime = element.__ready_for_runtime - old_strict_cache_key = element.__strict_cache_key - element._update_state() - - if element.__ready_for_runtime != old_ready_for_runtime or \ - element.__strict_cache_key != old_strict_cache_key: - for rdep in element.__reverse_build_deps | element.__reverse_runtime_deps: - queue.push(rdep._unique_id, rdep) - # __reset_cache_data() # # Resets all data related to cache key calculation and whether an artifact diff --git a/src/buildstream/types.py b/src/buildstream/types.py index d54bf0b6e..6f6262e41 100644 --- a/src/buildstream/types.py +++ b/src/buildstream/types.py @@ -26,7 +26,6 @@ Foundation types """ from enum import Enum -import heapq class Scope(Enum): @@ -126,52 +125,3 @@ class _KeyStrength(Enum): # Includes names of direct build dependencies but does not include # cache keys of dependencies. WEAK = 2 - - -# _UniquePriorityQueue(): -# -# Implements a priority queue that adds only each key once. -# -# The queue will store and priority based on a tuple (key, item). -# -class _UniquePriorityQueue: - - def __init__(self): - self._items = set() - self._heap = [] - - # push(): - # - # Push a new item in the queue. - # - # If the item is already present in the queue as identified by the key, - # this is a noop. - # - # Args: - # key (hashable, comparable): unique key to use for checking for - # the object's existence and used for - # ordering - # item (any): item to push to the queue - # - def push(self, key, item): - if key not in self._items: - self._items.add(key) - heapq.heappush(self._heap, (key, item)) - - # pop(): - # - # Pop the next item from the queue, by priority order. - # - # Returns: - # (any): the next item - # - # Throw: - # IndexError: when the list is empty - # - def pop(self): - key, item = heapq.heappop(self._heap) - self._items.remove(key) - return item - - def __len__(self): - return len(self._heap) |