lua-users home
lua-l archive

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

On Wed, Nov 13, 2013 at 11:18 AM, Andrew Starks <> wrote:
> On Wed, Nov 13, 2013 at 8:33 AM, steve donovan
> <> wrote:
>>  In
>> fact, the LuaJIT universe advises against explicit C bindings if
>> performance is desired.
> Ahh. Thanks. I had understood it to be the opposite. Something like,
> crossing boundaries from lua into C was slower with FFI. But, that's
> why I asked! :)

in fact the performance advantages and problems are very complex. the
rule of thumb is roughly:

- FFI is way faster for JITted code, but slower for interpreted code
(both plain Lua and LuaJIT interpreter).

- C API is very efficient on interpreted code (both plain Lua and
LuaJIT interpreter) but no better in LuaJIT and can prevent JITting
code, forcing the use of the interpreter.

in short: FFI can be the absolute fastest by a wide margin, or it can
be a drag when not.

that's why having two bindings (classic binding and FFI) with the same
API is so desirable.