test_merge_order: test smallest runtime cycle
authorZac Medico <zmedico@gentoo.org>
Sun, 12 Jun 2011 22:12:26 +0000 (15:12 -0700)
committerZac Medico <zmedico@gentoo.org>
Sun, 12 Jun 2011 22:12:26 +0000 (15:12 -0700)
In the case of multiple runtime cycles, where some cycles
may depend on smaller independent cycles, it's optimal
to merge smaller independent cycles before other cycles
that depend on them. Therefore, we search for the
smallest cycle in order to try and identify and prefer
these smaller independent cycles.

pym/_emerge/depgraph.py
pym/portage/tests/resolver/test_merge_order.py

index 3b47c35741bbeab9d8df6035001e8e09f91f731a..9ce199b159df145c24d9d8275aba2fb171f585bc 100644 (file)
@@ -5022,6 +5022,12 @@ class depgraph(object):
                                        # we want to minimize the number of nodes gathered, since
                                        # this tends to produce a more optimal merge order.
                                        # Ignoring all medium_soft deps serves this purpose.
+                                       # In the case of multiple runtime cycles, where some cycles
+                                       # may depend on smaller independent cycles, it's optimal
+                                       # to merge smaller independent cycles before other cycles
+                                       # that depend on them. Therefore, we search for the
+                                       # smallest cycle in order to try and identify and prefer
+                                       # these smaller independent cycles.
                                        ignore_priority = priority_range.ignore_medium_soft
                                        smallest_cycle = None
                                        for node in nodes:
index e94b6c7dd1c76ced0e6acab0d0cca4d4f4eacff9..0a52c813ba75803f200277034c50e7764fec5adc 100644 (file)
@@ -81,6 +81,27 @@ class MergeOrderTestCase(TestCase):
                                "DEPEND": "app-misc/circ-satisfied-a",
                                "RDEPEND": "app-misc/circ-satisfied-a",
                        },
+                       "app-misc/circ-smallest-a-1": {
+                               "RDEPEND": "app-misc/circ-smallest-b",
+                       },
+                       "app-misc/circ-smallest-b-1": {
+                               "RDEPEND": "app-misc/circ-smallest-a",
+                       },
+                       "app-misc/circ-smallest-c-1": {
+                               "RDEPEND": "app-misc/circ-smallest-d",
+                       },
+                       "app-misc/circ-smallest-d-1": {
+                               "RDEPEND": "app-misc/circ-smallest-e",
+                       },
+                       "app-misc/circ-smallest-e-1": {
+                               "RDEPEND": "app-misc/circ-smallest-c",
+                       },
+                       "app-misc/circ-smallest-f-1": {
+                               "RDEPEND": "app-misc/circ-smallest-g app-misc/circ-smallest-a app-misc/circ-smallest-c",
+                       },
+                       "app-misc/circ-smallest-g-1": {
+                               "RDEPEND": "app-misc/circ-smallest-f",
+                       },
                        "app-misc/installed-blocker-a-1" : {
                                "EAPI"   : "2",
                                "DEPEND" : "!app-misc/blocker-buildtime-a",
@@ -294,6 +315,18 @@ class MergeOrderTestCase(TestCase):
                                ambiguous_merge_order = True,
                                merge_order_assertions = (("app-misc/circ-satisfied-a-1", "app-misc/circ-satisfied-c-1"),),
                                mergelist = [("app-misc/circ-satisfied-a-1", "app-misc/circ-satisfied-b-1", "app-misc/circ-satisfied-c-1")]),
+                       # In the case of multiple runtime cycles, where some cycles
+                       # may depend on smaller independent cycles, it's optimal
+                       # to merge smaller independent cycles before other cycles
+                       # that depend on them.
+                       ResolverPlaygroundTestCase(
+                               ["app-misc/circ-smallest-a", "app-misc/circ-smallest-c", "app-misc/circ-smallest-f"],
+                               success = True,
+                               ambiguous_merge_order = True,
+                               all_permutations = True,
+                               mergelist = [('app-misc/circ-smallest-a-1', 'app-misc/circ-smallest-b-1'),
+                               ('app-misc/circ-smallest-c-1', 'app-misc/circ-smallest-d-1', 'app-misc/circ-smallest-e-1'),
+                               ('app-misc/circ-smallest-f-1', 'app-misc/circ-smallest-g-1')]),
                        # installed package has buildtime-only blocker
                        # that should be ignored
                        ResolverPlaygroundTestCase(