Emulator Issues #4283
closedCoreTiming code cleanup patch
0%
Description
Before r7342 I had a huge FPS slowdown under linux. Patch r7342 seems to solve this issue and meanwhile I was trying to understand why, I have started to refactor the code.
I would like to submit this new version of CoreTiming.cpp that seems to me:
1°- more threadsafe, with locks as short as possible
2°- easier to understand thanks to more meaningful names of functions and a simpler design
3°- having all the events correctly ordered in a unique queue may prevent bad scheduling compared to previous design based on two queues.
The original version is based on a 2 queues design. One thread could keep on reading the events, getting a lock only once and refilling periodically the main queue with the pending events from the another queue. The drawback of this approach is that some events could be handle too late because they are waiting in the pending queue.
I this new version the locks are held only for a small time (mainly the necessary time to insert/remove events in the queue) and not all the time necessary to handle all the events as previously. So it should improved accuracy with very little speed decrease.
While doing some test under Mario Galaxy I could not see any speed difference, but it is a bit hard to evaluated.
Well I hope you will accept this patch.