lua-users home
lua-l archive

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

* Oskar Forsslund:

> I have a logical expression that is evaluated in lua where some of the
> parameters are c calls.
> I wanted to make this faster by collecting all c calls into one call (thus
> just moving between lua and c once) made before the expression is evaluated
> This however did not give any performance increase as I now could not
> utilize the short evaluation of logical expressions in lua
> Therefore I would somehow like to transfer the evaluation entirely to the c
> side to gain both benefits (single call and short evaluation)
> This is easier said than done since the logical expression is dynamically
> created at runtime in lua by the use of loadstring (done before any
> performance critical sections)

Ah, so it's still the same issue.  You should really try to get some
profiles and check where your program is spending its time.

Theoretically, you could roll your own restricted bytecode
interpreter.  With a lot of work, it might even be faster than plain
Lua.  However, it is going to be tough to beat the LuaJIT interpreter.
You might have better luck with a custom compiler based on DynASM.
However, this is quite a bit of work, so you really should do some
benchmarks first, including some where you hand-compile the
expressions to C code, to check if the expectation time indeed goes
down considerably.