Skip to content

Expensive assertion in Distribution.Solver.Modular.Linking #4258

Closed

Description

@sebright

The assertion at

assert (lgInvariant $ vsLinks st) $ return ()
makes the solver run slowly when there are many setup dependencies, especially with --reorder-goals. Solving for jsaddle-warp with new-build is a good example (See #4192 (comment)). When I ran cabal new-build jsaddle-warp --dry-run with GHC 8.0.1, it took almost nine minutes with the assertion and about eight seconds without.

I didn't see any obvious ways to improve the performance. However, even if we minimized the effect of assertions on runtime, assertions could still affect performance measurements during development. It's easy to accidentally compare a cabal executable with assertions enabled to one without assertions.

I'm not sure of the best solution. Here are some ideas:

  • Remove ghc-options: -fno-ignore-asserts from cabal.project and then enable assertions for unit tests in CI.
  • Add another build flag to control just the expensive assertions, and turn them on in CI. Other assertions would be enabled in cabal.project.
  • Print a warning when assertions are enabled.

Activity

  1. ezyang commented on Jan 23, 2017

    @ezyang
    Contributor

    The way that GHC's RTS handles expensive asserts is like (2): by default they are not turned on, but if you turn on a "sanity" mode it will start running with them. The RTS asserts are toggleable at runtime but that will probably be inconvenient to do in the solver unless we're threading around some solver environment (maybe we are?)

  2. 23Skidoo commented on Jan 23, 2017

    @23Skidoo
    Member

    Print a warning when assertions are enabled.

    We should definitely do that at least.

  3. added 3 commits that reference this issue on Feb 20, 2017
    95a2cdb
    55354c1
    debc838
  4. sebright commented on Feb 20, 2017

    @sebright
    CollaboratorAuthor

    Thanks for the feedback. I added a build flag in #4346 so that it would be easy to call the conditional assert from anywhere in cabal-install.

    I think it would also be useful to warn when assertions are enabled. I'm not sure where we should put the warning, though.

  5. added a commit that references this issue on Feb 21, 2017
    ab5257c
  6. added a commit that references this issue on Feb 22, 2017
    7a4f0c1
  7. added a commit that references this issue on Feb 22, 2017
    b129a06
  8. sebright commented on Mar 6, 2017

    @sebright
    CollaboratorAuthor

    Print a warning when assertions are enabled.

    We should definitely do that at least.

    I opened a new issue: #4377

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions