Skip to content

Resolving dependencies for wai repo on GHC 7.6.3 times out with Travis #3453

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

Closed
snoyberg opened this issue May 22, 2016 · 17 comments
Closed

Comments

@snoyberg
Copy link
Collaborator

We have regular build failures on the wai repo due to the build timing out, e.g. https://travis-ci.org/yesodweb/wai/jobs/132019472. I don't know if there is legitimately no build plan, or if the solver is simply having difficulty finding one. I've kicked off some dependency solving on one of my servers to try to determine if there's a workaround. Nonetheless, taking over 10 minutes to solve dependencies is surprising.

Reproduction:

  • Tested with GHC 7.6.3 on Linux
  • Tested with cabal-install 1.16, 1.22, and 1.24
  • Check out the wai repo at commit c9427c887a40dbc35b6f4cca58f5096cd0a1b6e4 to the directory /home/travis/build/yesodweb/wai
  • Run the following command:
cabal install --enable-tests --enable-benchmarks --force-reinstalls --ghc-options=-O0 --reorder-goals --max-backjumps=-1 /home/travis/build/yesodweb/wai/warp/ /home/travis/build/yesodweb/wai/wai-conduit/ /home/travis/build/yesodweb/wai/wai-websockets/ /home/travis/build/yesodweb/wai/wai/ /home/travis/build/yesodweb/wai/wai-handler-launch/ /home/travis/build/yesodweb/wai/auto-update/ /home/travis/build/yesodweb/wai/warp-tls/ /home/travis/build/yesodweb/wai/wai-handler-fastcgi/ /home/travis/build/yesodweb/wai/mime-types/ /home/travis/build/yesodweb/wai/wai-extra/ /home/travis/build/yesodweb/wai/wai-app-static/

Expected:

  • Either dependency solving succeeds or fails, in a reasonable amount of time
  • Very long period of inactivity
snoyberg added a commit to yesodweb/wai that referenced this issue May 22, 2016
@23Skidoo
Copy link
Member

/cc @kosmikus

@23Skidoo 23Skidoo added this to the cabal-install 1.26 milestone May 22, 2016
@grayjay
Copy link
Collaborator

grayjay commented May 23, 2016

I started looking into this issue. There is no solution, because there is a conflict between warp's doctest test suite and its benchmarks with GHC 7.6.3.

The test requires doctest, which requires the package ghc. ghc cannot be reinstalled, and the installed version depends on the installed bytestring (0.10.0.2). The benchmark requires criterion >= 1. criterion-1.0.0.0 through 1.1.1.0 all require aeson >= 0.8, and aeson-0.8.0.0 through 0.11.2.0 require bytestring >= 0.10.4.0.

It would be nice to have cabal fail faster, especially when there is a conflict involving so few packages.

@snoyberg
Copy link
Collaborator Author

@grayjay Thank you, that information was very useful. For my immediate needs, I've disabled benchmark building for GHC 7.6.3 (yesodweb/wai@7127092), which works around this issue nicely, and we get testing of the wai repo with 7.6.3 again.

@phadej
Copy link
Collaborator

phadej commented May 23, 2016

@grayjay is the problem because solver tries ghc quite late in the traversal?

@grayjay
Copy link
Collaborator

grayjay commented May 26, 2016

cabal tries ghc late because it waits to try warp:test. I ran the solver after removing the constraint on criterion so that it could finish. Here are the logs, with and without --reorder-goals: https://gist.github.com/grayjay/5e889f9a701705399f3a054fbc2ac312. I think it would be better if --reorder-goals always ranked goals with 0 or 1 valid choices, like warp:test, ahead of goals with more choices.

@kosmikus
Copy link
Contributor

@grayjay Sorry, only now looking.

I think it would be better if --reorder-goals always ranked goals with 0 or 1 valid choices, like warp:test, ahead of goals with more choices.

Isn't this exactly what --reorder-goals is doing? Or are you saying that this strategy interferes with other heuristics? If you're already set up to test this, could you try with my or your "count-conflicts" branch?

@grayjay
Copy link
Collaborator

grayjay commented May 27, 2016

@kosmikus --reorder-goals prefers goals with fewer choices, but only after many choices have been removed by the heuristics phase. PSQ.prefer and preferByKeys remove the non-preferred goals:

prefer :: (a -> Bool) -> PSQ k a -> PSQ k a
.

I tried your count-conflicts branch, and it finished in about 8 minutes. The final conflict set was aeson, base, bytestring, criterion, directory, doctest, ghc, hashable, http2, psqueues, time, unix, wai-extra, warp, warp-3.2.7:test, warp-3.2.7:bench.

@kosmikus
Copy link
Contributor

@grayjay Oh right. I had indeed discovered that in most of the cases where count-conflicts is still slow, the removal of choices in the heuristics phase is the culprit. I think we can/should fix this by switching to a scoring approach, as we've discussed elsewhere. Then we can more easily defer choices without completely removing them.

@snoyberg
Copy link
Collaborator Author

I'm unfamiliar with how the solver works internally and therefore have no
input, but just wanted to say thank you all for investing time in trying to
resolve this.

On Fri, May 27, 2016 at 10:25 AM, Andres Löh [email protected]
wrote:

@grayjay https://github.com/grayjay Oh right. I had indeed discovered
that in most of the cases where count-conflicts is still slow, the removal
of choices in the heuristics phase is the culprit. I think we can/should
fix this by switching to a scoring approach, as we've discussed elsewhere.
Then we can more easily defer choices without completely removing them.


You are receiving this because you authored the thread.
Reply to this email directly, view it on GitHub
#3453 (comment), or mute
the thread
https://github.com/notifications/unsubscribe/AADBB7SwJMelL5kWudhMj0uOEJn2Ydtyks5qFpxbgaJpZM4Ij_b1
.

@grayjay
Copy link
Collaborator

grayjay commented May 28, 2016

@kosmikus Yes, I think that would fix the issue. How will --reorder-goals interact with the goal ordering on your branch, or will it no longer be necessary?

@snoyberg No problem

@grayjay
Copy link
Collaborator

grayjay commented May 31, 2016

I looked into why warp:test is being deferred in the heuristics phase, as @kosmikus suggested. The behavior changed in #3092 and b502b7f.

#3092 added preferPackageStanzaPreferences, which sets stanza nodes to "weak" in order to defer them and allow tests/benchmarks to be disabled more easily when a dependency is unavailable:

in SChoiceF qsn gr True ts' -- True: now weak choice
. b502b7f changed deferWeakFlagChoices to handle stanzas as well as flags.

I think there is a bug in preferPackageStanzaPreferences, because it changes the stanza choice to "weak" even when the preference doesn't apply. But even when the preference does apply, the function causes the stanza to be deferred when a choice has already been made with --enable-tests. One option is to change deferWeakFlagChoices so that it only defers flags and stanzas when no choices have been disabled. But then it would depend on the step that enforces constraints, which would complicate things slightly.

I also noticed that the weak/trivial field on the stanza choice node has a different meaning in other parts of the code. Here it means that the stanza has no dependencies:

-- The Bool indicates whether it's trivial (see 'FChoice' for a discussion
-- of triviality).
| SChoice QSN a Bool (PSQ Bool (Tree a))

/cc @kosmikus @dcoutts

@kosmikus
Copy link
Contributor

@grayjay The fact that "weak" and "trivial" are mixed up is deliberate. In index conversion, trivial flags and stanzas should get the flag set. Later, it's only relevant for deferral, and since all trivial entities should be weak, it should be safe to set the flag for additional entities that we want to be deferred.

I think I agree that preferPackageStanzaPreferences makes too many stanza choices weak.

More generally, I think we should prefer rather than defer choices for which we know that at most a single option can be taken.

@phadej
Copy link
Collaborator

phadej commented Jun 29, 2016

https://github.com/dmwit/universe solving is quite slow with ghc-7.0.4, and takes ages with ghc-7.2.2. Example build: https://travis-ci.org/phadej/universe/builds/141199839

Let's see if your changes for this issue would improve universe situation as well.

EDIT:

@kosmikus
Copy link
Contributor

@phadej it seems that universe is nicely handled by count-conflicts-2 as it currently is, without any extra tweaks on how to (not) defer flags.

I didn't have 7.2.2 readily available, so I tested with 7.2.1 instead.

Here are times on my machine (with other things running next to it, so not overly reliable, but the relative speedup should be definitive enough): https://gist.github.com/kosmikus/c411abf4390dfd1adbcc16f6b665eb43

  • ghc-7.0.2 with --count-conflicts: 2.011s
  • ghc-7.0.2 with --no-count-conflicts: 160.397s
  • ghc-7.2.1 with --count-conflicts: 1.961s
  • ghc-7.2.1 with --no-count-conflicts: 988.347s

(I'm a bit surprised that you got 3m22s for 7.2.2. I didn't think my machine to be that slow.)

@phadej
Copy link
Collaborator

phadej commented Jun 30, 2016

@kosmikus, great to hear! (I haven't waited for ghc-7.2.2, all times were for ghc-7.0.2)

@kosmikus
Copy link
Contributor

@phadej I've finally turned this into a PR, so you can test it yourself if you like.

@grayjay
Copy link
Collaborator

grayjay commented Jul 5, 2016

This is fixed by #3480. I opened #3482 and #3488 to track the other issues that were brought up by this example.

@grayjay grayjay closed this as completed Jul 5, 2016
@ezyang ezyang modified the milestones: cabal-install 2.0, 2.0 (planned for next feature release) Sep 6, 2016
@ezyang ezyang removed this from the cabal-install 2.0 milestone Sep 6, 2016
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

6 participants