Using mutable array after an unsafeFreezeArray, and GC details

Simon Marlow marlowsd at
Tue May 13 11:01:28 UTC 2014

On 12/05/2014 21:28, Brandon Simmons wrote:
> The idea is I'm using two atomic counters to coordinate concurrent
> readers and writers along an "infinite array" (a linked list of array
> segments that get allocated as needed and garbage collected as we go).
> So currently each cell in each array is written to only once, with a
> CAS.

Certainly you should freeze arrays when you're done writing to them, 
this will help the GC a lot.

>> How large are your arrays? Perhaps the new small array type (in HEAD but not
>> 7.8) would help?
> Thanks, maybe so! The arrays can be any size, but probably not smaller
> than length 64 (this will be static, at compile-time).
> I read through, and it
> seems like the idea is to improve array creation. I'm pretty happy
> with the speed of cloning an array (but maybe cloneSmallArray will be
> even faster still).
> It also looks like stg_casSmallArrayzh (in PrimOps.cmm) omits the card
> marking (maybe the idea is if the array is already at ~128 elements or
> less, then the card-marking is all just overhead?).

That right, the cards currently cover 128 elements, and there's also a 
per-array dirty bit, so the card table in an array smaller than 128 elts 
is just overhead.


More information about the Glasgow-haskell-users mailing list