lua-users home
lua-l archive

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


Hello!

On Wed, Nov 13, 2013 at 8:43 AM, Javier Guerra Giraldez wrote:
>
> - FFI is way faster for JITted code, but slower for interpreted code
> (both plain Lua and LuaJIT interpreter).
>
[...]
>
> in short: FFI can be the absolute fastest by a wide margin, or it can
> be a drag when not.
>

True.

But the situation will get better when Mike Pall implements the
"JITting around Not-Yet-Implemented (NYI) items" feature in LuaJIT 2.1
(soon). So in that mode, the FFI-based code will almost always get JIT
compiled even on code paths with NYI items and only the NYI calls
(like lua_CFunction calls) alone will be interpreted (but not the Lua
code around it).

The performance will still degrade, however, when the NYI items are
not sparse enough among the hot code paths, in which case snapshoting,
or synchronizing state between JITted code and the VM (used by the
LuaJIT interpreter) will become the bottleneck.

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

Yes, it's always recommended to do benchmark and tuning for specific
applications on the user side.

Best regards,
-agentzh