lua-users home
lua-l archive

[Date Prev][Date Next][Thread Prev][Thread Next] [Date Index] [Thread Index]


Hi,

Following up to myself:
> - Adding a void* to the table structure incurs no additional memory
>   overhead on most systems. I.e. the userdata pointer is free!
>   The current table structure is 32 bytes long (on 32 bit systems) and
>   anything between 29 and 36 bytes leads to the same effective memory
>   allocation due to malloc overhead and alignment constraints. YMMV.

I have to retract my comment. Apparently the word 'most' was a bit
optimistic. I was under the false impression that most OSS malloc
implementations had a common ancestor in Doug Lea's dlmalloc. So I just
tested my assumptions with Linux glibc and got the above results.

As Rici Lake pointed out to me in private e-mail his experiments on FreeBSD
and Mac OS X show different results. Upon closer inspection it seems that
the OSS malloc ancestry has diverged quite a bit. Everyone is using a
different set of optimizations. These lead to very different allocation
steps for small allocations (8*{2..2^14}-4 for Linux (32 bit),
2^{4..12} for FreeBSD (i386), 16*{1..32} for Mac OS X).

As the ongoing discussion shows, memory consumption is certainly not the
biggest issue for the table/userdata unification.

Bye,
     Mike