lua-users home
lua-l archive

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



Just guessing from past discussions on lua-l: it wasn't implemented
because Lua team don't implement any feasible optimization technique,
but only those that don't clutter the code.

Let me double check. 

Some optimization is indeed implemented for strings: long strings (>40 chars) are managed in a totally different way with respect to short strings. 
This has added a lot of complexity in the source code. (there is also a cache for strings, but the impact on the code is minimal).

So from my point of view the complexity to handle very short strings (<11 chars) is already in the code. 
It would be just another case in the switch statement.

The size of the core would only increase by 1.8K according to the original post.

Handling very short string as Lua handles int64/doubles not only makes the code faster, but also reduces the pressure on the garbage collector.

And the gain in speed was significant according to benchmarks done by Mike Pall. Let me copy here for convenience:

Benchmark   |   x86      x64     PPC32    PPC64
------------+----------------------------------
hash        | +38.2%   +55.8%   +40.9%   +38.7%
spellcheck  | +23.6%   +45.8%   +17.7%   +25.2%
reversefile |  +6.2%   +22.7%   +10.2%   +13.6%
wordfreq    |  +2.2%    +8.3%   +10.6%    +8.6%   

Maybe there is some other aspect that I am missing about things that may break when you implement this optimization....

Thank you for your notes!

   Andrea


--
Andrea Vitali