-
Notifications
You must be signed in to change notification settings - Fork 711
Expensive assertion in Distribution.Solver.Modular.Linking #4258
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
Comments
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?) |
We should definitely do that at least. |
I added a build flag, 'debug-assertions', and a function, 'debugAssert'. 'debugAssert' only calls 'assert' when the flag is enabled. I only replaced one call to 'assert' so far (in Distribution.Solver.Modular.Linking) in order to resolve haskell#4258.
I added a function, 'debugAssert', that wraps 'assert' and only calls it when the build flag 'debug-assertions' is enabled. The flag defaults to false. I only replaced one call to 'assert' so far (in Distribution.Solver.Modular.Linking) in order to resolve haskell#4258.
I added a function, 'debugAssert', that wraps 'assert' and only calls it when the build flag 'debug-assertions' is enabled. The flag defaults to false. I only replaced one call to 'assert' so far (in Distribution.Solver.Modular.Linking) in order to resolve haskell#4258.
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. |
I added a function, 'debugAssert', that wraps 'assert' and only calls it when the build flag 'debug-assertions' is enabled. The flag defaults to false. I only replaced one call to 'assert' so far (in Distribution.Solver.Modular.Linking) in order to resolve #4258.
I added a function, 'debugAssert', that wraps 'assert' and only calls it when the build flag 'debug-assertions' is enabled. The flag defaults to false. I only replaced one call to 'assert' so far (in Distribution.Solver.Modular.Linking) in order to resolve haskell#4258. (cherry picked from commit ab5257c)
I opened a new issue: #4377 |
The assertion at
cabal/cabal-install/Distribution/Solver/Modular/Linking.hs
Line 138 in 6d993e2
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:
ghc-options: -fno-ignore-asserts
from cabal.project and then enable assertions for unit tests in CI.The text was updated successfully, but these errors were encountered: