@@ -0,0 +1,147 @@
1+From fa47bff82b0f0f0bda7ca7e01b15e5740b63f775 Mon Sep 17 00:00:00 2001
2+From: Gershom Bazerman <gershom@arista.com>
3+Date: Fri, 23 Jul 2021 11:24:42 -0400
4+Subject: [PATCH 1/4] attempt to speed solving when test is enable projectwide
7+ .../Distribution/Solver/Modular/Preference.hs | 6 ++++--
8+ .../Distribution/Client/ProjectPlanning.hs | 13 ++++---------
9+ 2 files changed, 8 insertions(+), 11 deletions(-)
11+diff --git a/Distribution/Solver/Modular/Preference.hs b/Distribution/Solver/Modular/Preference.hs
12+index d25ef846356..4275563006e 100644
13+--- a/Distribution/Solver/Modular/Preference.hs
14++++ b/Distribution/Solver/Modular/Preference.hs
15+@@ -127,11 +127,13 @@ preferPackagePreferences pcs =
17+ -- | Traversal that tries to establish package stanza enable\/disable
18+ -- preferences. Works by reordering the branches of stanza choices.
19++-- Note that this works on packages lower in the path as well as at the top level,
20++-- as lower choices need to remain compatible with top level choices.
21+ preferPackageStanzaPreferences :: (PN -> PackagePreferences) -> Tree d c -> Tree d c
22+ preferPackageStanzaPreferences pcs = trav go
24+- go (SChoiceF qsn@(SN (Q pp pn) s) rdm gr _tr ts)
25+- | primaryPP pp && enableStanzaPref pn s =
26++ go (SChoiceF qsn@(SN (Q _pp pn) s) rdm gr _tr ts)
27++ | enableStanzaPref pn s =
28+ -- move True case first to try enabling the stanza
29+ let ts' = W.mapWeightsWithKey (\k w -> weight k : w) ts
30+ weight k = if k then 0 else 1
31+diff --git a/Distribution/Client/ProjectPlanning.hs b/Distribution/Client/ProjectPlanning.hs
32+index 077c6422be4..18a4bf43a0d 100644
33+--- a/Distribution/Client/ProjectPlanning.hs
34++++ b/Distribution/Client/ProjectPlanning.hs
35+@@ -1024,14 +1024,9 @@ planPackages verbosity comp platform solver SolverSettings{..}
36+ | (pc, src) <- solverSettingConstraints ]
39+- -- enable stanza preference where the user did not specify
40+- [ PackageStanzasPreference pkgname stanzas
41+- | pkg <- localPackages
42+- , let pkgname = pkgSpecifierTarget pkg
43+- stanzaM = Map.findWithDefault Map.empty pkgname pkgStanzasEnable
44+- stanzas = [ stanza | stanza <- [minBound..maxBound]
45+- , Map.lookup stanza stanzaM == Nothing ]
46+- , not (null stanzas)
47++ -- enable stanza preference unilaterally, even when the user asked to enable as well, to help hint the solver.
48++ [ PackageStanzasPreference pkgname [minBound..maxBound]
49++ | pkgname <- map pkgSpecifierTarget localPackages
53+From 624b8dc2069964de7c99cb7c9fa8c8674db797de Mon Sep 17 00:00:00 2001
54+From: Gershom Bazerman <gershom@arista.com>
55+Date: Tue, 3 Aug 2021 17:35:12 -0400
56+Subject: [PATCH 2/4] fix bug in preferences
59+ cabal-install/Distribution/Client/ProjectPlanning.hs | 7 ++++++-
60+ 1 file changed, 6 insertions(+), 1 deletion(-)
62+diff --git a/Distribution/Client/ProjectPlanning.hs b/Distribution/Client/ProjectPlanning.hs
63+index 18a4bf43a0d..42fe5be8f3d 100644
64+--- a/Distribution/Client/ProjectPlanning.hs
65++++ b/Distribution/Client/ProjectPlanning.hs
66+@@ -1026,7 +1026,12 @@ planPackages verbosity comp platform solver SolverSettings{..}
68+ -- enable stanza preference unilaterally, even when the user asked to enable as well, to help hint the solver.
69+ [ PackageStanzasPreference pkgname [minBound..maxBound]
70+- | pkgname <- map pkgSpecifierTarget localPackages
71++ | pkg <- localPackages
72++ , let pkgname = pkgSpecifierTarget pkg
73++ stanzaM = Map.findWithDefault Map.empty pkgname pkgStanzasEnable
74++ stanzas = [ stanza | stanza <- [minBound..maxBound]
75++ , Map.lookup stanza stanzaM /= Just False ]
76++ , not (null stanzas)
81+From a5d04451d3d45bcfc8f679340f1dfd1e0e2993ed Mon Sep 17 00:00:00 2001
82+From: Gershom Bazerman <gershom@arista.com>
83+Date: Mon, 9 Aug 2021 18:17:49 -0400
84+Subject: [PATCH 3/4] fix bug
87+ cabal-install/Distribution/Client/ProjectPlanning.hs | 2 +-
88+ 1 file changed, 1 insertion(+), 1 deletion(-)
90+diff --git a/Distribution/Client/ProjectPlanning.hs b/Distribution/Client/ProjectPlanning.hs
91+index 42fe5be8f3d..3aefe9242f8 100644
92+--- a/Distribution/Client/ProjectPlanning.hs
93++++ b/Distribution/Client/ProjectPlanning.hs
94+@@ -1025,7 +1025,7 @@ planPackages verbosity comp platform solver SolverSettings{..}
97+ -- enable stanza preference unilaterally, even when the user asked to enable as well, to help hint the solver.
98+- [ PackageStanzasPreference pkgname [minBound..maxBound]
99++ [ PackageStanzasPreference pkgname stanzas
100+ | pkg <- localPackages
101+ , let pkgname = pkgSpecifierTarget pkg
102+ stanzaM = Map.findWithDefault Map.empty pkgname pkgStanzasEnable
104+From fdf3f7f0a633de79b4c8f1298eaf433cdf558250 Mon Sep 17 00:00:00 2001
105+From: Gershom Bazerman <gershom@arista.com>
106+Date: Wed, 11 Aug 2021 13:57:57 -0400
107+Subject: [PATCH 4/4] touchup comments
110+ .../Distribution/Solver/Modular/Preference.hs | 9 +++++++--
111+ cabal-install/Distribution/Client/ProjectPlanning.hs | 3 ++-
112+ 2 files changed, 9 insertions(+), 3 deletions(-)
114+diff --git a/Distribution/Solver/Modular/Preference.hs b/Distribution/Solver/Modular/Preference.hs
115+index 4275563006e..ed5adfbf8b2 100644
116+--- a/Distribution/Solver/Modular/Preference.hs
117++++ b/Distribution/Solver/Modular/Preference.hs
118+@@ -127,8 +127,13 @@ preferPackagePreferences pcs =
120+ -- | Traversal that tries to establish package stanza enable\/disable
121+ -- preferences. Works by reordering the branches of stanza choices.
122+--- Note that this works on packages lower in the path as well as at the top level,
123+--- as lower choices need to remain compatible with top level choices.
124++-- Note that this works on packages lower in the path as well as at the top level.
125++-- This is because stanza preferences apply to local packages only
126++-- and for local packages, a single version is fixed, which means
127++-- (for now) that all stanza preferences must be uniform at all levels.
128++-- Further, even when we can have multiple versions of the same package,
129++-- the build plan will be more efficient if we can attempt to keep
130++-- stanza preferences aligned at all levels.
131+ preferPackageStanzaPreferences :: (PN -> PackagePreferences) -> Tree d c -> Tree d c
132+ preferPackageStanzaPreferences pcs = trav go
134+diff --git a/Distribution/Client/ProjectPlanning.hs b/Distribution/Client/ProjectPlanning.hs
135+index 3aefe9242f8..fc6d9a17383 100644
136+--- a/Distribution/Client/ProjectPlanning.hs
137++++ b/Distribution/Client/ProjectPlanning.hs
138+@@ -1024,7 +1024,8 @@ planPackages verbosity comp platform solver SolverSettings{..}
139+ | (pc, src) <- solverSettingConstraints ]
142+- -- enable stanza preference unilaterally, even when the user asked to enable as well, to help hint the solver.
143++ -- enable stanza preference unilaterally, regardless if the user asked
144++ -- accordingly or expressed no preference, to help hint the solver
145+ [ PackageStanzasPreference pkgname stanzas
146+ | pkg <- localPackages
147+ , let pkgname = pkgSpecifierTarget pkg