knulli-cfw / distribution

Main KNULLI distribution
https://knulli.org
Other
215 stars 12 forks source link

Performance regression and freeze issues in PPSSPP #60

Open Louisvh opened 1 week ago

Louisvh commented 1 week ago

Knulli build version

40-dev-d8b86623f3 2024/05/30

Your architecture

RG35XX PLUS

Issue description

On Batocera v40, several PSP games (such as DBZ: Shin Budokai 2) run without any slowdowns or crashes (I've confirmed this by playing long enough to collect nearly all Retroachievements without any issues). After switching to Knulli, PPSSPP performance varies; sometimes it runs for a while without any slowdowns, but occasionally the emulator starts stuttering, sometimes completely freezing. Freezing seems more common when using savestates. In these cases, menu+start doesnt kill the emulator anymore, and the hardware reset button is the only way to get back to Emulationstation.

Detailed reproduction steps

Flash Knulli, start Shin Budokai 2 with PPSSPP, play the game for a while.

Details of any attempts to fix this yourself

I made sure the PPSSPP settings are identical to the ones on Bato v40 and I asked for input on the Discord.

Details of any modifications you have made to Knulli.

none

Logs and data

No response

Louisvh commented 1 week ago

The problem seems exacerbated when browsing emulationstation for a while. Checking via ssh, after a while of browsing ES, I've seen ram usage creep up from 40% to over 60%. Trying to start a PSP game at that point failed altogether, with both processes crashing before PPSSPP could start in earnest and emulationstation failing to restart properly.

So: memory leak in ES, I guess? I'm not sure why my v40 install wasn't hitting the same problem, though.

Louisvh commented 1 week ago

Workaround

It's a bit hack-y, but I created a fairly robust workaround for this nonsense: automatically murder emulationstation whenever emulatorlauncher is called and delay its revival until after any emulators have finished.

In /usr/bin/emulationstation-standalone, add this at the start of the while loop (line 25):

while ps aux | grep -v grep | grep -q "python /usr/bin/emulatorlauncher"
do
    sleep 2
done

In /usr/bin/emulatorlauncher, add this right before the runCommand() call that starts the emulator (line 284):

            # murder emulationstation right before we start the emulator
            subprocess.run(['killall', 'emulationstation'])

note that it's python, so the number of spaces in the indentation has to match exactly.

Then call batocera-save-overlay from the command line to make the changes persistent and reboot. I'm not very familiar with the batocera/emulationstation system, so this might horribly break some things, but it seems to work fine on my end. It's essentially upgraded my handheld from an effective 0.4GB to 0.95GB RAM, so I'm pretty happy with that.

Mikhailzrick commented 1 week ago

Testing DBZ: Shin Budokai Another Road(US Shin Budokai 2), could not reproduce reported issue in latest 06/09/24 alpha build

Memory usage during gameplay after playing a couple arcade matches is 420MB.

Louisvh commented 1 week ago

That checks out, because I've seen the ES memory usage spike up to above 600MB, which would have OOM'd there. I haven't had any lag since I implemented the workaround above, so I'm pretty confident RAM was indeed the issue.