summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTristan Maat <tristan.maat@codethink.co.uk>2019-10-18 14:24:17 +0100
committerTristan Maat <tristan.maat@codethink.co.uk>2019-11-04 11:26:48 +0000
commit596f6b579788af92bae28e93c919e33f9b7fa3bd (patch)
treec651b37a63ec9bde1ebc6025b03db3b60ebd5522
parent135f278c9f461e49817c5e69cbcbd862aaf88e63 (diff)
downloadbuildstream-596f6b579788af92bae28e93c919e33f9b7fa3bd.tar.gz
Only run `element.__update_source_state` when necessary
-rw-r--r--src/buildstream/_artifactelement.py1
-rw-r--r--src/buildstream/_loader/loader.py4
-rw-r--r--src/buildstream/_pipeline.py1
-rw-r--r--src/buildstream/element.py24
-rw-r--r--tests/artifactcache/push.py1
5 files changed, 24 insertions, 7 deletions
diff --git a/src/buildstream/_artifactelement.py b/src/buildstream/_artifactelement.py
index 48c3d1769..0baf634b4 100644
--- a/src/buildstream/_artifactelement.py
+++ b/src/buildstream/_artifactelement.py
@@ -80,6 +80,7 @@ class ArtifactElement(Element):
artifact_element = ArtifactElement(context, ref)
# XXX: We need to call update state as it is responsible for
# initialising an Element/ArtifactElement's Artifact (__artifact)
+ artifact_element._update_source_state()
artifact_element._update_state()
cls.__instantiated_artifacts[ref] = artifact_element
diff --git a/src/buildstream/_loader/loader.py b/src/buildstream/_loader/loader.py
index cceda284c..ab2ae69ff 100644
--- a/src/buildstream/_loader/loader.py
+++ b/src/buildstream/_loader/loader.py
@@ -626,6 +626,10 @@ class Loader():
LoadErrorReason.INVALID_JUNCTION)
element = Element._new_from_meta(meta_element)
+ element._update_source_state()
+ # FIXME: We're doubly updating here for the moment; this
+ # should be removed once we don't need the entirety of
+ # _update_state() anymore
element._update_state()
# If this junction element points to a sub-sub-project, we need to
diff --git a/src/buildstream/_pipeline.py b/src/buildstream/_pipeline.py
index 943d65e44..c13cb05e9 100644
--- a/src/buildstream/_pipeline.py
+++ b/src/buildstream/_pipeline.py
@@ -152,6 +152,7 @@ class Pipeline():
for element in self.dependencies(targets, Scope.ALL):
# Determine initial element state.
if not element._resolved_initial_state:
+ element._update_source_state()
element._update_state()
# We may already have Elements which are cached and have their runtimes
diff --git a/src/buildstream/element.py b/src/buildstream/element.py
index dd62deccd..621f02abe 100644
--- a/src/buildstream/element.py
+++ b/src/buildstream/element.py
@@ -1239,9 +1239,6 @@ class Element(Plugin):
self._resolved_initial_state = True
context = self._get_context()
- # Compute and determine consistency of sources
- self.__update_source_state()
-
if self._get_consistency() == Consistency.INCONSISTENT:
# Tracking may still be pending
return
@@ -1330,7 +1327,9 @@ class Element(Plugin):
self.__tracking_scheduled = False
- self._update_state()
+ # Tracking may change the source's ref, and therefore the
+ # source state. We need to update source state.
+ self._update_source_state()
# _track():
#
@@ -1766,7 +1765,7 @@ class Element(Plugin):
# 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()
+ self._update_source_state()
# _pull_pending()
#
@@ -2371,7 +2370,7 @@ class Element(Plugin):
# Private Local Methods #
#############################################################
- # __update_source_state()
+ # _update_source_state()
#
# Updates source consistency state
#
@@ -2379,19 +2378,24 @@ class Element(Plugin):
# cache keys, because the source's ref, whether defined in yaml or
# from the workspace, is a component of the element's cache keys.
#
- def __update_source_state(self):
+ def _update_source_state(self):
# Cannot resolve source state until tracked
if self.__tracking_scheduled:
return
+ old_consistency = self.__consistency
self.__consistency = Consistency.CACHED
# Determine overall consistency of the element
for source in self.__sources:
+ # FIXME: It'd be nice to remove this eventually
source._update_state()
self.__consistency = min(self.__consistency, source._get_consistency())
+ if old_consistency != self.__consistency:
+ self._update_state()
+
# __can_build_incrementally()
#
# Check if the element can be built incrementally, this
@@ -3210,6 +3214,9 @@ class Element(Plugin):
assert not rdep.__build_deps_without_strict_cache_key < 0
if rdep.__build_deps_without_strict_cache_key == 0:
+ # FIXME: Get to the bottom of why we need
+ # source cache keys to be updated here
+ rdep._update_source_state()
rdep._update_state()
# __update_ready_for_runtime()
@@ -3246,6 +3253,9 @@ class Element(Plugin):
assert not rdep.__build_deps_without_cache_key < 0
if rdep.__build_deps_without_cache_key == 0:
+ # FIXME: Get to the bottom of why we need
+ # source cache keys to be updated here
+ rdep._update_source_state()
rdep._update_state()
# If the element is cached, and has all of its runtime dependencies cached,
diff --git a/tests/artifactcache/push.py b/tests/artifactcache/push.py
index 62c443d61..e3ecc554b 100644
--- a/tests/artifactcache/push.py
+++ b/tests/artifactcache/push.py
@@ -40,6 +40,7 @@ def _push(cli, cache_dir, project_dir, config_file, target):
# as this test does not use the cli frontend.
for e in element.dependencies(Scope.ALL):
# Determine initial element state.
+ e._update_source_state()
e._update_state()
# Manually setup the CAS remotes