Gentoo Archives: gentoo-portage-dev

From: Zac Medico <zmedico@g.o>
To: gentoo-portage-dev@l.g.o
Cc: Zac Medico <zmedico@g.o>
Subject: [gentoo-portage-dev] [PATCH] circular_dependency_handler: limit USE combination search (bug 555698)
Date: Mon, 03 Aug 2015 06:22:13
Message-Id: 1438582896-4172-1-git-send-email-zmedico@gentoo.org
1 Limit the number of USE combinations search to 1024, in order to
2 avoid consuming unreasonable abouts of time. First, discard
3 irrelevent flags that are not enabled. Since extract_affecting_use
4 doesn't distinguish between positive and negative effects (flag? vs.
5 !flag?), assume a positive relationship. If there are still too many
6 combinations, then don't bother to explore any of them.
7
8 X-Gentoo-Bug: 555698
9 X-Gentoo-Bug-url: https://bugs.gentoo.org/show_bug.cgi?id=555698
10 ---
11 pym/_emerge/resolver/circular_dependency.py | 21 +++++++++++++++++++--
12 1 file changed, 19 insertions(+), 2 deletions(-)
13
14 diff --git a/pym/_emerge/resolver/circular_dependency.py b/pym/_emerge/resolver/circular_dependency.py
15 index b710671..5c11956 100644
16 --- a/pym/_emerge/resolver/circular_dependency.py
17 +++ b/pym/_emerge/resolver/circular_dependency.py
18 @@ -14,7 +14,9 @@ from _emerge.DepPrioritySatisfiedRange import DepPrioritySatisfiedRange
19 from _emerge.Package import Package
20
21 class circular_dependency_handler(object):
22 -
23 +
24 + MAX_AFFECTING_USE = 10
25 +
26 def __init__(self, depgraph, graph):
27 self.depgraph = depgraph
28 self.graph = graph
29 @@ -156,7 +158,7 @@ class circular_dependency_handler(object):
30 total_flags = set()
31 total_flags.update(affecting_use, required_use_flags)
32 total_flags.difference_update(untouchable_flags)
33 - if len(total_flags) <= 10:
34 + if len(total_flags) <= self.MAX_AFFECTING_USE:
35 affecting_use = total_flags
36
37 affecting_use = tuple(affecting_use)
38 @@ -164,6 +166,21 @@ class circular_dependency_handler(object):
39 if not affecting_use:
40 continue
41
42 + if len(affecting_use) > self.MAX_AFFECTING_USE:
43 + # Limit the number of combinations explored (bug #555698).
44 + # First, discard irrelevent flags that are not enabled.
45 + # Since extract_affecting_use doesn't distinguish between
46 + # positive and negative effects (flag? vs. !flag?), assume
47 + # a positive relationship.
48 + current_use = self.depgraph._pkg_use_enabled(parent)
49 + affecting_use = tuple(flag for flag in affecting_use
50 + if flag in current_use)
51 +
52 + if len(affecting_use) > self.MAX_AFFECTING_USE:
53 + # There are too many USE combinations to explore in
54 + # a reasonable amount of time.
55 + continue
56 +
57 #We iterate over all possible settings of these use flags and gather
58 #a set of possible changes
59 #TODO: Use the information encoded in REQUIRED_USE
60 --
61 2.3.6

Replies