[plt-scheme] cost of closure?
On Fri, Jun 01, 2007 at 10:16:35AM +0800, Matthew Flatt wrote:
> 100 objects is too small to measure via `current-memory-use'. I turned
> up `num' to 100000, and I get right at 40 bytes in both cases. That's
> the answer I expect, based on the implementation:
>
> 12 = 4 bytes * 3 fields or captured bindings
> 4 = 4 bytes * 1 code (closure) or type (struct) pointer
> 4 = 4 bytes * 1 MzScheme type tag and hash code
> 12 = 12 bytes per cons cell (MzScheme level)
> 8 = 4 bytes * 2 objects for GC's layer of size info
> ----
> 40
>
> Add a little bit of page-level GC management overhead, and the result
> should be slightly more than 40 bytes per.
I've just tried that with num 1000000, which seemed to produce
stable answers on both of my test machines. Both of my answers
differ, though, which seemed interesting. My PowerPC Mac
produces 48.5 for both results in v360 and 40 bytes for v370.
My amd64 FreeBSD box (which only has v360 so far) produces 64.2
for both answers. That suggests to me that you've done some
compression or optimization on the 64-bit platform to avoid
gratuitously doubling the size of everything. Cool.
Cheers,
--
Andrew