barbudreadmon / fbalpha-backup-dontuse-ty

Deprecated port of Final Burn Alpha to Libretro (v0.2.97.43).
61 stars 43 forks source link

Run Ahead perf degradation over time #240

Closed Tatsuya79 closed 6 years ago

Tatsuya79 commented 6 years ago

When using Run Ahead, after a certain time of play the game will begin to slow down and sound to crackle when pushing buttons.

I was trying to find a way to make it easy to reproduce, leaving it on fast forward for a while but it doesn't seem to help. I think it's happening as you're playing and calling states repeatedly via run ahead.

I had it happened (with the new save state fix from https://github.com/libretro/fbalpha/commit/7c79ba992cafa6e4cfb5519c67fec5f4b60cb990) playing Hyper Street Fighter II_ The Anniversary Edition (040202 Japan) with run ahead 2nd instance 3 frames reduction after around 20mn on a i5-3570k in gl with hard sync 0 frame enabled.

It was already happening before that commit, and also in 1 instance mode. I did notice it in several games such as Battle Garegga near the end of the game (so probably a good 20mn+ as well).

barbudreadmon commented 6 years ago

How is cpu usage ?

inactive123 commented 6 years ago

@Dwedit Would you be willing to investigate this, and try to find a potential fix for it?

Tatsuya79 commented 6 years ago

I monitored it with MSI afterburner, that gave me a html log that is pretty useless outside of the program itself, anyway...

Playing Hyper Street Fighter II_ The Anniversary Edition (in the conditions mentioned earlier) it started to slow down after 30mn. The graph shows that 1 core started with an average 35% usage that went up steadily overtime to 70% after 40mn.

RAM usage doesn't seem to have changed much, but I monitored it globally for the OS. At least no big leak it seems.

Dwedit commented 6 years ago

This needs profiling. Profiling! Only thing is I don't have a working installation of a suitable toolchain to build this program. I do have a symbol converter though, so if someone could build it with full debug information and no symbols stripped, I could run it in the MSVC profiler.

Tatsuya79 commented 6 years ago

Here, I compiled it in mingw64 gcc 7.3 with DEBUG=1.

Dwedit commented 6 years ago

CV2PDB took a decent amount of time to run on that dll...

Modified Retroarch to always resync state every frame, as if input was dirty, and running Twinkle Star Sprites with fast forward on. Framerate starts out at around 170, and after a while tapers down to 64.8, will look at a profile log soon.

Framerate gradually drops lower and lower every time I watch attract mode.

Edit: it's weird, profile data is saying that it's calling the input code a lot?

edit: Pinpointed the problem, FBA was requesting ID 255 which was considered to be out of range (max is 36), and causes my input code to keep adding more and more elements into the cache. So yes, this time the problem is in my code. Will change state from 36 elements to dynamic-sized.