The size of things

Simon Marlow simonmar@microsoft.com
Fri, 15 Feb 2002 15:23:27 -0000


> ketil@ii.uib.no (Ketil Z. Malde) writes:
>=20
> > Thanks for all your help, though!
>=20
> One interesting(?) observation,=20
>=20
> using a custom data type of
>=20
>         data STuple =3D STuple !Int Foo
>=20
> is slightly less efficient than using a normal tuple
>=20
>         (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
>=20
>         data MyArray label elts =3D MA label (Array Int elts)
>=20
> which means I have
>=20
>         data Foo l a =3D Foo (MyArray l a) !Int
>=20
> 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.

Cheers,
	Simon