[GHC] #6082: Program compiled with 7.4.1 runs many times slower than compiled with 7.2.2

GHC cvs-ghc at haskell.org
Wed Jul 18 15:53:52 CEST 2012


#6082: Program compiled with 7.4.1 runs many times slower than compiled with 7.2.2
--------------------------------------+-------------------------------------
  Reporter:  gchrupala                |          Owner:  simonpj         
      Type:  bug                      |         Status:  new             
  Priority:  high                     |      Milestone:  7.4.3           
 Component:  libraries (other)        |        Version:  7.4.1           
Resolution:                           |       Keywords:                  
        Os:  Unknown/Multiple         |   Architecture:  Unknown/Multiple
   Failure:  Runtime performance bug  |     Difficulty:  Unknown         
  Testcase:                           |      Blockedby:                  
  Blocking:                           |        Related:                  
--------------------------------------+-------------------------------------

Comment(by milan):

 I am not a specialist, but considering the code
 {{{
 module Data.Array.MArray
   {-# INLINE unsafeFreeze #-}
   unsafeFreeze :: (Ix i, MArray a e m, IArray b e) => a i e -> m (b i e)
   unsafeFreeze = Data.Array.Base.unsafeFreeze

 module Data.Array.Unsafe
   (exports Data.Array.Base.unsafeFreeze)

 module Data.Array.Base
   {-# INLINE unsafeFreeze #-}
   unsafeFreeze :: (Ix i, MArray a e m, IArray b e) => a i e -> m (b i e)
   unsafeFreeze = freeze

   {-# RULES
   "unsafeFreeze/STArray"  unsafeFreeze = ArrST.unsafeFreezeSTArray
   "unsafeFreeze/STUArray" unsafeFreeze = unsafeFreezeSTUArray
   #-}
 }}}
 then when calling Data.Array.Base.unsafeFreeze, RULES have chance to fire
 before the INLINing happen. But when calling
 Data.Array.MArray.unsafeFreeze, RULES do not fire (as they fire only on
 Data.Array.Base.unsafeFreeze) and then '''both''' INLINing happen at once,
 replacing the Data.Array.MArray.unsafeFreeze by Data.Array.Base.freeze.

 When the Data.Array.Base module postpones the INLINing of unsafeFreeze to
 phase 1, as in
 {{{
 module Data.Array.Base
   {-# INLINE[1] unsafeFreeze #-}
   unsafeFreeze :: (Ix i, MArray a e m, IArray b e) => a i e -> m (b i e)
   unsafeFreeze = freeze
 }}}
 everything works as expected.

 I am not a RULES expert, so I do not know, what the right behaviour is. In
 a situation like this:
 {{{
 {-# INLINE f #-}
 f = g

 {-# INLINE g #-}
 g = h
 {-# RULES "g/gspec" g = gspec #-}
 }}}
 is f expected to be rewrittenn to h or gspec? In our array situation, GHC
 follows the f -> g -> h path.

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



More information about the Glasgow-haskell-bugs mailing list