[Date Prev][Date Next][Thread Prev][Thread Next]
[Date Index]
[Thread Index]
- Subject: Re: [ANNOUNCE] Lua 4.0 (alpha) now available
- From: Edgar Toernig <froese@...>
- Date: Thu, 04 May 2000 00:29:17 +0200
Hi,
Roberto Ierusalimschy wrote:
> I said:
> > - You wrote "+ reduced memory usage" and I was surprised to find that
> > tables take 17-25% more space. [...]
That's the additional space malloced.
> 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"...)
I had a thinko about the fill rate of the old hash. I thought, it would
only rehash if no free slot was found (would have given a nearly 100% fill
rate for numeric keys - the typical lua arrays). But it always rehashes at
66%.
I also said in my initial posting:
> I just hope, that the additional memory for management is compensated by
> the high fill rate.
So I'm quite relieved *g* Thanks.
Ciao, ET.