diff --git a/rpcs3/Emu/Cell/SPUThread.cpp b/rpcs3/Emu/Cell/SPUThread.cpp index f724dd5539..c6a5c13034 100644 --- a/rpcs3/Emu/Cell/SPUThread.cpp +++ b/rpcs3/Emu/Cell/SPUThread.cpp @@ -159,10 +159,8 @@ namespace spu { if (remaining >= native_jiffy_duration_us) std::this_thread::sleep_for(1ms); - else if (remaining > 100) - std::this_thread::yield(); else - busy_wait(); + std::this_thread::yield(); const auto now = get_system_time(); const auto elapsed = now - start; diff --git a/rpcs3/Emu/Cell/lv2/sys_timer.cpp b/rpcs3/Emu/Cell/lv2/sys_timer.cpp index bf3103b03f..468212e02c 100644 --- a/rpcs3/Emu/Cell/lv2/sys_timer.cpp +++ b/rpcs3/Emu/Cell/lv2/sys_timer.cpp @@ -296,19 +296,29 @@ error_code sys_timer_usleep(ppu_thread& ppu, u64 sleep_time) if (sleep_time) { + // Host scheduler quantum for windows (worst case) + // NOTE: On ps3 this function has very high accuracy + const u32 host_min_quantum = 500; + u64 passed = 0; u64 remaining; lv2_obj::sleep(ppu, sleep_time); - while (sleep_time > passed) + while (sleep_time >= passed) { remaining = sleep_time - passed; - if (remaining > 500) - thread_ctrl::wait_for(remaining - (remaining % 500)); + if (remaining > host_min_quantum) + { + // Wait on multiple of min quantum for large durations + thread_ctrl::wait_for(remaining - (remaining % host_min_quantum)); + } else - busy_wait(4000); + { + // Try yielding. May cause long wake latency but helps weaker CPUs a lot by alleviating resource pressure + std::this_thread::yield(); + } passed = (get_system_time() - ppu.start_time); }