[GHC] #14610: newtype wrapping of a monadic stack kills performance

GHC ghc-devs at haskell.org
Tue Jan 2 15:06:07 UTC 2018


#14610: newtype wrapping of a monadic stack kills performance
-------------------------------------+-------------------------------------
        Reporter:  mrkkrp            |                Owner:  (none)
            Type:  bug               |               Status:  new
        Priority:  normal            |            Milestone:  8.6.1
       Component:  Compiler          |              Version:  8.2.2
      Resolution:                    |             Keywords:  JoinPoints
Operating System:  Unknown/Multiple  |         Architecture:
 Type of failure:  Runtime           |  Unknown/Multiple
  performance bug                    |            Test Case:
      Blocked By:                    |             Blocking:
 Related Tickets:  #14620            |  Differential Rev(s):
       Wiki Page:                    |
-------------------------------------+-------------------------------------

Comment (by simonpj):

 Good example.  But it fails the `isValidJoinPointType` test (c.f. #14620),
 so even if
 we roped the `markAllNonTailCalled` in the `Cast` case of occurrence-
 analysis, we
 would not get `go` as a join point.  And indeed that's not unreasonable.
 Consider
 {{{
 case  ( letrec go n m ds m2 = case ds of                   )
       (                          FX co -> m2 |> (...co..)  )
       (                          FS ... -> (go ...) |> co2 )
       ( in go t1 t2 a b                                    ) of
   BLAH
 }}}
 Operationally we have a join point, but the transformation to move
 that case inwards would give this
 {{{
 letrec go n m ds m2 = case ds of
                          FX co -> case m2 |> (...co..) of BLAH
                          FS ... -> (go ...) |> co2
 in go t1 t2 a b
 }}}
 but now the outer case is scrutinising something involving n, m etc,
 which makes no sense.

 Operationally the transformation makes sense, but it's not well typed.  I
 have no idea how to fix this.

 We still have no example of a program that has a cast in the return (and
 and hence might benefit from dropping the `makrAllNonTailCalled`) but
 which passes the `isValidJoinPointType` test.

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


More information about the ghc-tickets mailing list