You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@buildstream.apache.org by ju...@apache.org on 2021/03/02 16:02:18 UTC

[buildstream] 03/08: _pipeline.py: Drop the optimization for cached elements in the planner

This is an automated email from the ASF dual-hosted git repository.

juergbi pushed a commit to branch juerg/cache-query
in repository https://gitbox.apache.org/repos/asf/buildstream.git

commit e90f3e9952379790e7e655999111984b7246ba52
Author: Jürg Billeter <j...@bitron.ch>
AuthorDate: Wed Sep 16 15:55:26 2020 +0200

    _pipeline.py: Drop the optimization for cached elements in the planner
    
    The overhead of planning already cached elements and unneeded build-only
    dependencies should be fairly small as unneeded jobs can still be
    skipped. This optimization was also already disabled for non-strict
    build plans with a remote artifact cache.
    
    This change is necessary in preparation for parallelizing cache queries.
---
 src/buildstream/_pipeline.py | 20 +++++++-------------
 1 file changed, 7 insertions(+), 13 deletions(-)

diff --git a/src/buildstream/_pipeline.py b/src/buildstream/_pipeline.py
index e1e6dcf..802e52b 100644
--- a/src/buildstream/_pipeline.py
+++ b/src/buildstream/_pipeline.py
@@ -88,10 +88,7 @@ def get_selection(context: Context, targets: List[Element], mode: str, *, silent
         return elements
 
     def plan() -> List[Element]:
-        # Keep locally cached elements in the plan if remote artifact cache is used
-        # to allow pulling artifact with strict cache key, if available.
-        plan_cached = not context.get_strict() and context.artifactcache.has_fetch_remotes()
-        return _Planner().plan(targets, plan_cached)
+        return _Planner().plan(targets)
 
     # Work around python not having a switch statement; this is
     # much clearer than the if/elif/else block we used to have.
@@ -293,9 +290,8 @@ def assert_sources_cached(context: Context, elements: List[Element]):
 # _Planner()
 #
 # An internal object used for constructing build plan
-# from a given resolved toplevel element, while considering what
-# parts need to be built depending on build only dependencies
-# being cached, and depth sorting for more efficient processing.
+# from a given resolved toplevel element, using depth
+# sorting for more efficient processing.
 #
 class _Planner:
     def __init__(self):
@@ -319,15 +315,13 @@ class _Planner:
         for dep in element._dependencies(_Scope.RUN, recurse=False):
             self.plan_element(dep, depth)
 
-        # Dont try to plan builds of elements that are cached already
-        if not element._cached_success():
-            for dep in element._dependencies(_Scope.BUILD, recurse=False):
-                self.plan_element(dep, depth + 1)
+        for dep in element._dependencies(_Scope.BUILD, recurse=False):
+            self.plan_element(dep, depth + 1)
 
         self.depth_map[element] = depth
         self.visiting_elements.remove(element)
 
-    def plan(self, roots, plan_cached):
+    def plan(self, roots):
         for root in roots:
             self.plan_element(root, 0)
 
@@ -337,4 +331,4 @@ class _Planner:
         for index, item in enumerate(depth_sorted):
             item[0]._set_depth(index)
 
-        return [item[0] for item in depth_sorted if plan_cached or not item[0]._cached_success()]
+        return [item[0] for item in depth_sorted]