The size of things

Simon Marlow
Fri, 15 Feb 2002 15:23:27 -0000

> (Ketil Z. Malde) writes:
> > Thanks for all your help, though!
> One interesting(?) observation,=20
> using a custom data type of
>         data STuple =3D 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 =

> And one more thing, would parametrised types make a difference?
> E.g. my array is
>         data MyArray label elts =3D MA label (Array Int elts)
> which means I have
>         data Foo l a =3D 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.=20

		data StrictList a =3D 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.