Hello! I’m making a port of Celeste Classic from PICO-8 to Playdate. And I’m struggling to reach a stable 30 FPS on device. I initially tried to stay close the PICO-8 Lua structure (global all the things!). I then tried to apply the usual Lua/Playdate tips (local and sprites all the things!). The game usually runs around 28 FPS with ups and downs (between 25 to 30). I'd like to make it a solid and stable 30 FPS.
What would be a good process to do that? I've tried the C and Lua Sampler on device as well as the Device Info Screen. But I'm not even sure what to do and what to look for there.
There's a known performance problem with the current firmware. The next version of the firmware should be better.
Until then can test on recovery firmware (hold lock + menu + A + B for a while and follow the prompts) to get more of an idea about how your game runs.
I was already at around 25-30 FPS before update 1.13. But that update did drop the framerate of about 5 FPS (so around 20-25 FPS). I did some more optimizations after that to gain more FPS. So it's good news if the next firmware improves things. Still, I'd love to get directions on how to improve things in general. (And what should I look for in the Sampler or Device Info windows?)
debugging prints in a hot/frequent code path will slow down your game "game_just_restarted false" you only do this on the menu but it's worth mentioning
There are some additional, more involved things you can do @hteumeuleu ; namely splitting data according to access patterns, as well as creating your data structures in a way that doesnt generate additional garbage (think ring buffer, as an example).
These are a bit more involved to be sure, but if you'd like help going down that route, feel free to DM me.
Edit: additional info
I found an old perf capture from my game (Gun Trails) back when it was Lua based, and these techniques were able to keep memory usage nearly static, and basically eliminate GC spikes.