Unboxed mutable variables

Simon Marlow marlowsd at gmail.com
Thu Jan 12 19:43:11 CET 2012


On 12/01/2012 18:37, Johan Tibell wrote:
> On Thu, Jan 12, 2012 at 10:25 AM, Simon Marlow<marlowsd at gmail.com>  wrote:
>> I think by (1) you mean mutable variables containing unboxed values, right?
>
> Yes.
>
>> I normally use an unboxed array of length 1 for these.  There's not much
>> overhead - only an extra word in the heap compared to implementing them
>> natively.  I'm guessing you care more about the overhead of the operations
>> than the space overhead of the counter itself, and a 1-element unboxed array
>> should be just fine in that respect.
>
> I will run some benchmarks. If it turns out that using an unboxed
> array is costly, what would it take to get real mutable variables
> containing unboxed values?

It'd need a new heap object type, which is fairly invasive (lots of RTS 
changes).  Not prohibitive, but more invasive than adding a primop for 
example.

Cheers,
	Simon



More information about the Glasgow-haskell-users mailing list