
ketil@ii.uib.no (Ketil Z. Malde) writes:
Thanks for all your help, though!
One interesting(?) observation,
using a custom data type of
data STuple = STuple !Int Foo
is slightly less efficient than using a normal tuple
(Int,Foo)
Just checking... with -funbox-strict-fields, right?
Seems to go against theory, in which STuple should use three words plus the Foo, while (,) should use three words plus the Foo, plus two for the Int. Perhaps the Ints are constructed anyway, since they are inserted from a function parameter? Sounds reasonable, I suppose; memory use seemed to be the same (from "top"), and there was only a speed difference.
It's possible that the boxed Int is being reconstructed for some reason. You'll be able to see the difference more accurately using heap profiling.
And one more thing, would parametrised types make a difference? E.g. my array is
data MyArray label elts = MA label (Array Int elts)
which means I have
data Foo l a = Foo (MyArray l a) !Int
and so on. As far as I can see, this shouldn't matter (a heap object is a heap object), but am I seeing far enough, I wonder?
A polymorphic strict field can't be unboxed - eg. data StrictList a = Scons !a | Snil will never result in the elements being unboxed, even in (StrictList Int). Apart from that, parameterised data types make no difference to the storage representation. Cheers, Simon