[Haskell-cafe] Efficient mutable arrays in STM
Benjamin Franksen
benjamin.franksen at helmholtz-berlin.de
Fri Oct 28 12:15:07 CEST 2011
David Barbour wrote:
> Create an extra TVar Int for every `chunk` in the array (e.g every 256
> elements, tuned to your update patterns). Read-write it (increment it, be
> sure to force evaluation) just before every time you write an element or
> slice it or slice the array element.
Incrementing and forcing evaluation should not be necessary, a TVar ()
should be enough. I would be very much surprised if the internal STM
machinery compares the actual _values_ of what is inside a TVar, I guess it
just notes that a read or a write happened. Anyway, this is just a guess, I
wonder if these details are documented somewhere...
Cheers
Ben
More information about the Haskell-Cafe
mailing list