[Date Prev][Date Next][Thread Prev][Thread Next]
- Subject: Re: No way to get uservalue count from API; intended?
- From: Sergey Zakharchenko <doublef.mobile@...>
- Date: Tue, 18 Aug 2020 21:36:53 +0400
Roberto Ierusalimschy <email@example.com>:
> Would you mind sharing with us that implementation and the other things?
I never mind sharing something that's not mine:)
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,a,a=...
(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):
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.