Performance LuaJIT for Java Bridge #244
Replies: 2 comments 3 replies
|
Yep, this is very typical LuaJIT behaviour. I remember there are some great articles (or mailing list entries) talking about this. But here is the best that I can find in a few minutes: Callback performance - LuaJIT. So, yes, LuaJIT is most fast when your code is mostly in Lua (or Lua + LuaJIT FFI). When Lua/C (or Lua/C/Java) API is heavily used, LuaJIT basically can't do anything because it can't optimize across the boundries. However, for LuaJ, with all the code in Java, JVM can optimze things across the boundries, potentially made the API calls cheaper. This repository has some benchmarks on this:
Android uses different JVM and can contain different optimizations though, and I can't really reason about it just looking at the numbers. |
|
Hi thank you for the reply, this is really helpful for my research, where do I can find the code of this benchmark ? |
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
Hi, thank you for creating this awesome library, I’m currently benchmarking LuaJava against LuaJ/LuaJIT in Android platform mostly as Java Bridge to call Java object and I’m seeing mixed performance results depending on the use case. For pure/native Lua calculations, LuaJava (with LuaJIT) performs significantly better—around a 90% improvement compared to LuaJ, as shown in the attached benchmark. However, when I use LuaJava to frequently call Java methods, the performance becomes noticeably worse than LuaJ. This seems counterintuitive given the large speedup in native computation. Is this slowdown expected due to JNI/Java bridge overhead.
? Are there recommended patterns or optimizations to improve LuaJava performance when interacting heavily with Java/Android services?
This is an example calling a fibonacci sequence, LuaJIT performs better

Besides that, I made a java method that have access to Android's internal API by using LuaJ took 450+ calls/sec when using LuaJ, but when I use LuaJIT it only gets 235+ calls/secs
All reactions