Gentoo Archives: gentoo-dev

From: Martin Vaeth <martin@×××××.de>
To: gentoo-dev@l.g.o
Subject: [gentoo-dev] Re: SAT-based dependency solver: request for test cases
Date: Tue, 13 Feb 2018 07:53:04
Message-Id: p5u5at$58h$1@blaine.gmane.org
In Reply to: Re: [gentoo-dev] SAT-based dependency solver: request for test cases by Michael Lienhardt
1 Michael Lienhardt <michael.lienhardt@×××××××.net> wrote:
2 >
3 > ad-hoc fixes and tweaks that can hardly be encoded into SAT constraints.
4
5 The main difficulty which I see is that one does not want only _some_
6 solution, but among all solutions one which optimizes certain quantities.
7 So it seems to me that a discrete optimization under constraints
8 is required instead of a pure SAT solver (although formally, of course,
9 such an optimization problem can be reduced to SAT, I do not know whether
10 you went the road):
11
12 a. The number of packages which change their status (from installed to
13 uninstalled or vice versa) should be minimal.
14
15 b. Similarly, the number of USE-flag changes necessary to achieve this
16 aim should be minimized.
17 (You didn't tell whether your solver already supports such changes,
18 but when it is finished, it definitely should.)
19
20 Hopefully in near future, there will be a second class of USE-flags
21 whose change is "cheap" which should be excluded from this minimization
22 restriction:
23 https://bugs.gentoo.org/show_bug.cgi?id=424283
24 I think the main reason why nobody dared to implement them yet
25 (although almost everybody wants them) are exactly these implications
26 on the current solver in portage which nobody dares to change anymore
27 seriously.
28
29 c. A solution with dependency loops should be avoided if possible
30 (which is why currently the PDEPEND hacks do exist: To tell the solver
31 which loops are not a problem.)
32
33 d. In || ( ... ) clauses the left-most packages should be preserved.
34 There are similar (and more difficult) rules for REQUIRED_USE.
35
36 e. Last but not least: The preferences are ordered a > b > c > d
37 (A dependency loop of uninstalled packages should probably have even
38 higher priority than a).
39 Additionally the change installed -> uninstalled should be less
40 "expensive" than the change uninstalled -> installed.
41 The correct weighting of the quantities should probably be a matter
42 of discussion (or preferrably even user-customizable), and preferrably
43 should not depend only on the number of packages but also on other
44 customizable quantities (e.g. the package size).
45
46 Perhaps - if one can rely on some solver - in a future EAPI instead
47 of the size heuristic, one could give a hint for how "expensive" it
48 is to recompile a certain package, so that dependency results can
49 be better optimized for that.
50
51 IIRC, this is already built in rudimentarily in portage's current
52 solver by defining the recompilation costs of virtual packages as 0.
53
54 > I don't deal with installation order [...] circular dependency problem
55
56 ++
57 Once the packages are known, the installation order and breaking of
58 unavoidable circles is a matter of a single graph traversal in the
59 resulting subgraph which needs neglectable linear time.
60 However, if there is a solution without a circle this should have
61 been found instead in the first place (cf. c).

Replies