lua-users home
lua-l archive

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


Luís Eduardo Jason Santos wrote:
> Is there a benchmark concerning LuaJIT performance on its first run (as
> compared to plain Lua)?

It's slightly faster. I've timed lua_open + luaL_openlibs in
isolation. First immediately on process startup, then a second
time after closing it, to eliminate effects of cache/TLB warmup.
All times in microseconds on a 3GHz Core2 (lower is better):

1st 2nd
---------------------------
155  95  Lua 5.1.4
 85  60  LuaJIT 2.0.0-beta2

But the main overhead comes from the process startup, shared
library loading and resolving the symbol stubs. This is of course
system dependent. With Linux it takes at least another 250
microseconds, even without loading readline.

The standard Lua stand-alone program is linked with readline. Just
loading the required shared libraries, without even using a single
function of them, adds a whopping 900 microseconds to the total time!

> Maybe the real question I'd like to ask is: would it hurt to run a cgi-based
> application using LuaJIT?

It wouldn't hurt. But you wouldn't see much of a difference,
either. If the Lua code for request handling is only run once,
it's probably not compiled at all. So you're not getting any
benefit from a JIT compiler.

Consider using FastCGI which eliminates the process startup
overhead. And keep the same lua_State alive across many requests,
so the Lua code can get compiled. This should give you much better
performance.

--Mike