Card marking for newly allocated arrays

Simon Marlow marlowsd at gmail.com
Mon Mar 10 12:45:34 UTC 2014


Johan and I talked about this on IRC.  The card table is actually 
irrelevant for newly allocated arrays, so in fact we can just not 
initialise it at all.

Cheers,
Simon

On 10/03/2014 08:22, Johan Tibell wrote:
> Hi,
>
> For MutableArray#s, a card is supposed to be marked if the array is
> pointing to an object in a younger generation than itself resides in.
> Since the array always points to elements in the same or an older
> generation when it gets allocated, we should be fine with marking the
> array as clean upon allocation and setting all the cards to zero. Right
> now it's marked as *dirty* and all cards are (modulo a bug) marked as zero.
>
> I think we should mark these arrays as clean to avoid some GC costs
> later. We could avoid writing the card table on allocation as well, as
> it's always safe to default to dirty. However, this will incur extra GC
> costs later (after the first write to the array) as the whole array will
> appear as dirty (due to garbage values in the card table as it wasn't
> initialized) even if only a single element was written.
>
> I'm leaning towards 1) marking arrays as clean and 2) zeroing out the
> card table when the array is created. Thoughts?
>
> -- Johan
>


More information about the ghc-devs mailing list