#650: Improve interaction between mutable arrays and GC
--------------------------------------+-------------------------------------
  Reporter:  simonmar                 |          Owner:  simonmar        
      Type:  bug                      |         Status:  new             
  Priority:  normal                   |      Milestone:  6.12.2          
 Component:  Runtime System           |        Version:  6.4.1           
Resolution:                           |       Keywords:                  
Difficulty:  Difficult (2-5 days)     |             Os:  Unknown/Multiple
  Testcase:                           |   Architecture:  Unknown/Multiple
   Failure:  Runtime performance bug  |  
--------------------------------------+-------------------------------------
Changes (by simonmar):

  * milestone:  6.14.1 => 6.12.2

Comment:

 Fixed:

 {{{
 Thu Dec 17 14:42:28 PST 2009  Simon Marlow <[email protected]>
   * Fix #650: use a card table to mark dirty sections of mutable arrays
   The card table is an array of bytes, placed directly following the
   actual array data.  This means that array reading is unaffected, but
   array writing needs to read the array size from the header in order to
   find the card table.

   We use a bytemap rather than a bitmap, because updating the card table
   must be multi-thread safe.  Each byte refers to 128 entries of the
   array, but this is tunable by changing the constant
   MUT_ARR_PTRS_CARD_BITS in includes/Constants.h.

     M ./compiler/codeGen/CgPrimOp.hs -2 +14
     M ./includes/Cmm.h +3
     M ./includes/HaskellConstants.hs +3
     M ./includes/mkDerivedConstants.c +1
     M ./includes/rts/Constants.h +7
     M ./includes/rts/storage/ClosureMacros.h -1 +29
     M ./includes/rts/storage/Closures.h +2
     M ./rts/PrimOps.cmm -5 +23
     M ./rts/Weak.c -2 +9
     M ./rts/sm/Scav.c -54 +123
 }}}

 I benchmarked this program, amongst others:

 {{{
 import Control.Monad
 import qualified Data.HashTable as H
 import System.Environment

 main = do
   [size] <- fmap (fmap read) getArgs
   m <- H.new (==) H.hashInt
   forM_ [1..size] $ \n -> H.insert m n n
   v <- H.lookup m 100
   print v
 }}}

 for size=1000000, with 6.12.1 it takes around 50s on my x86/Linux laptop,
 with the HEAD and this patch it takes 9.5s.

 We could merge this into 6.12.2 after more testing and benchmarking, as
 the changes are fairly localised.

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