[Date Prev][Date Next][Thread Prev][Thread Next]
- Subject: Re: TIOBE: Lua in the Top 20
- From: David Kastrup <dak@...>
- Date: Thu, 12 Jul 2007 12:13:38 +0200
Tony Finch <firstname.lastname@example.org> writes:
> On Thu, 12 Jul 2007, David Kastrup wrote:
>> I'd still very much prefer a Lua variant which defaults to uninterned
>> strings _until_ one uses them for indexing.
> What would be the advantage of that?
It would open the possibility for later implementing compacting
garbage collection of the string pool. It would also prevent cache
poisoning (a principal feature of large hashes and string copying).
It would spead up the creation and handling of throwaway strings that
are never needed for indexing and possibly even never at all: since
Lua is quite viable as an _extension_ language, making the passing of
string data into and out of it as cheap as possible is a boon. Not
interning throwaway strings into the global string table will help to
keep the global string table limited in size implying fewer cache
misses for every operation involving it.
So it benefits _both_ operations not needing the hash _and_ those
needing the hash to postpone interning strings. The only operations
where interning is useful is indexing and comparison for equality.
Comparisons for equality where a large prefix of the compared strings
matches are not really likely to occur often, and indexing would