[GHC] #9233: Compiler performance regression

GHC ghc-devs at haskell.org
Mon Jul 7 23:48:00 UTC 2014


#9233: Compiler performance regression
---------------------------------+------------------------------------
        Reporter:  augustss      |            Owner:
            Type:  bug           |           Status:  new
        Priority:  low           |        Milestone:
       Component:  Compiler      |          Version:  7.8.2
      Resolution:                |         Keywords:
Operating System:  Windows       |     Architecture:  Unknown/Multiple
 Type of failure:  None/Unknown  |       Difficulty:  Unknown
       Test Case:                |       Blocked By:
        Blocking:                |  Related Tickets:
---------------------------------+------------------------------------

Comment (by rwbarton):

 The following patch reduces compile time for Lennart's program to 15s
 (compare 9s 7.6.3, 25s 7.8.1, 18s with my previous patch):
 {{{
 diff --git a/compiler/types/Coercion.lhs b/compiler/types/Coercion.lhs
 index b33eae9..1417ad7 100644
 --- a/compiler/types/Coercion.lhs
 +++ b/compiler/types/Coercion.lhs
 @@ -1033,6 +1033,7 @@ mkNthCo n (Refl r ty) = ASSERT( ok_tc_app ty n )
                          Refl r' (tyConAppArgN n ty)
    where tc = tyConAppTyCon ty
          r' = nthRole r tc n
 +mkNthCo n (TyConAppCo _ _ cos) = cos !! n
  mkNthCo n co        = ASSERT( ok_tc_app _ty1 n && ok_tc_app _ty2 n )
                        NthCo n co
                      where
 }}}
 Richard, does this look okay to you (modulo error handling—is it possible
 that `n >= length cos`?)? I am emboldened by this equation from
 !OptCoercion
 {{{
 opt_co' env sym mrole (NthCo n (TyConAppCo _ _ cos))
   = opt_co env sym mrole (getNth cos n)
 }}}
 but cautious due to the comment above it.

 The simplifier was somehow building up a hugely nested coercion `(Nth:1
 (Nth:1 (Nth:1 (... (<String>_R -> <Bool>_R -> <Bool>_R -> ... -> <Bool>_R
 -> Sym (Identity.NTCo:Identity[0] <Options>_R))...))))`.

 After this patch, the slowdown from 7.6 to 7.8 on Lennart's program is in
 line with what I see on other modules. There is still a signification
 regression overall, but this program was particularly bad.

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


More information about the ghc-tickets mailing list