[GHC] #11735: Optimize coercionKind

GHC ghc-devs at haskell.org
Wed Jan 24 19:36:23 UTC 2018


#11735: Optimize coercionKind
-------------------------------------+-------------------------------------
        Reporter:  goldfire          |                Owner:  (none)
            Type:  task              |               Status:  new
        Priority:  normal            |            Milestone:
       Component:  Compiler          |              Version:  7.10.3
      Resolution:                    |             Keywords:
Operating System:  Unknown/Multiple  |         Architecture:
 Type of failure:  Compile-time      |  Unknown/Multiple
  performance bug                    |            Test Case:
      Blocked By:                    |             Blocking:
 Related Tickets:                    |  Differential Rev(s):
       Wiki Page:                    |
-------------------------------------+-------------------------------------

Comment (by tdammers):

 Oh, and also this note further up:

 {{{
 Note [Computing a coercion kind and role]
 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
 To compute a coercion's kind is straightforward: see coercionKind.
 But to compute a coercion's role, in the case for NthCo we need
 its kind as well.  So if we have two separate functions (one for kinds
 and one for roles) we can get exponentially bad behaviour, since each
 NthCo node makes a separate call to coercionKind, which traverses the
 sub-tree again.  This was part of the problem in Trac #9233.

 Solution: compute both together; hence coercionKindRole.  We keep a
 separate coercionKind function because it's a bit more efficient if
 the kind is all you want.
 }}}

 Which leads me to believe that maybe this particular input I'm testing
 doesn't hit the `NthCo` branch enough to make a dent there, and thus fares
 better with the separated-out implementation, but other code might.

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


More information about the ghc-tickets mailing list