X-Plane / XLua

Ultra-Minimal Lua Plugin for X-Plane
MIT License
31 stars 18 forks source link

Xlua 1.2.0 (LuaJIT) performance issues #18

Open JT8D-17 opened 1 year ago

JT8D-17 commented 1 year ago

Investigating the heavy impact of xlua 1.2.0 on the frametime when using XP 12.05's default Airbus A330, I stumbled upon the use of "jit.off()" in "A333.ecam_fws999.lua".

On my system (Ryzen 5800X, Arch Linux, kernel 6.3), the default A330's xlua, in its "out of the box" configuration takes up ~18 % of the frametime in a test scenario.

Disabling "jit.off()" in the Lua file, i.e. using the JIT compiler instead of the regular Lua interpreter, and restarting XP makes xlua's frametime proportion baloon to >60 %.

Then I compiled xlua 1.2.0 with a library from the LuaJIT repository's 2.0.5 branch. Without "jit.off()", i.e. using the JIT compiler, xlua uses ~18 % of frametime. But I've also had cases where the frametime proportion was >60 %, but dropped back to ~18 % after an aircraft reload. With "jit.off()", i.e. using the Lua interpreter, frametime fraction was lower at ~15%.

Compiling xlua 1.2.0 with the LuaJIT library from the 2.1 branch (latest commit) exhibited no change in behavior compared to the regular xlua 1.2.0 release.

Since the employment of "jit.off()" also seems to benefit SASL (which apparently also uses LuaJIT 2.1.0) and other xlua 1.2.0 applications (Zibo's 737), I think the frametime performance issue may be a general LuaJIT 2.1.0 bug.

As my C skill is too low to debug LuaJIT, I am posting this here for awareness and information, hoping that somebody else is able to dive deeper and potentially take this issue to the LuaJIT developers.

- Edit:
The effects of the recompiled Xlua plugin using 2.0.5 may have been due to scripts that refuse to parse and which are thus not being executed. So please disregard that finding.

JT8D-17 commented 9 months ago

The issue has come up on x-plane.org again with some hard performance testing:

https://forums.x-plane.org/index.php?/forums/topic/297785-linux-users-inconsistent-xlua-performance-with-complex-default-aircraft-eg-lr-a330-300/