[Date Prev][Date Next][Thread Prev][Thread Next]
- Subject: Re: Question about LuaJIT's future FFI/Struct Extension
- From: Pavel Holejsovsky <pavel.holejsovsky@...>
- Date: Thu, 18 Mar 2010 09:52:37 +0100
On 3/17/2010 8:57 PM, Mike Pall wrote:
Peter Cawley wrote:
Along the same lines, I noticed that in a recent project, most of my
C(++) glue functions did very simple things - read some values off the
Lua stack, call some C++ method, and push the results back onto the
stack. It seems to me rather wasteful for LuaJIT to setup a stack,
call my C(++) function, have that call back to the API to read/write
values, then have LuaJIT tear the stack down again.
Yes, now that everything else has gotten so fast, that's the main
performance bottleneck when calling C functions from compiled Lua
code. And it gets worse: the compiler can't optimize across such
calls, because they might have arbitrary side-effects (changing a
global, growing/reallocating a table etc.).
Maybe for beginning it would be nice to have possibility to mark
luCFunction as 'does not touch Lua state at all', therefore having no
LuaJIT-visible side effects. This would mean that trace recording would
not be aborted if such call is met. I think that this could speed up
things if such calls are met inside hot loops (e.g. lua loop processing
data from externally-allocated memory block).
Of source, full implementation of Mike's FFI proposal would make this