Hacker Newsnew | past | comments | ask | show | jobs | submitlogin

Do most games that use Lua for scripting (addons, UI, possibly game logic) actually use LuaJIT?

As far as I could tell, 100% of the AAA titles that use it that I tested (3 in total) did not. And in profiling, Lua was actually consuming a lot of CPU relatively.

That confuses me given how easy it is to use LuaJIT over the reference, and how vital performance in these environments is.

Games, contrary to the beliefs of dense hiring managers, disconnected producers, and even designers, are performance critical applications -- achieving a mere 30 FPS and > XX+ms input latency on hardware 5 years in the future in the enthusiast category, on the order of $4000+, is an absolute failure. Every gamer I've ever met (thousands, thousands upon thousands, hundreds that I know well) is extremely sensitive to performance. Performance is king. If a game looks a little shitty but runs AMAZING, it is better than a game that looks AMAZING but runs a little shitty. Hell, it's even better than a game that looks WTFAMAZING and runs pretty well. We only start caring about the looks, typically, when performance is sufficient. So if we can dial the game's graphics up while maintaining performance, we get happy. Enthusiasts love it when they can dial all the way to max settings and still play the game at 60+ fps and unnoticeable input lag. So running your render loop and lua on the same thread (a WTF in itself) and not using LuaJIT is a huge WTF.



I think people are gradually switching over. There may be some porting involved, people may have lots of Lua code for older versions. Plus depending what you are doing the JIT may not speed things up (and you can't use it on many consoles); the 2.1 has a lot of string functions accelerated that would break jitting in 2.0. But someone has just paid for a PS4 port, so clearly many people are using it...


It has worked on PS3 + Xbox360 for some years now and is significantly faster than vanilla Lua. I've no idea why more games haven't picked it up.


Religion. It will take ages to move game developers away from C and C++ to other languages.

Similar to how much it has taken them to move from Assembly to C and C++.


No, they use Lua a lot. The discussion was about LuaJIT vs Lua...


Some games use it. I'm under the impression the number is much larger than 3. There are competing interpreters like Havok.

However, vanilla Lua is pretty fast to begin with. Additionally, the types of optimization you do with vanilla Lua are the opposite kind you do with LuaJIT and vice versa. Generally you need to decide early in the project which you want to go with because it impacts how you write code. And it isn't always guaranteed that LuaJIT will be faster. And since game engine cores are written in C/C++, this optimization works against LuaJIT.

Ultimately, games need to stay within their fps budget. If Lua is high on the CPU, but the game is still in budget, nobody really cares. And CPU profiling doesn't always tell the whole story since many things can be GPU bound. It could very well be that the game is already GPU bound so getting more CPU back won't help.


One more thing. Sometimes modifying Lua is desired. Modifying vanilla Lua is easy. Modifying LuaJIT is not so easy.


There are other lua implementations (for example HavokVM is lua with very good debugging toolset), there are possibly many others too (commercial, or not, or under other names).




Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: