lua-users home
lua-l archive

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


On Tue, Jun 5, 2012 at 5:39 PM, Ashwin Hirschi <lua-l@reflexis.com> wrote:
>> The only reason to pre-compile chunks, really, is because you'vestripped
>> the parser out of your lua vm. byte code is less portable,harder to deal
>> with (as you've found), and not really faster to load

You chopped the last part of my sentence:

>> (and if you are loading code in a critical speed path, you probably shouldn't be)

> I disagree. In my experience loading compiled chunks is (much) faster than
> loading source code.

If your run-time is A+B, making it A/4 + B sounds great... unless B >>> A.

If you notice load time, lua is spending about as much time loading
scripts as running them. I'm sure there are programs where thats just
the way it is, or that have so much lua code loading at startup that
startup is being slowed down, but its worth making sure this is your
situation before optimizing load time.

Btw, to the original poster, if size of the script is a problem,
compression might be a good idea (at the price of code size, but maybe
you have lots of ROM for zlib, or already have decompression code),
but there are also various src diet programs around that will rewrite
lua code into smaller lua code (shorten identifiers, strip white space
and comments, etc.). Also, maybe this is obvious, but uncompiled lua
src is compiled at load time, so after load, there is no difference in
execution speed (in other words, its not the case that uncompiled code
is run in some kind of slower interpreted mode).

Cheers,
Sam