mirror of
https://github.com/RPCS3/rpcs3.git
synced 2025-07-08 16:01:42 +12:00
Use Linux timers for sleeps up to 1ms (#6697)
* Use Linux timers for sleeps up to 1ms (v3) The current sleep timer implementation basically offers two variants. Either wait the specified time exactly with a condition variable (as host) or use a combination of it with a thread yielding busy loop afterwards (usleep timer). While the second one is very precise it consumes CPU loops for each wait call below 50us. Games like Bomberman Ultra spam 30us waits and the emulator hogs low power CPUs. Switching to host mode reduces CPU consumption but gives a ~50us penalty for each wait call. Thus extending all sleeps by a factor of more than two. The following bugfix tries to improve the system timer for Linux by using Linux native timers for small wait calls below 1ms. This has two effects. - Host wait setting has much less wait overhead - usleep wait setting produces lower CPU overhead
This commit is contained in:
parent
6b1e1e4020
commit
925f2ce02f
3 changed files with 48 additions and 8 deletions
|
@ -118,6 +118,11 @@ class thread_base
|
|||
using native_entry = void*(*)(void* arg);
|
||||
#endif
|
||||
|
||||
#ifdef __linux__
|
||||
// Linux thread timer
|
||||
int m_timer = -1;
|
||||
#endif
|
||||
|
||||
// Thread handle (platform-specific)
|
||||
atomic_t<std::uintptr_t> m_thread{0};
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue