lua-users home
lua-l archive

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


Roberto,

Roberto Ierusalimschy <roberto@inf.puc-rio.br>:
> Would you mind sharing with us that implementation and the other things?

I never mind sharing something that's not mine:)
http://lua-users.org/lists/lua-l/2018-03/msg00330.html

A sizeof(unsigned short), and possibly more, could be saved if it
didn't have to store the uservalue count.

Other things would mostly be debugging-related (though performance
would then be irrelevant).

I'm inspecting efficiency of different ways of storing a possibly
variable number of arguments. Options considered:
t1: create a single table, fill in place;
u1: create a single tuple, fill in place;
tN: create a new table every time;
uN: create a new tuple every time;
t0: create a single table, assign using a[1],a[2],a[3]=...
(effectively cheating as this limits argument count)

One possibly useful thing I can share is the benchmark result set of
these options (4 elements actually assigned, 1 mln loop iterations,
median of 10, MIPS, somewhat patched Lua 5.4.0):
t1: 5.865s
u1: 7.315s
tN: 26.695s
uN: 14.97s
t0: 2.425s

As you see, tuples beat tables if we (have to) create a new one every
time; tables beat tuples when they can be reused (assignment performed
via lua_rawseti in a loop vs lua_setiuservalue in a loop). The
"cheating" variant is there to provide a baseline to compare against.

Best regards,

-- 
DoubleF