lua-users home
lua-l archive

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

On 2/9/2011 3:16 PM, Alex Bradbury wrote:
On 9 February 2011 13:04, Pavel Holejsovsky<>  wrote:
realized that dynamic approach would be better - uses binary .typelib files
at runtime to lookup function and type info and calls function using libffi.
  At the beginning it looked simple enough (but it wasn't :-)

Any idea on the call overhead? Glib+Gio provides a fairly good
standard library if the overhead of each call is not too high, while
it's not likely to matter much for most GUI code.

I haven't measured the overhead, but I'm afraid that it might be significant - libffi itself is not exactly fast, and marshalling Lua values into C-style ones might get expensive too. As you said, it is probably fine for most GUI usages, but might be problematic for time-critical code.

Also, have you
looked at the in-development LuaJIT2 FFI API and considered if it
might at some point be possible to make use of that rather than

I'm watching LJ2 FFI and planning to use it. Ideally it should provide as fast calling sequence as native C code, if not faster. Once FFI gets callback support and some nice __gc support (and I finish features of the rest of LGI), I'll start porting. The lgi architecture is hopefully roughly prepared for it - it is divided to 'core' which is in C and is basically wrapper around libffi, GI and marshalling, and the rest of the code is already in Lua. Replacing currently-in-C-written core with Lj2FFI based one will hopefully do the trick.