[GHC] #8095: TypeFamilies painfully slow

GHC ghc-devs at haskell.org
Thu Jan 24 19:58:27 UTC 2019


#8095: TypeFamilies painfully slow
-------------------------------------+-------------------------------------
        Reporter:  MikeIzbicki       |                Owner:  goldfire
            Type:  bug               |               Status:  new
        Priority:  high              |            Milestone:  8.8.1
       Component:  Compiler (Type    |              Version:  7.6.3
  checker)                           |
      Resolution:                    |             Keywords:  TypeFamilies
Operating System:  Unknown/Multiple  |         Architecture:
 Type of failure:  Compile-time      |  Unknown/Multiple
  performance bug                    |            Test Case:
      Blocked By:                    |             Blocking:
 Related Tickets:  #5321, #11598,    |  Differential Rev(s):  Phab:D3752,
  #12506, #13386                     |  Phab:D4766
       Wiki Page:                    |
-------------------------------------+-------------------------------------

Comment (by hussein.aitlahcen):

 Hello everyone,

 My team experience the same issue when using Squeal extensively
 (https://github.com/morphismtech/squeal).
 I found two things:
 - GHC is unfolding the exported types (a lot of type families involved) in
 the `.hi` file.
 - Stack is asking GHC to dump the `.hi` to know which module it has to
 rebuild
 (https://github.com/commercialhaskell/stack/blob/master/src/Stack/Build/Execute.hs#L1977).
 This exact thing is making GHC crazy, forcing him to dump a pretty printed
 3.5gb .txt (head of the file
 https://gist.githubusercontent.com/haitlahcen/3f1e83cdc78d48ed2100d51a0ea05844/raw/c49218be742cd3d2450a8f13683a04339b1ab9e7/hi.txt).

 Because of that, GHC was taking **12gb+** to compile some files. I found
 that omitting the interfaces pragmas with `-fomit-interface-pragmas` was
 helping a lot. In fact, no more unfolded type in the interface file,
 making the dumped .txt file going from **3.5gb** to **700kb** with a
 maximum allocated memory of **2.5gb**.

 I already patched Stack to stop asking for a dump and directly read the
 binary interface file (the startup time is greatly improved) and will
 probably push a PR.

 Finally, It looks like unfolding options for GHC does not apply to types
 (or I missed something?).
 I'm asking because of
 https://github.com/ghc/ghc/blob/886ddb27bfbbb52c41690cd29e2ab3ed80bf5450/compiler/coreSyn/CoreUnfold.hs#L583.
 Since we are now able to compute stuff at type level, it would be handy to
 be able to control the unfolding depending on the `typeLevelExprSize`.

 Thanks for reading

-- 
Ticket URL: <http://ghc.haskell.org/trac/ghc/ticket/8095#comment:58>
GHC <http://www.haskell.org/ghc/>
The Glasgow Haskell Compiler


More information about the ghc-tickets mailing list