mirror of
https://github.com/RPCS3/rpcs3.git
synced 2025-01-29 00:33:01 +00:00
perf hotfix for sys_timer_usleep
This commit is contained in:
parent
f0bd0b5a7c
commit
72fb3ba794
@ -1040,21 +1040,19 @@ void lv2_obj::sleep_timeout(cpu_thread& thread, u64 timeout)
|
||||
ppu->start_time = start_time;
|
||||
}
|
||||
|
||||
if (timeout && g_cfg.core.sleep_timers_accuracy != sleep_timers_accuracy_level::_all_timers)
|
||||
if (timeout)
|
||||
{
|
||||
const u64 wait_until = start_time + timeout;
|
||||
|
||||
// Register timeout if necessary
|
||||
for (auto it = g_waiting.begin(), end = g_waiting.end(); it != end; it++)
|
||||
for (auto it = g_waiting.cbegin(), end = g_waiting.cend();; it++)
|
||||
{
|
||||
if (it->first > wait_until)
|
||||
if (it == end || it->first > wait_until)
|
||||
{
|
||||
g_waiting.emplace(it, wait_until, &thread);
|
||||
return;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
g_waiting.emplace_back(wait_until, &thread);
|
||||
}
|
||||
|
||||
schedule_all();
|
||||
|
@ -218,6 +218,10 @@ struct lv2_obj
|
||||
template<bool is_usleep = false>
|
||||
static bool wait_timeout(u64 usec, cpu_thread* const cpu = nullptr)
|
||||
{
|
||||
// Clamp to max timeout accepted (also solves potential oveflows when scaling)
|
||||
if (usec > cond_variable::max_timeout) usec = cond_variable::max_timeout;
|
||||
|
||||
// Now scale the result
|
||||
usec = (usec * g_cfg.core.clocks_scale) / 100;
|
||||
|
||||
#ifdef __linux__
|
||||
|
@ -307,7 +307,7 @@ error_code sys_timer_usleep(ppu_thread& ppu, u64 sleep_time)
|
||||
|
||||
if (sleep_time)
|
||||
{
|
||||
lv2_obj::sleep(ppu, 0);
|
||||
lv2_obj::sleep(ppu, sleep_time);
|
||||
|
||||
lv2_obj::wait_timeout<true>(sleep_time);
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user