raylib-lua is slow on Apple M1
Opened this issue · 6 comments
I'm on a MacBook Air (M1, 2020) running macOS 12.4.
After cloning the repo and subrepos and running make
, trying to run any of the raylua_* binaries results in:
zsh: killed ./raylua_e
(…or raylua_s or raylua_r) and an exit code of 137.
Searching for "zsh: killed" seems to mostly result in pages relating to running Homebrew or tools installed with it on M1 Macs. I don't think this is Homebrew-related since I'm a boomer who uses MacPorts (if it ain't broke…). Nonetheless I wonder if the issue might still be related to the relatively new M1 hardware and I wonder if anyone else is seeing this issue happen on M1 Macs, or alternatley is running it successfully.
Unfortunately I no longer have easy access to Intel-based Mac hardware to see if the issue is happening there too.
Exit code 137 is out of memory error, not sure why/where it happens.
I don't have a Mac, so it's tricky to test, I should try with a vm.
👋🏼 @GarrettAlbright
Have you find out a way to work with it?
I'm afraid I haven't. I haven't had another look at this since I posted this issue.
I've submitted a pull request for the issue, but one thing I am noticing is performance is not great. Here is a benchmark I've run 100,000 bunnies, 144 FPS max.
M1 Mac Mini - 16GB RAM - macOS Ventura 13.4.1
Language | Extension | FPS | Memory | CPU | GPU |
---|---|---|---|---|---|
C (CMake Release) | Native | 85 FPS | 47 MB | 64% | 90% |
Zig 0.11.0 (ReleaseFast) (Arena) | raylib.zig | 85 FPS | 54 MB | 60% | 90% |
Rust (Release) | bitten2up/raylib-rs | 85 FPS | 48 MB | 67% | 90% |
Go 2.20 (Release) | gen2brain/raylib-go | 85 FPS | 55 MB | 73% | 90% |
Nim 2.0 (Release) | planetis-m/naylib | 83 FPS | 48 MB | 70% | 90% |
C# 11 .Net 7 | raylib-cs | 85 FPS | 68 MB | 75% | 90% |
NodeJS 20 | node-raylib | 44 FPS | 134 MB | 100% | 80% |
PHP 8.2 (Jit) | raylib-php | 41 FPS | 257 MB | 100% | 60% |
PHP 8.2 | raylib-php | 27 FPS | 242 MB | 100% | 57% |
Python 3.11 | raylib-python-cffi | 10 FPS | 100 MB | 100% | 35% |
Lua (LuaJIT 2.1.0-beta3) (-O2) | TSnake41/raylib-lua | 5 FPS | 113 MB | 100% | 31% |
I am not sure why LuaJIT is having these performance issues as I ran raylib_e with a zipfile to make a binary. The branch checkout is from 6 months ago so its a recent code base for LuaJIT. Even ran with MACOSX_DEPLOYMENT_TARGET=13.4 make
to try anything for additional performance. Also used -arch arm64 -O3 -flto
but nothing really improved performance.
I think this issue is due to LuaJIT on Mac OS not using JIT for some reason.
What gives jit.status()
(may require jit = require "jit"
) on Mac OS X with M1/M2 ?
jit = require "jit"
print("jit status", jit.status())
./raylua_s examples/textures_bunnymark.lua
RAYLUA: Raylua boot script
RAYLUA: Lua Version: Lua 5.1
RAYLUA: Lua JIT: LuaJIT 2.1.0-beta3
RAYLUA: Loading FFI binding entries.
RAYLUA: Loaded 846 FFI entries.
jit status true fold cse dce fwd dse narrow loop abc sink fuse