commit:     cdc781349337fa755bc15773e2a87e4b41f5ff1e
Author:     Zac Medico <zmedico <AT> gentoo <DOT> org>
AuthorDate: Wed Nov 22 21:46:12 2023 +0000
Commit:     Zac Medico <zmedico <AT> gentoo <DOT> org>
CommitDate: Wed Nov 22 22:26:13 2023 +0000
URL:        https://gitweb.gentoo.org/proj/portage.git/commit/?id=cdc78134

Revert "find_smallest_cycle: Increase ignore_priority to find smaller cycles"

This reverts commit 9206d5a75ecd2d9ae0fe63e57d28aa8061b5927e.
The len(smallest_cycle) == 1 loop termination condition is
not optimal and it's too expensive as reported in bug 917660.

Bug: https://bugs.gentoo.org/917660
Bug: https://bugs.gentoo.org/917259
Signed-off-by: Zac Medico <zmedico <AT> gentoo.org>

 lib/_emerge/depgraph.py                            |  7 +++----
 .../tests/resolver/test_alternatives_gzip.py       |  7 +++++--
 lib/portage/tests/resolver/test_merge_order.py     | 24 ++++++++++------------
 .../tests/resolver/test_rebuild_ghostscript.py     |  6 +++---
 4 files changed, 22 insertions(+), 22 deletions(-)

diff --git a/lib/_emerge/depgraph.py b/lib/_emerge/depgraph.py
index 0d3b37c698..e4305c18c9 100644
--- a/lib/_emerge/depgraph.py
+++ b/lib/_emerge/depgraph.py
@@ -9345,10 +9345,9 @@ class depgraph:
                                     smallest_cycle = selected_nodes
                                     ignore_priority = priority
 
-                        if smallest_cycle is not None and len(smallest_cycle) 
== 1:
-                            # The cycle can't get any smaller than this,
-                            # so there is no need to search further since
-                            # we try to minimize ignore_priority.
+                        # Exit this loop with the lowest possible priority, 
which
+                        # minimizes the use of installed packages to break 
cycles.
+                        if smallest_cycle is not None:
                             break
 
                     return smallest_cycle, ignore_priority

diff --git a/lib/portage/tests/resolver/test_alternatives_gzip.py 
b/lib/portage/tests/resolver/test_alternatives_gzip.py
index 7cd1da25f1..602ed1756f 100644
--- a/lib/portage/tests/resolver/test_alternatives_gzip.py
+++ b/lib/portage/tests/resolver/test_alternatives_gzip.py
@@ -1,6 +1,8 @@
 # Copyright 2023 Gentoo Authors
 # Distributed under the terms of the GNU General Public License v2
 
+import pytest
+
 from portage.tests import TestCase
 from portage.tests.resolver.ResolverPlayground import (
     ResolverPlayground,
@@ -8,6 +10,7 @@ from portage.tests.resolver.ResolverPlayground import (
 )
 
 
[email protected]()
 class AlternativesGzipTestCase(TestCase):
     def testAlternativesGzip(self):
         """
@@ -16,8 +19,8 @@ class AlternativesGzipTestCase(TestCase):
         find_smallest_cycle selects a large cycle and the topological
         sort produces poor results when leaf_nodes returns
         app-alternatives/gzip as part of a large group of nodes.
-        This problem was solved by increasing ignore_priority in order
-        to find a smaller cycle.
+        This problem might be solved by implementing a finer-grained
+        ignore_priority for leaf_nodes calls.
         """
         ebuilds = {
             "app-alternatives/gzip-1": {

diff --git a/lib/portage/tests/resolver/test_merge_order.py 
b/lib/portage/tests/resolver/test_merge_order.py
index 671543ca29..940eb3bbbe 100644
--- a/lib/portage/tests/resolver/test_merge_order.py
+++ b/lib/portage/tests/resolver/test_merge_order.py
@@ -382,12 +382,10 @@ class MergeOrderTestCase(TestCase):
                 ambiguous_merge_order=True,
                 # The following merge order assertion reflects optimal order 
for
                 # a circular relationship which is DEPEND in one direction and
-                # RDEPEND in the other. However, it is not respected because
-                # it would result in a temporarily broken RDEPEND, so we 
instead
-                # rely on satisfied installed build-time dependencies.
-                # merge_order_assertions=(
-                #    ("app-misc/circ-buildtime-a-1", 
"app-misc/circ-buildtime-c-1"),
-                # ),
+                # RDEPEND in the other.
+                merge_order_assertions=(
+                    ("app-misc/circ-buildtime-a-1", 
"app-misc/circ-buildtime-c-1"),
+                ),
                 mergelist=[
                     (
                         "app-misc/circ-buildtime-b-1",
@@ -701,15 +699,15 @@ class MergeOrderTestCase(TestCase):
                     "!app-misc/installed-blocker-a",
                     "app-misc/circ-direct-a-1",
                     "app-misc/circ-direct-b-1",
-                    "app-misc/circ-satisfied-a-1",
-                    "app-misc/circ-satisfied-c-1",
-                    "app-misc/circ-satisfied-b-1",
-                    "app-misc/circ-buildtime-c-1",
-                    "app-misc/circ-buildtime-b-1",
-                    "app-misc/circ-buildtime-a-1",
-                    "app-misc/some-app-c-1",
                     "x11-base/xorg-server-1.14.1",
                     "media-libs/mesa-9.1.3",
+                    "app-misc/circ-buildtime-a-1",
+                    "app-misc/circ-buildtime-b-1",
+                    "app-misc/circ-buildtime-c-1",
+                    "app-misc/some-app-c-1",
+                    "app-misc/circ-satisfied-a-1",
+                    "app-misc/circ-satisfied-b-1",
+                    "app-misc/circ-satisfied-c-1",
                 ],
             ),
         )

diff --git a/lib/portage/tests/resolver/test_rebuild_ghostscript.py 
b/lib/portage/tests/resolver/test_rebuild_ghostscript.py
index e1d736610e..8d7cbb1f92 100644
--- a/lib/portage/tests/resolver/test_rebuild_ghostscript.py
+++ b/lib/portage/tests/resolver/test_rebuild_ghostscript.py
@@ -136,12 +136,12 @@ class RebuildGhostscriptTestCase(TestCase):
                 success=True,
                 mergelist=[
                     "sys-apps/dbus-1.15.6",
+                    "x11-libs/gtk+-3.24.38",
+                    "net-print/cups-2.4.6",
+                    "net-dns/avahi-0.8-r7",
                     "app-text/ghostscript-gpl-10.01.2",
                     "app-text/libspectre-0.2.12",
                     "x11-libs/goffice-0.10.55",
-                    "net-dns/avahi-0.8-r7",
-                    "net-print/cups-2.4.6",
-                    "x11-libs/gtk+-3.24.38",
                 ],
             ),
         )

Reply via email to