hrydgard / ppsspp

A PSP emulator for Android, Windows, Mac and Linux, written in C++. Want to contribute? Join us on Discord at https://discord.gg/5NJB6dD or just send pull requests / issues. For discussion use the forums at forums.ppsspp.org.
https://www.ppsspp.org
Other
11.32k stars 2.18k forks source link

Problem with 'Multithreaded' feature + workaround #7774

Closed enomat closed 7 years ago

enomat commented 9 years ago

I run PPSSPP on my Galaxy S2 (I9100).

Multithreaded option doesn't have any effect if it's enabled before you start the game.

The only way to get it working:

  1. disable multithreaded,
  2. start the game
  3. then enable multithreaded.

So enable it only after you started the game. You have to do this everytime when you want to play (disable, start game, enable). The only work-around is to create a PPSSPP save file after you got it working.

For example you can test this bug with Colin McRae Rally 2005, because the Multithreaded feature makes noticeable difference with this game (on my Galaxy S2 it gives about 20% improvement in speed, combined with my other settings).

unknownbrackets commented 9 years ago

I'm not sure your assumption is right. More likely, this has to do with your device's thread scheduler.

As an example, it might be that your thread scheduler sees the thread doing all sorts of game-loading stuff at the beginning, and makes the all-important decision that it is not a heavy duty thread. After this, it simply puts the thread on the same core as your other threads - to save precious battery power.

In contrast (and this is still an example), when you enable the setting midgame, PPSSPP creates a brand new thread and moves the cpu work onto it. The heuristics are probably seeing what this thread does differently.

This can depend on your Android version, since heuristics change. It can also depend on your phone manufacturer and device. It's an unfortunate situation on mobile devices.

Now, that's not to say it wouldn't be nice to do something about this. My point is, I don't think your assumption that it "doesn't enable" from the start is correct. AFAICT it works fine. I don't have this Rally game, but on my Android 5.1.1 Nexus 5, I don't see different behavior in other games as you describe.

-[Unknown]

enomat commented 9 years ago

You might don't see different behaviour because your phone (Nexus 5) has much stronger CPU than my S2, so your device (or your games) doesn't benefit much from multithreading, because games already run fast.

My Galaxy S2 (I9100) has Android 4.1.2 .


My PPSSPP settings with performance comparison: The values were measured on the first map (Spain 1, morning), after the 5 seconds in-game countdown expired, but staying at the start position.

With default settings: FPS 18/60 SPEED 28%

With my settings (this is everything that I changed from default settings) -Frameskipping -- 2 -Simulate block transfer -- Disabled -Disable slower effects (speedup) -- Enabled and

screenshot_2015-06-13-18-36-05

But the bug is that if I keep multithreaded enabled and exit from game and restart it, it will behave like if multithreaded were disabled.

If the problem is with the thread scheduler, is it related to a certain brand (Samsung) or the old Android version (4.1.2)? Anyway, a possible work-around may be a timer in PPSSPP which checks whether 'Multithreaded' is enabled or not when a game is started. If it's enabled, then automatically disable it, then enable it after a few seconds. And limit this work-around for that certain brand or Android version.

unknownbrackets commented 9 years ago

It's not that I don't see a difference between multithreaded on and off - I do. What I don't see is different behavior when I turn it on before starting the game and when I turn it on later (though, I tested in different games.)

Well, doing it based on device is a bad solution. If we do a brand, then we penalize all devices from the brand that are made after the older ones with the problem. If we do it by device, we're left with a sea of literally around 20,000 different Android devices. Sure, you don't care much about the other 19,999 since the all that matters right now is your S2, but what about other people? Before answering, ask yourself what motivates me to care about you if you don't care about other people.

I do think potentially, newer Android versions just may have better, smarter schedulers. It may be that we could do this based on Android version alone. Probably the best solution to "trick" the governor would be to spin on both the gpu and cpu threads for a certain period of time - perhaps a second - burning a chunk of battery power in the process. Then proceed on. The solution of delaying it into X seconds after starting the game might only work for certain games.

What we really need is more data at this point. What other devices does it happen on, and what other devices does it not?

-[Unknown]

enomat commented 9 years ago

Nobody said that do it for one brand only and penalize others. It was just an idea, to make it for ALL brands whose devices has this problem. (Samsung was an example.) So it's not that I don't care about other devices. I do care about them. I always try to find a general solution for all cases. I just can't test them, because I don't have more Android devices. My bug report is based on my device which has stock Android. My idea is a general fix for all devices. The reason why I wrote that idea is to help finding a possible solution, investigating the problem. But since I'm not able to test which other devices has this problem, it's up to you (PPSSPP developers) to further test/investigate this problem. Restricting this fix for a certain brand/Android version was just a possibility in case when you recognize a consistency which brands/devices or Android version or software environment suffer from this problem.