lua-users home
lua-l archive

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


Chris Chapman wrote:
Just a quick (and vague) question: what are the expected sizes of compiled
lua scripts? I had expected quite a good ratio of plain text script size to
compiled script size. However, on running luac over a directory of about 45
scripts, totalling about 100K of uncompiled scripts, the resulting combined
compiled lua file was 132K in size. Stripping debug info only brought it
down to 97K. Bearing in mind that the majority of our lua scripts are
function calls/variable references, lua conditionals and function
definitions, but other than that very little lua logic - does this sound
like expected results?

Hmm, not too surprising really, for many small scripting making
named references to many other variables.  The strings representing
the names of those variables (including referenced function names
 etc) are stored in the bytecode as-is, since lua is dynamic and
has no 'linking' stage.  While these strings are uniquified
per-chunk, that won't help much when you have many small scripts.

You can verify this by loading up the bytecode in a binary-browser
-- you should see raw strings taking up a large proportion of the
bytecode size.  Still, your bytecode will compress well, if you
use a compressed on-disc format.

--Adam
--
Adam D. Moss   . ,,^^   adam@gimp.org   http://www.foxbox.org/   co:3
Consume Less, Live More