Skip to content

Attempt to speed solving when test is enable projectwide #7490

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 6 commits into from
Aug 11, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -127,11 +127,18 @@ preferPackagePreferences pcs =

-- | Traversal that tries to establish package stanza enable\/disable
-- preferences. Works by reordering the branches of stanza choices.
-- Note that this works on packages lower in the path as well as at the top level.
-- This is because stanza preferences apply to local packages only
-- and for local packages, a single version is fixed, which means
-- (for now) that all stanza preferences must be uniform at all levels.
-- Further, even when we can have multiple versions of the same package,
-- the build plan will be more efficient if we can attempt to keep
-- stanza preferences aligned at all levels.
preferPackageStanzaPreferences :: (PN -> PackagePreferences) -> Tree d c -> Tree d c
preferPackageStanzaPreferences pcs = trav go
where
go (SChoiceF qsn@(SN (Q pp pn) s) rdm gr _tr ts)
| primaryPP pp && enableStanzaPref pn s =
go (SChoiceF qsn@(SN (Q _pp pn) s) rdm gr _tr ts)
| enableStanzaPref pn s =
-- move True case first to try enabling the stanza
let ts' = W.mapWeightsWithKey (\k w -> weight k : w) ts
weight k = if k then 0 else 1
Expand Down
7 changes: 4 additions & 3 deletions cabal-install/src/Distribution/Client/ProjectPlanning.hs
Original file line number Diff line number Diff line change
Expand Up @@ -1024,13 +1024,14 @@ planPackages verbosity comp platform solver SolverSettings{..}
| (pc, src) <- solverSettingConstraints ]

. addPreferences
-- enable stanza preference where the user did not specify
-- enable stanza preference unilaterally, regardless if the user asked
-- accordingly or expressed no preference, to help hint the solver
[ PackageStanzasPreference pkgname stanzas
| pkg <- localPackages
, let pkgname = pkgSpecifierTarget pkg
stanzaM = Map.findWithDefault Map.empty pkgname pkgStanzasEnable
stanzas = [ stanza | stanza <- [minBound..maxBound]
, Map.lookup stanza stanzaM == Nothing ]
, Map.lookup stanza stanzaM /= Just False ]
, not (null stanzas)
]

Expand Down Expand Up @@ -2592,7 +2593,7 @@ nubComponentTargets =
-> [(ComponentTarget, NonEmpty a)]
wholeComponentOverrides ts =
case [ ta | ta@(ComponentTarget _ WholeComponent, _) <- ts ] of
((t, x):_) ->
((t, x):_) ->
let
-- Delete tuple (t, x) from original list to avoid duplicates.
-- Use 'deleteBy', to avoid additional Class constraint on 'nubComponentTargets'.
Expand Down