lua-users home
lua-l archive

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

On 2021-08-12 3:39 p.m., Roberto Ierusalimschy wrote:
> > A note concerning this optimization used by Lua:
> > 
> > The increased size of a bytecode is usually not a problem.
> > But increased loading of CPU cache is always a performance hit.
> > Assigning a non-internable string to a local const variable is
> > cache-unfriendly in the current implementation of Lua: the constant string
> > would exist as multiple copies in RAM and each copy would be cached
> > independently.
> > I suggest to apply this optimization (to convert local const variables to
> > real constants) only for internable strings.  Constant variables containing
> > long strings should stay non-optimized in bytecode as if they were
> > non-constant locals/upvalues.
> This problem only happens in precompiled bytecode. In regular code,
> the compiler reuses the same copy for all occurences of any string,
> so this is not an issue. What we need is a way to reuses strings
> in dump format, both to reduce its size and to avoid the problem
> you mentioned.

Wait, Lua doesn't intern all strings contained in bytecode (aka
basically all literals) like Java does? Only the ones that fall within
the interning cap? We uh, thought it did...

> -- Roberto