Optimize merge order to try and select nodes that only have
authorZac Medico <zmedico@gentoo.org>
Fri, 2 Nov 2007 07:43:53 +0000 (07:43 -0000)
committerZac Medico <zmedico@gentoo.org>
Fri, 2 Nov 2007 07:43:53 +0000 (07:43 -0000)
unsatisfied PDEPEND slightly earlier. This solves a problem
with xorg-server being merged too early during an all binary
install (since DEPEND is ignored for binaries), triggering
built_with_use() calls to fail as reported in bug #189966.
Since DEPEND is discarded in cases like this, it is
important to exploit the difference between PDEPEND and
RDEPEND in order to optimize merge order. Without this
optimization, the merge order is technically correct, but
not as optimal as it should be and has lots of potential to
trigger issues with built_with_use() or similar things that
require better optimization of merge order.
(trunk r8357:8359)

Fix ignore_priority logic in depgraph.altlist() in order
to handle some cases where it was possible for nodes to
be selected without their PDEPENDs being propperly added
to the asap_nodes list. (trunk r8360)

svn path=/main/branches/2.1.2/; revision=8378

bin/emerge

index c38e4d3c18c21f0bdb972057452e54918a2faf56..b9bebda6b578cd4c2e8118650deceb326afb4dbc 100755 (executable)
@@ -2346,7 +2346,7 @@ class depgraph:
                                        break
                ignore_priority_soft_range = [None]
                ignore_priority_soft_range.extend(
-                       xrange(DepPriority.MIN, DepPriority.SOFT + 1))
+                       xrange(DepPriority.MIN, DepPriority.MEDIUM_SOFT + 1))
                tree_mode = "--tree" in self.myopts
                # Tracks whether or not the current iteration should prefer asap_nodes
                # if available.  This is set to False when the previous iteration
@@ -2375,6 +2375,7 @@ class depgraph:
 
                while not mygraph.empty():
                        selected_nodes = None
+                       ignore_priority = None
                        if prefer_asap and asap_nodes:
                                """ASAP nodes are merged before their soft deps."""
                                asap_nodes = [node for node in asap_nodes \
@@ -2411,6 +2412,7 @@ class depgraph:
                                                        (accept_root_node or ignore_priority is None):
                                                        # settle for a root node
                                                        selected_nodes = [nodes[0]]
+
                        if not selected_nodes:
                                nodes = get_nodes(ignore_priority=DepPriority.MEDIUM)
                                if nodes:
@@ -2454,6 +2456,14 @@ class depgraph:
                                                if selected_nodes:
                                                        break
 
+                                       # If any nodes have been selected here, it's always
+                                       # possible that anything up to a MEDIUM_SOFT priority
+                                       # relationship has been ignored. This state is recorded
+                                       # in ignore_priority so that relevant nodes will be
+                                       # added to asap_nodes when appropriate.
+                                       if selected_nodes:
+                                               ignore_priority = DepPriority.MEDIUM_SOFT
+
                                        if prefer_asap and asap_nodes and not selected_nodes:
                                                # We failed to find any asap nodes to merge, so ignore
                                                # them for the next iteration.
@@ -2466,25 +2476,23 @@ class depgraph:
                                                accept_root_node = True
                                                continue
 
-                                       if selected_nodes and ignore_priority > DepPriority.SOFT:
-                                               # Try to merge ignored medium deps as soon as possible.
-                                               for node in selected_nodes:
-                                                       children = set(mygraph.child_nodes(node))
-                                                       soft = children.difference(
-                                                               mygraph.child_nodes(node,
-                                                               ignore_priority=DepPriority.SOFT))
-                                                       medium_soft = children.difference(
-                                                               mygraph.child_nodes(node,
-                                                               ignore_priority=DepPriority.MEDIUM_SOFT))
-                                                       medium_soft.difference_update(soft)
-                                                       for child in medium_soft:
-                                                               if child in selected_nodes:
-                                                                       continue
-                                                               if child in asap_nodes:
-                                                                       continue
-                                                               # TODO: Try harder to make these nodes get
-                                                               # merged absolutely as soon as possible.
-                                                               asap_nodes.append(child)
+                       if selected_nodes and ignore_priority > DepPriority.SOFT:
+                               # Try to merge ignored medium deps as soon as possible.
+                               for node in selected_nodes:
+                                       children = set(mygraph.child_nodes(node))
+                                       soft = children.difference(
+                                               mygraph.child_nodes(node,
+                                               ignore_priority=DepPriority.SOFT))
+                                       medium_soft = children.difference(
+                                               mygraph.child_nodes(node,
+                                               ignore_priority=DepPriority.MEDIUM_SOFT))
+                                       medium_soft.difference_update(soft)
+                                       for child in medium_soft:
+                                               if child in selected_nodes:
+                                                       continue
+                                               if child in asap_nodes:
+                                                       continue
+                                               asap_nodes.append(child)
 
                        if not selected_nodes:
                                if not myblockers.is_empty():