[GHC] #8326: Place heap checks common in case alternatives before the case

GHC ghc-devs at haskell.org
Tue Aug 4 08:45:38 UTC 2015


#8326: Place heap checks common in case alternatives before the case
-------------------------------------+-------------------------------------
        Reporter:  jstolarek         |                   Owner:
            Type:  task              |                  Status:  new
        Priority:  normal            |               Milestone:
       Component:  Compiler          |                 Version:  7.7
      Resolution:                    |                Keywords:
Operating System:  Unknown/Multiple  |            Architecture:
 Type of failure:  Runtime           |  Unknown/Multiple
  performance bug                    |               Test Case:
      Blocked By:                    |                Blocking:  8317
 Related Tickets:  #1498             |  Differential Revisions:  Phab:D343
-------------------------------------+-------------------------------------

Comment (by simonpj):

 Good point.  Trying that is an excellent idea.   Note that in a tree of
 (primop) conditionals, if even one branch allocates, then we'll do a heap
 check in all cases.

 It might be interesting to gather the following statistic in ticky-ticky
 profiling
  * Total number of heap checks
  * Total number of times that `Hp` is wound back to zero. This winding
 back is done by `adjustHpBackwards`.  You can tell if you are winding back
 to zero because `vHp` is zero.

 If we wind back to zero, that means that we allocated nothing, so the
 original heap check was wasted.  Then we can see what proportion of heap
 checks are wasted.

 I guess the worry is that this might happen a lot in some hot inner loop,
 but let's see.

 Thanks for doing this.  If it looks reasonable it'd be a much simpler
 cleaner solution.

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


More information about the ghc-tickets mailing list