[GHC] #13253: Exponential compilation time with RWST & ReaderT stack with `-02`

GHC ghc-devs at haskell.org
Fri Jan 19 09:13:55 UTC 2018


#13253: Exponential compilation time with RWST & ReaderT stack with `-02`
-------------------------------------+-------------------------------------
        Reporter:  phadej            |                Owner:  bgamari, osa1
            Type:  bug               |               Status:  new
        Priority:  normal            |            Milestone:  8.4.1
       Component:  Compiler          |              Version:  8.0.1
      Resolution:                    |             Keywords:
Operating System:  Unknown/Multiple  |         Architecture:
 Type of failure:  Compile-time      |  Unknown/Multiple
  performance bug                    |            Test Case:
      Blocked By:                    |             Blocking:
 Related Tickets:                    |  Differential Rev(s):
       Wiki Page:                    |
-------------------------------------+-------------------------------------

Comment (by osa1):

 I checked Core outputs of gameteb generated with and without this patch.
 What happens with this patch is we don't inline some join points that
 allocates `Int`s, so we end up allocating more `Int`s than before.

 In gameteb project these files change with this patch:

 - InitTable
 - Output
 - Utils

 Changes in InitTable and Output do not cause any increase in allocations.
 In Utils we generate join points like this:

 {{{
 eIndx_s686 [Dmd=<L,U(U)>] :: Int
 [LclId]
 eIndx_s686
   = let {
       wild_a4If [Dmd=<L,U(U)>] :: Int
       [LclId, Unf=OtherCon []]
       wild_a4If = GHC.Types.I# 1# } in
     case logE_s687 of { GHC.Types.D# x_a364 ->
     case ergs of { GHC.Arr.Array l_a5Ty u_a5Tz dt_a5TA ds_a5TB ->
     case l_a5Ty of wild3_s6zo { GHC.Types.I# m_s6zp ->
     case u_a5Tz of wild4_s6zr { GHC.Types.I# n_s6zs ->
     join {
       $j_s68y [Dmd=<L,1*U(U)>] :: Int
       [LclId[JoinId(0)], Str=x]
       $j_s68y = exit_r6GT wild_a4If wild3_s6zo wild4_s6zr } in
     case GHC.Prim.<=# m_s6zp 1# of {
       __DEFAULT -> jump $j_s68y;
       1# -> ...
 }}}

 notice the `Int` allocation in `wild_a4If`, which is referenced by the
 join point.

 Without this patch, this code is simplified to:

 {{{
 eIndx_s68j [Dmd=<L,U(U)>] :: Int
 [LclId]
 eIndx_s68j
   = case logE_s68k of { GHC.Types.D# x_a362 ->
     case ergs of { GHC.Arr.Array l_a5TL u_a5TM dt_a5TN ds_a5TO ->
     case l_a5TL of wild2_s6zD { GHC.Types.I# m_s6zE ->
     case u_a5TM of wild3_s6zG { GHC.Types.I# n_s6zH ->
     case GHC.Prim.<=# m_s6zE 1# of {
       __DEFAULT -> exit_r6Hk 1# wild2_s6zD wild3_s6zG;
       1# -> ...
 }}}

 In this version the `exit` function called with `1#` instead of an `Int`.

 There are a few changes that all look like this.

 I tried running both versions with -ticky, but couldn't make sense of the
 output yet. I think the code explains the increase though so maybe we
 don't need -ticky output.

 I'll now look at what reduced allocationsin `mate`.

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


More information about the ghc-tickets mailing list