lua-users home
lua-l archive

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



In this cases u may use/implement a custom allocator to avoid related problems.

https://www.lua.org/manual/5.1/manual.html#3.7




---- Em Dom, 23 out 2022 02:24:57 -0300 bil til <biltil52@gmail.com> escreveu ---

Thank you for the PDF version of Roberto's "Lua performance tricks"
article from Lua Gems.

After this extremely nicely presented tragic-philosophical start about
modern software programming in the first paragraph, it gives me really
very interesting insights into the storage of Lua. As I especially am
just interested in tables, it is especially this Polyline
construction:

polyline = { x = { 10.3, 10.3, 15.0, ...},
y = { 98.5, 18.3, 98.5, ...}
}

It is stated that this needs 24MBytes for a 1 Mio-Point Polyline (see
errata, there is a misprint of "kBytes" in the original article).

I assume, this depends strongly on the C compiler used?

So 24MByte presumably for a C compiler for Lua64 using 'int' fo 32
bits to facilitate to "uplift 32bits software to 64bit world" (as it
does MS Visual Studion C++ e. g. for the creation of Win64 bit
software)?

And I assume this was before Lua started with 64bits integers / lua
integers, so possible in Lua5.1 times? (8bytes per double, plus 4
bytes per type, so 12 bytes per Lua number?).

And after Lua integers appearing (I think Lua 5.2) this would possibly
even have increased to 32 MByte? (8 bytes per double, plus 8 bytes per
type info, so 16 bytes per Lua number?).

And after Lua 5.4, where the type info shrinked to 1 byte, if I
understand this correctly, this shrinked now to 18 MByte (8bytes per
double, plus 1 byte per type info)?

And for Lua32 the numbers would be quite identical, except there of
course 4 byte per float, and int also remains with 4 bytes - so
approximately halfed memory usage?

Could some "Lua internals specialst" tell me, whether this is correct
understanding from my side?