#4138: Performance regression in overloading
---------------------------------+------------------------------------------
    Reporter:  simonmar          |        Owner:  simonpj                
        Type:  bug               |       Status:  new                    
    Priority:  high              |    Milestone:  6.14.1                 
   Component:  Compiler          |      Version:  6.13                   
    Keywords:                    |   Difficulty:                         
          Os:  Unknown/Multiple  |     Testcase:                         
Architecture:  Unknown/Multiple  |      Failure:  Runtime performance bug
---------------------------------+------------------------------------------
 The following program goes 25% slower with HEAD compared to 6.12.3:

 {{{
 module Main (main) where

 import DeepSeq

 main :: IO ()
 main = do
   rnf [ mk x | x <- [ 1 .. 1024 ] ] `seq` return ()
   where
     mk :: Float -> [(Float,Float)]
     mk x = [ (x+i,x+i+1) | i <- [ 1 .. 2048] ]
 }}}

 using the attached `DeepSeq` module, or indeed the standard
 `Control.DeepSeq`.

 Simon and I diagnosed the problem to be the following dictionary for
 `NFData (Float,Float)` (this is HEAD):

 {{{
 Main.main6 :: DeepSeq.NFData (GHC.Types.Float, GHC.Types.Float)
 Main.main6 =
   DeepSeq.$fNFData(,)
     @ GHC.Types.Float
     @ GHC.Types.Float
     DeepSeq.$fNFDataFloat
     DeepSeq.$fNFDataFloat
 }}}

 GHC has not inlined the dictionary function or the arguments here, even
 though this class is in fact just a single-method dictionary.  With 6.12
 we got:

 {{{
 Main.main6 =
   \ (ds_dBc :: (GHC.Types.Float, GHC.Types.Float)) ->
     case ds_dBc of _ { (x_awr, y_aws) ->
     case x_awr of _ { GHC.Types.F# _ ->
     case y_aws of _ { GHC.Types.F# _ -> GHC.Unit.() }
     }
     }
 }}}

 i.e. everything fully inlined and a nice efficient definition.

 This is currently affecting parallel programs where we typically use `rnf`
 quite a lot.

-- 
Ticket URL: <http://hackage.haskell.org/trac/ghc/ticket/4138>
GHC <http://www.haskell.org/ghc/>
The Glasgow Haskell Compiler
_______________________________________________
Glasgow-haskell-bugs mailing list
[email protected]
http://www.haskell.org/mailman/listinfo/glasgow-haskell-bugs

Reply via email to