Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

LV2: Introduce Dynamic Timer signals #16481

Open
wants to merge 4 commits into
base: master
Choose a base branch
from
Open

Conversation

elad335
Copy link
Contributor

@elad335 elad335 commented Dec 30, 2024

For a while, the emulator has dealt with LV2 timed syscalls pretty inefficiently:

  • With "Usleep" setting: the emulator would keep the thread awake for the last 500 (on Windows, 100 for the rest) microseconds of the syscall duration awake, which had increased CPU time significantly while also not actually working as expected in a highly active threading environment due to forced operating systems preemptions.
  • With "As Host" setting: none of the above, but the delay in the syscall schedule was huge! leading to various performance issues as well.

Instead, try a new thing: we know that direct thread notifications are very fast on every operaing systems, so try to systematically check for time-outs by other emulationh threads when they have little to no work themeselfs. This would eliminate the delay and cut on CPU time!
But hold on! what about times when other emulation threads do have work to be ?
The truth is that we cannot predict such cases with full accuracy, but what we can do is calculate the avarage response time of other threads to this in the past in games and see if it is valueable to opt for this mechanis instead. At the times when not, fallback to "Useleep" setting behaviour. This would provide accuracy in the "not well suited" cases too!

This adds the setting value "Dynamic" for LV2 timers accuracy, while it being the new default.

What to test:

  1. PPU usage.
  2. CPU usage.
  3. Framerate
  4. If Nier works properly.

Results: around 20% in CPU time specifically used by PPU in usleep syscalls is saved now, it's nice but it's a bit disappointing because there may be more potential there. That's it for this pr though.

@elad335 elad335 added Firmware: LLE Optimization Optimizes existing code labels Dec 30, 2024
@elad335 elad335 marked this pull request as draft December 30, 2024 07:26
@elad335 elad335 changed the title [TESTERS NEEDED] LV2: Introduce Dynamic Timer signals LV2: Introduce Dynamic Timer signals Dec 30, 2024
@elad335 elad335 force-pushed the spu32 branch 2 times, most recently from 991b3a5 to 3580387 Compare December 30, 2024 07:41
@elad335 elad335 marked this pull request as ready for review December 30, 2024 07:41
@elad335 elad335 added the ☘️ Power Saving Aims to reduce power consumption of RPCS3 label Dec 30, 2024
@elad335 elad335 force-pushed the spu32 branch 7 times, most recently from dd3f27a to 725fce4 Compare December 30, 2024 11:02
@elad335
Copy link
Contributor Author

elad335 commented Dec 30, 2024

It seems like the majority of USLEEP calls in games happen in loop and for short periods of time, while not currently targeted, I will add a case for it in the new setting.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Firmware: LLE Optimization Optimizes existing code ☘️ Power Saving Aims to reduce power consumption of RPCS3
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants