lua-users home
lua-l archive

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


On Wed, Sep 30, 2015 at 07:29:22AM -0300, Luiz Henrique de Figueiredo wrote:
> > 4) Lua uses tables heavily. 
> 
> The upside of this is that you may count on much attention being given
> to implementing table access efficiently.

I benchmarked the difference between using a custom testudata that used
upvalues and luaL_testudata which uses the registry. I don't have the
numbers but the difference was really inconsequential in _practice_. In
microbenchmarks it looked like a big deal, but it mostly got lost in the
noise of application workloads. And much of the difference related to
pushing the metatable string name onto the stack. The actual table indexing
is quite fast.

I tested this before the Lua 5.3 string caching feature. I haven't had a
chance to play around with that. I'm concerned metatable names would be
evicted too quickly. If so I wanted to play around with the size as well as
maybe limiting the types of strings kept in the cache (e.g. only shorts
strings or only literals). But probably my concerns are unwarranted.

It's hard, if not impossible, to beat the performance of upvalues. But
they're a specialized construct, and I don't think it's reasonable to use
them as a metric for judging the performance of other constructs.