[GHC] #9067: Optimize clearNursery by short-circuiting when we get to currentNursery

GHC ghc-devs at haskell.org
Sat May 3 01:04:25 UTC 2014


#9067: Optimize clearNursery by short-circuiting when we get to currentNursery
------------------------------+--------------------------------------------
       Reporter:  ezyang      |             Owner:  ezyang
           Type:  task        |            Status:  new
       Priority:  low         |         Milestone:
      Component:  Runtime     |           Version:  7.9
  System                      |  Operating System:  Unknown/Multiple
       Keywords:              |   Type of failure:  Runtime performance bug
   Architecture:              |         Test Case:
  Unknown/Multiple            |          Blocking:
     Difficulty:  Unknown     |
     Blocked By:              |
Related Tickets:              |
------------------------------+--------------------------------------------
 This is a note to myself so I don't forget about this. Essentially, we can
 do something like this (this particular patch variant untested):

 {{{
 diff --git a/rts/sm/Storage.c b/rts/sm/Storage.c
 index 36776b9..0311042 100644
 --- a/rts/sm/Storage.c
 +++ b/rts/sm/Storage.c
 @@ -598,6 +598,11 @@ clearNursery (Capability *cap)
          ASSERT(bd->gen_no == 0);
          ASSERT(bd->gen == g0);
          IF_DEBUG(sanity,memset(bd->start, 0xaa, BLOCK_SIZE));
 +        if (bd == cap->r.rCurrentNursery) {
 +            IF_DEBUG(sanity, for (bd = bd->link; bd; bd = bd->link)
 +                                ASSERT(bd->free == bd->start));
 +            break;
 +        }
      }
      }
  }
 }}}

 This is due to invariants about how we manage the currentNursery pointer.
 But we need a note about it, and I need to test it more carefully. This
 optimization probably doesn't help too much on normal GHC, but when I have
 lots of nurseries it helps quite a bit.

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


More information about the ghc-tickets mailing list