lua-users home
lua-l archive

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



On Wed, 13 Sep 2023, at 00:19, Lars Müller wrote:
> Having started Lua at version 5.1,
> I expect(ed) all strings to be interned,
> guaranteeing me O(1) string comparisons
> and O(1) table access no matter the keys
> (save hash collisions).
>
> However Lua 5.3 introduced a distinction between
> "short" strings (which are interned) and "long" strings (which aren't
> interned).
> The distinction of whether a string is "short" or "long"
> is made based on an arbitrary length limit; Lua users have no control.
> This means code can be arbitrarily slower -
> and arbitrarily more memory inefficient - compared to 5.2.
> The only benefit is that string creation is faster, since no hashing is
> required.

iirc this was exactly the reason a CVE was reported for a DoS hashing attack, and this was the fix. (please correct me if I'm wrong)


> The second "implementation detail" is interior table memory management:
> Lua never shrinks tables; it only ever grows hash and array part.

I've been bitten by this one in the past.

Thijs