#5068: Possible loss of sharing: big performance change
---------------------------------+------------------------------------------
    Reporter:  simonpj           |        Owner:              
        Type:  bug               |       Status:  new         
    Priority:  normal            |    Milestone:  7.4.1       
   Component:  Compiler          |      Version:  7.0.3       
    Keywords:                    |     Testcase:              
   Blockedby:                    |   Difficulty:              
          Os:  Unknown/Multiple  |     Blocking:              
Architecture:  Unknown/Multiple  |      Failure:  None/Unknown
---------------------------------+------------------------------------------

Comment(by simonpj):

 Oh, now I understand.  You have something like this:
 {{{
 {-# INLINE bad #-}
 bad n = let k = fib 200
         in n + k
 }}}
 And GHC does exactly what you ask, replacing every call `(bad e)` with
 `(let k = fib 200 in e + k)`.  So the `(fib 200)` gets done once per call
 of `bad`.   Fair enough.  If you didn't have an INLINE pragma, GHC's full
 laziness transformation would lift out that constant expression, but
 INLINE (by design) does exactly what it says on the tin.

 However I'm stil surprised you get such a massive slow-down.  You'll get
 one call to `(fib 200)` per call of `bad` ''in the program text''; ie only
 a fixed increment on execution time.  For exmaple, if the call to `bad`
 was in a loop, the call to `(fib 200)` should then be lifted out of the
 loop:
 {{{
 loop 0 = 0
 loop n = bad n + loop (n-1)

 ===>  after inlining

 loop 0 = 0
 loop n = let k = fib 200 in n + k + loop (n-1)

 ===>  full laziness

 k = fib 200
 loop 0 = 0
 loop n = n + k + loop (n-1)
 }}}
 Moreover (and separately) I don't see how your changeset (linked above)
 would affect this behaviour.

 So there is still a mystery here.

 Simon

-- 
Ticket URL: <http://hackage.haskell.org/trac/ghc/ticket/5068#comment:4>
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