[project @ 2006-01-17 16:03:47 by simonmar]
authorsimonmar <unknown>
Tue, 17 Jan 2006 16:03:47 +0000 (16:03 +0000)
committersimonmar <unknown>
Tue, 17 Jan 2006 16:03:47 +0000 (16:03 +0000)
commitda69fa9c5047c5b0d05bdb05eaddefa1eb5d5a36
treee36c0dbe532aa64733194420ff9b0dd96359e7f6
parentba41623270c1d541e74bd5182e1b4fcbe99809cc
[project @ 2006-01-17 16:03:47 by simonmar]
Improve the GC behaviour of IOArrays/STArrays

See Ticket #650

This is a small change to the way mutable arrays interact with the GC,
that can have a dramatic effect on performance, and make tricks with
unsafeThaw/unsafeFreeze redundant.  Data.HashTable should be faster
now (I haven't measured it yet).

We now have two mutable array closure types, MUT_ARR_PTRS_CLEAN and
MUT_ARR_PTRS_DIRTY.  Both are on the mutable list if the array is in
an old generation.  writeArray# sets the type to MUT_ARR_PTRS_DIRTY.
The garbage collector can set the type to MUT_ARR_PTRS_CLEAN if it
finds that no element of the array points into a younger generation
(discovering this required a small addition to evacuate(), but rough
tests indicate that it doesn't measurably affect performance).

NOTE: none of this affects unboxed arrays (IOUArray/STUArray), only
boxed arrays (IOArray/STArray).

We could go further and extend the DIRTY bit to be per-block rather
than for the whole array, but for now this is an easy improvement.
14 files changed:
ghc/compiler/cmm/CLabel.hs
ghc/compiler/codeGen/CgPrimOp.hs
ghc/includes/ClosureTypes.h
ghc/includes/StgMiscClosures.h
ghc/rts/ClosureFlags.c
ghc/rts/GC.c
ghc/rts/GCCompact.c
ghc/rts/LdvProfile.c
ghc/rts/PrimOps.cmm
ghc/rts/Printer.c
ghc/rts/ProfHeap.c
ghc/rts/RetainerProfile.c
ghc/rts/Sanity.c
ghc/rts/StgMiscClosures.cmm