lua-users home
lua-l archive

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


Hi,

Over the past two weeks I have been working on a few things.

I tried integrating Coco into Ravi but have not been able to make it
work. To allow coroutines to be run, for now I have adopted the simple
solution that only functions on main thread can be executed in JIT
mode. Any threads other than the main thread will run the interpreter.
As a result I am able to run the tests on coroutines.

I have added an optimization of fornum loops - where the index
variable can be determined to be integer, and step is > 0, a more
optimized fornum loop is executed.

This enhancement improves performance of the benchmarks. The latest
results are at:

https://github.com/dibyendumajumdar/ravi/blob/master/readthedocs/ravi-benchmarks.rst

The benchmarks do not tell the full story however as the LLVM
compilation time is excluded. LLVM's JIT compilation is not very fast
hence enabling JIT compilation for everything slows things down
substantially.

For instance the Lua 5.3 tests take less than 1 second in interpreted
mode but when everything is JIT compiled the overall time taken
increases to 72 seconds! This then means that like Java and other
method based JIT engines, the JIT compilation needs to be adaptive.

I have implemented some simple controls for now.

Firstly there is manual mode - only functions requested by the user
are JIT compiled. This is best approach for library designers who can
compile functions before returning a module table.

In auto mode - I enable JIT compilation if the function has a fornum
loop, or the function's bytecode size is above a threshold, or if the
function is being executed many times. Even with these changes the
overall time taken to run Lua tests is hurt by the JIT compilation,
and the overall time taken is still high at around 11 seconds.

I am now building and testing Ravi on MAC OSX (64-bit) in addition to
Ubuntu and Windows.

I have hit a weird issue on Windows -  when JIT compiled code is run
sometimes the luaD_throw() function fails with 'invalid or misaligned
stack error' when it tries to do a longjmp(). I am still trying to
determine if this is a bug in my code, LLVM or MSVC.

Finally - I am also looking to create an alternative JIT compiler
using newly released GCC 5.0 which has a JIT compilation API.

Regards
Dibyendu