[GHC] #10788: performance regression involving minimum (and maybe Vector)

GHC ghc-devs at haskell.org
Sun Aug 23 20:05:03 UTC 2015


#10788: performance regression involving minimum (and maybe Vector)
-------------------------------------+-------------------------------------
        Reporter:  rwbarton          |                   Owner:
            Type:  bug               |                  Status:  new
        Priority:  normal            |               Milestone:
       Component:  Compiler          |                 Version:  7.10.1
      Resolution:                    |                Keywords:
Operating System:  Unknown/Multiple  |            Architecture:
 Type of failure:  Runtime           |  Unknown/Multiple
  performance bug                    |               Test Case:
      Blocked By:                    |                Blocking:
 Related Tickets:                    |  Differential Revisions:
-------------------------------------+-------------------------------------

Comment (by rwbarton):

 It looks like more inlining happened in 7.10.1 at the definition site of
 `strictMinimum`, and the result was that the unfolding became too large
 for GHC to want to inline it at use sites.

 7.8.4:
 {{{
 Considering inlining: Data.List.strictMinimum
     arg infos [ValueArg, NonTrivArg]
     uf arity 2
     interesting continuation CaseCtxt
     some_benefit True
     is exp: True
     is work-free: True
     guidance IF_ARGS [30 30] 80 0
     discounted size = -10
     ANSWER = YES

   strictMinimum :: GHC.Classes.Ord a -> [a] -> a
     {- Arity: 2, Strictness: <L,1*U(A,A,A,A,A,A,A,1*C(C1(U)))><S,1*U>,
        Unfolding: (\ @ a $dOrd :: GHC.Classes.Ord a ds :: [a] ->
                    case ds of wild {
                      [] -> Data.List.minimum1 @ a
                      : ipv ipv1
                      -> Data.List.foldl'
                           @ a
                           @ a
                           (GHC.Classes.min @ a $dOrd)
                           ipv
                           ipv1 }) -}
 }}}

 7.10.1:
 {{{
 Considering inlining: strictMinimum
   arg infos [ValueArg, NonTrivArg]
   interesting continuation CaseCtxt
   some_benefit True
   is exp: True
   is work-free: True
   guidance IF_ARGS [30 30] 200 0
   discounted size = 110
   ANSWER = NO

   strictMinimum :: Ord a => [a] -> a
   {- Arity: 2, Strictness: <L,1*U(A,A,A,A,A,A,A,1*U)><S,1*U>,
      Unfolding: (\ @ a $dOrd :: Ord a ds :: [a] ->
                  case ds of wild {
                    [] -> minimum1 @ a
                    : ipv ipv1
                    -> let {
                         k :: a -> a -> a = min @ a $dOrd
                       } in
                       letrec {
                         go :: [a] -> a -> a {- Arity: 2, Strictness:
 <S,1*U><S,1*U> -}
                         = \ ds1 :: [a] eta :: a ->
                           case ds1 of wild1 {
                             [] -> eta : y ys -> case eta of z { DEFAULT ->
 go ys (k z y) } }
                       } in
                       go ipv1 ipv }) -}
 }}}

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


More information about the ghc-tickets mailing list