LuaJIT performance on ARM Macs

Questions about the LÖVE API, installing LÖVE and other support related questions go here.
Forum rules
Before you make a thread asking for help, read this.
Post Reply
User avatar
Madrayken
Party member
Posts: 126
Joined: Sun May 04, 2014 4:21 pm
Location: Oakland CA
Contact:

LuaJIT performance on ARM Macs

Post by Madrayken »

Hi folks,
As I'm getting to the end of making Moonring, and testing on a bunch of different machines, I'm noticing massive slowdows on Mac M2. Is this likely to be a LuaJIT issue, a Rosetta issue, or something else? The game is doing lots of *very* intensive processing, and using a ton of shaders etc, but so far all has worked pretty well on Intel machines 5+ years old. Any help much appreciated.

- Fluttermind
Discord: https://discord.gg/tYfHgXc
Bandcamp: https://madrayken.bandcamp.com/
Twitter: @Fluttermind
User avatar
GVovkiv
Party member
Posts: 688
Joined: Fri Jan 15, 2021 7:29 am

Re: LuaJIT performance on ARM Macs

Post by GVovkiv »

Madrayken wrote: Sat Jul 22, 2023 11:28 pm Hi folks,
As I'm getting to the end of making Moonring, and testing on a bunch of different machines, I'm noticing massive slowdows on Mac M2. Is this likely to be a LuaJIT issue, a Rosetta issue, or something else? The game is doing lots of *very* intensive processing, and using a ton of shaders etc, but so far all has worked pretty well on Intel machines 5+ years old. Any help much appreciated.

- Fluttermind
It's LuaJIT ARM issues, in love 11.5 and love 12 will use newer version of luajit, where some issues with ARM might be fixed
Go to love 12 artefacts here: https://github.com/love2d/love/actions/runs/5513844263, (or, better, love 11.5 https://github.com/love2d/love/actions/runs/5632754795) download binaries for mac os and try run game with it and see if there any difference with performance.
You can also build manually, but download compiled binary sounds easier.
User avatar
BrotSagtMist
Party member
Posts: 665
Joined: Fri Aug 06, 2021 10:30 pm

Re: LuaJIT performance on ARM Macs

Post by BrotSagtMist »

I think i remember talks about jit not working on these processors.
obey
User avatar
slime
Solid Snayke
Posts: 3172
Joined: Mon Aug 23, 2010 6:45 am
Location: Nova Scotia, Canada
Contact:

Re: LuaJIT performance on ARM Macs

Post by slime »

JIT compilation works on arm64 (the architecture used by Apple Silicon CPUs). However, right now LuaJIT can only use a really small section of memory to store JIT-compiled code on arm64 - and that small section is also shared with other parts of the app like C/C++ libraries love uses. So what ends up happening is it can run out of memory in that area really quickly, which causes it to frequently try to recompile code, which can really slow things down when it happens repeatedly like that.

There's an open bug report on the LuaJIT github page about it, but a proper fix seems like it needs quite a lot of work and Mike Pall hasn't had a lot of time to dedicate to LuaJIT in the past few years, so I don't know if or when a fix will happen.

love tries its best to maximize the amount of memory in that area that's available to LuaJIT, but there's only so much it can do. You might end up having more consistent performance by turning off JIT compilation via jit.off() at the top of main.lua. If you have any threads you'd need to do it at the top of each thread's code too, in order to turn it off there. It will be slower than the peak performance LuaJIT is able to achieve when it's working well of course, but faster than it is when it tries to recompile every block of code all the time.
User avatar
Madrayken
Party member
Posts: 126
Joined: Sun May 04, 2014 4:21 pm
Location: Oakland CA
Contact:

Re: LuaJIT performance on ARM Macs

Post by Madrayken »

Thanks so much, folks. Thought I was going nuts.
Discord: https://discord.gg/tYfHgXc
Bandcamp: https://madrayken.bandcamp.com/
Twitter: @Fluttermind
Post Reply

Who is online

Users browsing this forum: Ahrefs [Bot], Bing [Bot], Google [Bot] and 5 guests