[GHC] #9583: Simplifier ticks exhausted while compiling Cabal HEAD

#9583: Simplifier ticks exhausted while compiling Cabal HEAD -------------------------------------+------------------------------------- Reporter: ezyang | Owner: Type: bug | Status: new Priority: highest | Milestone: Component: Compiler | Version: 7.9 Keywords: | Operating System: Architecture: Unknown/Multiple | Unknown/Multiple Difficulty: Unknown | Type of failure: Compile- Blocked By: | time crash Related Tickets: | Test Case: | Blocking: | Differential Revisions: -------------------------------------+------------------------------------- Steps to reproduce: 1. Clone Cabal HEAD 2. `cabal configure --with-ghc=/path/to/ghc-head` 3. `dist/setup/setup build` Actual results: {{{ [ 8 of 78] Compiling Distribution.Text ( Distribution/Text.hs, dist/build/Distribution/Text.o ) [ 9 of 78] Compiling Distribution.Version ( Distribution/Version.hs, dist/build/Distribution/Version.o ) ghc-stage2: panic! (the 'impossible' happened) (GHC version 7.9.20140911 for x86_64-unknown-linux): Simplifier ticks exhausted When trying UnfoldingDone GHC.Word.$fNumWord8_$c+ To increase the limit, use -fsimpl-tick-factor=N (default 100) If you need to do this, let GHC HQ know, and what factor you needed To see detailed counts use -ddump-simpl-stats Total ticks: 813720 Please report this as a GHC bug: http://www.haskell.org/ghc/reportabug }}} I know that it still fails with tick factor 4096; I haven't found a tick amount which makes it succeed. -- Ticket URL: http://ghc.haskell.org/trac/ghc/ticket/9583 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler

#9583: Simplifier ticks exhausted while compiling Cabal HEAD -------------------------------------+------------------------------------- Reporter: ezyang | Owner: Type: bug | Status: new Priority: highest | Milestone: Component: Compiler | Version: 7.9 Resolution: | Keywords: Operating System: | Architecture: Unknown/Multiple Unknown/Multiple | Difficulty: Unknown Type of failure: Compile- | Blocked By: time crash | Related Tickets: Test Case: | Blocking: | Differential Revisions: | -------------------------------------+------------------------------------- Comment (by simonpj): How do I "clone Cabal Head"? Perhaps {{{ git clone http://git.haskell.org/packages/Cabal.git }}} Just want to be sure we are talking about the same thing -- Ticket URL: http://ghc.haskell.org/trac/ghc/ticket/9583#comment:1 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler

#9583: Simplifier ticks exhausted while compiling Cabal HEAD -------------------------------------+------------------------------------- Reporter: ezyang | Owner: Type: bug | Status: new Priority: highest | Milestone: Component: Compiler | Version: 7.9 Resolution: | Keywords: Operating System: | Architecture: Unknown/Multiple Unknown/Multiple | Difficulty: Unknown Type of failure: Compile- | Blocked By: time crash | Related Tickets: Test Case: | Blocking: | Differential Revisions: | -------------------------------------+------------------------------------- Comment (by ezyang): Sorry, use the GitHub repo: {{{ git clone http://github.com/haskell/cabal.git }}} It also fails at tick factor 8192, and ran out of memory for me on the next power of two. Probably an infinite loop. -- Ticket URL: http://ghc.haskell.org/trac/ghc/ticket/9583#comment:2 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler

#9583: Simplifier ticks exhausted while compiling Cabal HEAD -------------------------------------+------------------------------------- Reporter: ezyang | Owner: Type: bug | Status: new Priority: highest | Milestone: Component: Compiler | Version: 7.9 Resolution: | Keywords: Operating System: | Architecture: Unknown/Multiple Unknown/Multiple | Difficulty: Unknown Type of failure: Compile- | Blocked By: time crash | Related Tickets: Test Case: | Blocking: | Differential Revisions: | -------------------------------------+------------------------------------- Comment (by hvr): Replying to [comment:2 ezyang]:
UPDATE: I just checked, both should work.
that's because github's master branch is automatically mirrored to our git.haskell.org copy of Cabal -- Ticket URL: http://ghc.haskell.org/trac/ghc/ticket/9583#comment:3 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler

#9583: Simplifier ticks exhausted while compiling Cabal HEAD -------------------------------------+------------------------------------- Reporter: ezyang | Owner: Type: bug | Status: new Priority: highest | Milestone: Component: Compiler | Version: 7.9 Resolution: | Keywords: Operating System: | Architecture: Unknown/Multiple Unknown/Multiple | Difficulty: Unknown Type of failure: Compile- | Blocked By: time crash | Related Tickets: Test Case: | Blocking: | Differential Revisions: | -------------------------------------+------------------------------------- Comment (by slyfox): I wonder if #9565 is of the same cause (smaller source file, but nastier). -- Ticket URL: http://ghc.haskell.org/trac/ghc/ticket/9583#comment:4 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler

#9583: Simplifier ticks exhausted while compiling Cabal HEAD -------------------------------------+------------------------------------- Reporter: ezyang | Owner: Type: bug | Status: new Priority: highest | Milestone: Component: Compiler | Version: 7.9 Resolution: | Keywords: Operating System: | Architecture: Unknown/Multiple Unknown/Multiple | Difficulty: Unknown Type of failure: Compile- | Blocked By: time crash | Related Tickets: Test Case: | Blocking: | Differential Revisions: | -------------------------------------+------------------------------------- Comment (by ezyang): I've reduced the test case example. It appears to be related to the Generic binary implementation: {{{ {-# LANGUAGE DeriveDataTypeable #-} {-# LANGUAGE DeriveGeneric #-} module Distribution.Version where import Data.Binary ( Binary(..) ) import Data.Data ( Data ) import Data.Typeable ( Typeable ) import GHC.Generics ( Generic ) data T = A | B | C T | D T T | E T T deriving (Data, Generic, Typeable) instance Binary T }}} -- Ticket URL: http://ghc.haskell.org/trac/ghc/ticket/9583#comment:5 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler

#9583: Simplifier ticks exhausted while compiling Cabal HEAD -------------------------------------+------------------------------------- Reporter: ezyang | Owner: Type: bug | Status: new Priority: highest | Milestone: Component: Compiler | Version: 7.9 Resolution: | Keywords: Operating System: | Architecture: Unknown/Multiple Unknown/Multiple | Difficulty: Unknown Type of failure: Compile- | Blocked By: time crash | Related Tickets: Test Case: | Blocking: | Differential Revisions: | -------------------------------------+------------------------------------- Comment (by JohnWiegley): Simon and I had a look at this, and we found a few more data points: 1. Manually implementing {{{get}}} and {{{put}}} for the instance, even if just to copy the default definitions, causes the test case above to pass. 2. The following data type also reproduces the problem: {{{ data T = A T T T T T T T T T T T T | B T deriving (Data, Typeable, Generic) }}} 3. If you implement {{{get}}} for the instance, but not {{{put}}}, the error still occurs; but the converse works. 4. If you set {{{put = gdmput}}}, and then define it in its own module, marking it INLINE works, but INLINEABLE fails: {{{ gdmput :: (Generic t, GBinary (Rep t)) => t -> Put gdmput = gput . from {-# INLINABLE gdmput #-} }}} 5. Displaying inlining information with {{{-ddump-inlinings -ddump-rule- firings}}} shows that after the first few unfoldings, the following repeats continually up until the failure. Increasing the tick cause simply causes more of this occurrence to display: {{{ Rule fired: Class op gput Rule fired: Class op gput Rule fired: Class op gput Rule fired: Class op gput Inlining done: Data.Binary.Generic.unTagged Inlining done: Data.Binary.Generic.unTagged1 Inlining done: GHC.Base.id Inlining done: GHC.Word.$fOrdWord64_$c<= Inlining done: GHC.Word.$fNumWord64_$c- Inlining done: Data.Binary.Generic.$fSumSizeM1_$csumSize Inlining done: Data.Binary.Generic.$fSumSizeM1_$csumSize Rule fired: plusWord# Inlining done: GHC.Word.$fBitsWord64_$cfromInteger Rule fired: integerToWord Rule fired: minusWord# Rule fired: leWord# Rule fired: tagToEnum# Inlining done: GHC.Word.$fBitsWord8_$cfromInteger Rule fired: integerToWord Rule fired: narrow8Word# Inlining done: Data.Binary.Generic.$fSumSizeM1_$csumSize Inlining done: Data.Binary.Generic.$fSumSizeM1_$csumSize Rule fired: plusWord# Inlining done: GHC.Base.id Rule fired: narrow8Word# Inlining done: GHC.Word.$fBitsWord8_$cshiftR Rule fired: >=# Rule fired: tagToEnum# Rule fired: uncheckedShiftRL# Rule fired: Class op putSum Inlining done: Data.Binary.Put.$fApplicativePutM_$c*> Inlining done: Data.Binary.Put.$fApplicativePutM2 Rule fired: Class op put Inlining done: Data.Binary.Put.putWord8 Inlining done: GHC.Base.$ Inlining done: GHC.Base.returnIO Inlining done: GHC.Base.returnIO1 Inlining done: GHC.Base.bindIO Inlining done: GHC.Base.bindIO1 Inlining done: GHC.Base.flip Inlining done: Foreign.Storable.$fStorableWord8_$cpoke Inlining done: Foreign.Storable.$fStorableWord19 Rule fired: Class op gput Inlining done: GHC.Word.$fNumWord8_$c+ Rule fired: plusWord# Rule fired: narrow8Word# Inlining done: GHC.Word.$fNumWord8_$c- Rule fired: minusWord# Rule fired: narrow8Word# Rule fired: Class op putSum Inlining done: Data.Binary.Put.$fApplicativePutM_$c*> Inlining done: Data.Binary.Put.$fApplicativePutM2 Rule fired: Class op put Inlining done: Data.Binary.Put.putWord8 Inlining done: GHC.Base.$ Inlining done: GHC.Base.returnIO Inlining done: GHC.Base.returnIO1 Inlining done: GHC.Base.bindIO Inlining done: GHC.Base.bindIO1 Inlining done: GHC.Base.flip Inlining done: Foreign.Storable.$fStorableWord8_$cpoke Inlining done: Foreign.Storable.$fStorableWord19 }}} -- Ticket URL: http://ghc.haskell.org/trac/ghc/ticket/9583#comment:6 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler

#9583: Simplifier ticks exhausted while compiling Cabal HEAD -------------------------------------+------------------------------------- Reporter: ezyang | Owner: Type: bug | Status: new Priority: highest | Milestone: Component: Compiler | Version: 7.9 Resolution: | Keywords: Operating System: | Architecture: Unknown/Multiple Unknown/Multiple | Difficulty: Unknown Type of failure: Compile- | Blocked By: time crash | Related Tickets: Test Case: | Blocking: | Differential Revisions: | -------------------------------------+------------------------------------- Comment (by ezyang): I'm going to try and bisect this problem. -- Ticket URL: http://ghc.haskell.org/trac/ghc/ticket/9583#comment:7 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler

#9583: Simplifier ticks exhausted while compiling Cabal HEAD
-------------------------------------+-------------------------------------
Reporter: ezyang | Owner:
Type: bug | Status: new
Priority: highest | Milestone:
Component: Compiler | Version: 7.9
Resolution: | Keywords:
Operating System: | Architecture: Unknown/Multiple
Unknown/Multiple | Difficulty: Unknown
Type of failure: Compile- | Blocked By:
time crash | Related Tickets:
Test Case: |
Blocking: |
Differential Revisions: |
-------------------------------------+-------------------------------------
Comment (by ezyang):
Bisection finished, the bad commit is this one:
{{{
b9e49d3e9580e13d89efd1f779cb76f610e0d6e0 is the first bad commit
[4/1912]
commit b9e49d3e9580e13d89efd1f779cb76f610e0d6e0
Author: Simon Peyton Jones

#9583: Simplifier ticks exhausted while compiling Cabal HEAD -------------------------------------+------------------------------------- Reporter: ezyang | Owner: Type: bug | Status: new Priority: highest | Milestone: Component: Compiler | Version: 7.9 Resolution: | Keywords: Operating System: | Architecture: Unknown/Multiple Unknown/Multiple | Difficulty: Unknown Type of failure: Compile- | Blocked By: time crash | Related Tickets: Test Case: | Blocking: | Differential Revisions: | -------------------------------------+------------------------------------- Comment (by simonpj): I thought this was going to be very complicated but it turned out to be very simple! The occurrence analyser does something called "glomming" if the application of imported RULES means that something that didn't look recursive becomes recursive. See `Note [Glomming]` in `OccurAnal`. Under these circumstances we group all the top-level bindings into a single massive `Rec`. But, crucially, I failed to repeat the occurrence analysis on this glommed set of bindings. That means that we weren't establishing the right loop breakers (indeed there were no loop breakers whatsoever), and that led immediately to the loop. The only surprising this is that it didn't happen before. Patch coming Simon -- Ticket URL: http://ghc.haskell.org/trac/ghc/ticket/9583#comment:9 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler

#9583: Simplifier ticks exhausted while compiling Cabal HEAD -------------------------------------+------------------------------------- Reporter: ezyang | Owner: Type: bug | Status: new Priority: highest | Milestone: Component: Compiler | Version: 7.9 Resolution: | Keywords: Operating System: | Architecture: Unknown/Multiple Unknown/Multiple | Difficulty: Unknown Type of failure: Compile- | Blocked By: time crash | Related Tickets: Test Case: | Blocking: | Differential Revisions: | -------------------------------------+------------------------------------- Comment (by hvr): Replying to [comment:9 simonpj]:
Patch coming
any ETA on that patch? It's blocking a few things right now... :-) -- Ticket URL: http://ghc.haskell.org/trac/ghc/ticket/9583#comment:10 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler

#9583: Simplifier ticks exhausted while compiling Cabal HEAD
-------------------------------------+-------------------------------------
Reporter: ezyang | Owner:
Type: bug | Status: new
Priority: highest | Milestone:
Component: Compiler | Version: 7.9
Resolution: | Keywords:
Operating System: | Architecture: Unknown/Multiple
Unknown/Multiple | Difficulty: Unknown
Type of failure: Compile- | Blocked By:
time crash | Related Tickets:
Test Case: |
Blocking: |
Differential Revisions: |
-------------------------------------+-------------------------------------
Comment (by Simon Peyton Jones

#9583: Simplifier ticks exhausted while compiling Cabal HEAD -------------------------------------+------------------------------------- Reporter: ezyang | Owner: Type: bug | Status: new Priority: highest | Milestone: Component: Compiler | Version: 7.9 Resolution: | Keywords: Operating System: | Architecture: Unknown/Multiple Unknown/Multiple | Difficulty: Unknown Type of failure: Compile- | Blocked By: time crash | Related Tickets: Test Case: | Blocking: | Differential Revisions: | -------------------------------------+------------------------------------- Comment (by simonpj): I've just pushed it. I'm getting a failure on `perf/compiler/T783`, but as usual I'm uncertain about whether the patch is the culprit or not. I suspect not, so since it's a blocker I'm pushing it anyway. Simon -- Ticket URL: http://ghc.haskell.org/trac/ghc/ticket/9583#comment:12 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler

#9583: Simplifier ticks exhausted while compiling Cabal HEAD
-------------------------------------+-------------------------------------
Reporter: ezyang | Owner:
Type: bug | Status: new
Priority: highest | Milestone:
Component: Compiler | Version: 7.9
Resolution: | Keywords:
Operating System: | Architecture: Unknown/Multiple
Unknown/Multiple | Difficulty: Unknown
Type of failure: Compile- | Blocked By:
time crash | Related Tickets:
Test Case: |
Blocking: |
Differential Revisions: |
-------------------------------------+-------------------------------------
Comment (by Simon Peyton Jones

#9583: Simplifier ticks exhausted while compiling Cabal HEAD -------------------------------------+------------------------------------- Reporter: ezyang | Owner: Type: bug | Status: new Priority: highest | Milestone: Component: Compiler | Version: 7.9 Resolution: | Keywords: Operating System: | Architecture: Unknown/Multiple Unknown/Multiple | Difficulty: Unknown Type of failure: Compile- | Blocked By: time crash | Related Tickets: Test Case: | Blocking: | Differential Revisions: | -------------------------------------+------------------------------------- Changes (by simonpj): * cc: dreixel (added) Comment: Perhaps someone can confirm that Cabal is ok, and then close. Pedro: the "deriving Binary" stuff still generates a gargantuan quantity of code! Simon -- Ticket URL: http://ghc.haskell.org/trac/ghc/ticket/9583#comment:14 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler

#9583: Simplifier ticks exhausted while compiling Cabal HEAD -------------------------------------+------------------------------------- Reporter: ezyang | Owner: Type: bug | Status: new Priority: highest | Milestone: Component: Compiler | Version: 7.9 Resolution: | Keywords: Operating System: | Architecture: Unknown/Multiple Unknown/Multiple | Difficulty: Unknown Type of failure: Compile- | Blocked By: time crash | Related Tickets: Test Case: | Blocking: | Differential Revisions: | -------------------------------------+------------------------------------- Comment (by hvr): Replying to [comment:12 simonpj]:
I've just pushed it. I'm getting a failure on `perf/compiler/T783`, but as usual I'm uncertain about whether the patch is the culprit or not. I suspect not, so since it's a blocker I'm pushing it anyway.
fwiw, Phab:harbormaster/build/952 built just fine (but that's for Linux/x86_64 thresholds) -- Ticket URL: http://ghc.haskell.org/trac/ghc/ticket/9583#comment:15 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler

#9583: Simplifier ticks exhausted while compiling Cabal HEAD -------------------------------------+------------------------------------- Reporter: ezyang | Owner: Type: bug | Status: new Priority: highest | Milestone: Component: Compiler | Version: 7.9 Resolution: | Keywords: Operating System: | Architecture: Unknown/Multiple Unknown/Multiple | Difficulty: Unknown Type of failure: Compile- | Blocked By: time crash | Related Tickets: Test Case: | Blocking: | Differential Revisions: | -------------------------------------+------------------------------------- Comment (by hvr): Replying to [comment:14 simonpj]:
Perhaps someone can confirm that Cabal is ok, and then close.
Pedro: the "deriving Binary" stuff still generates a gargantuan quantity of code!
Compiling Cabal within the GHC tree is not really ok (see comments in Phab:D183). It does compile, but it takes *several* minutes as well as massive amount of memory (over 50% of the 4GiB mem available in the buildbot, causing it to fail w/ an out-of-mem exception since we build mit CPUS=4) to when trying to produce the `libraries/Cabal/Cabal/dist- install/build/Language/Haskell/Extension.o` module with `ghc-stage1` -- Ticket URL: http://ghc.haskell.org/trac/ghc/ticket/9583#comment:16 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler

#9583: Simplifier ticks exhausted while compiling Cabal HEAD -------------------------------------+------------------------------------- Reporter: ezyang | Owner: Type: bug | Status: new Priority: highest | Milestone: Component: Compiler | Version: 7.9 Resolution: | Keywords: Operating System: | Architecture: Unknown/Multiple Unknown/Multiple | Difficulty: Unknown Type of failure: Compile- | Blocked By: time crash | Related Tickets: Test Case: | Blocking: | Differential Revisions: | -------------------------------------+------------------------------------- Comment (by simonpj): Well this ticket was about a bug in GHC that meant it really didn't compile *at all*. Now, from what you say, it does. But there may still be a problem with the amount of code that `deriving Binary` generates (hence copying Pedro), perhaps due to nested tuples (which might be helped by the new SOP approach) or perhaps due to over-enthusiastic INLINE pragmas. In any case, I don't think there's a bug in GHC any more. But I'll leave this ticket open in the hope that we may make progress on the `deriving Binary` question. Simon -- Ticket URL: http://ghc.haskell.org/trac/ghc/ticket/9583#comment:17 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler

#9583: Simplifier ticks exhausted while compiling Cabal HEAD -------------------------------------+------------------------------------- Reporter: ezyang | Owner: Type: bug | Status: new Priority: highest | Milestone: Component: Compiler | Version: 7.9 Resolution: | Keywords: Operating System: | Architecture: Unknown/Multiple Unknown/Multiple | Difficulty: Unknown Type of failure: Compile- | Blocked By: time crash | Related Tickets: #9630 Test Case: | Blocking: | Differential Revisions: | -------------------------------------+------------------------------------- Changes (by hvr): * related: => #9630 Comment: I've created a new ticket for the performance regression over at #9630 to separate concerns a bit -- Ticket URL: http://ghc.haskell.org/trac/ghc/ticket/9583#comment:18 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler

#9583: Simplifier ticks exhausted while compiling Cabal HEAD -------------------------------------+------------------------------------- Reporter: ezyang | Owner: Type: bug | Status: closed Priority: highest | Milestone: Component: Compiler | Version: 7.9 Resolution: fixed | Keywords: Operating System: | Architecture: Unknown/Multiple Unknown/Multiple | Difficulty: Unknown Type of failure: Compile- | Blocked By: time crash | Related Tickets: #9630 Test Case: | Blocking: | Differential Revisions: | -------------------------------------+------------------------------------- Changes (by simonpj): * status: new => closed * resolution: => fixed Comment: In which case we can close this one. -- Ticket URL: http://ghc.haskell.org/trac/ghc/ticket/9583#comment:19 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler
participants (1)
-
GHC