[Date Prev][Date Next][Thread Prev][Thread Next]
[Date Index]
[Thread Index]
**Subject**: **Re: [ANNOUNCE] Lua 4.0 (alpha) now available**
**From**: Roberto Ierusalimschy <roberto@...>
**Date**: Wed, 03 May 2000 17:51:43 -0300

> - You wrote "+ reduced memory usage" and I was surprised to find that
> tables take 17-25% more space. [...]
This is strange. In a machine with alignment 8 for doubles (and using
doubles as Lua numbers), the old tables need 4 "units" (8 bytes each) for
each pair (2 units for each TObject, key and value), while the new tables
need 5 units (the old 4 + one link). On the other hand, the old tables have
a load-factor range of 50%-67%, so the average load factor was 58%. The new
tables have a range of 50%-100%, average is 75%. So, on the average, to
store 100 pairs in the old tables we need 100/0.58*4=690 units; with the new
tables, we need 100/0.75*5=667 units. If you use single floats as numbers,
the result is the same, but the unit is 4 bytes. If you use double but
with alignment of 4, then you need 6 units (4 bytes each) for a pair in
old tables, and 7 units in the new tables: 100/0.58*6=1034, 100/0.75*7=933.
In any case, new tables should use less memory than old ones (of course,
this is "on average"...)
-- Roberto