wine CPU usage and CreateWaitableTimer

andrea mariofutire at googlemail.com
Wed Jul 1 14:43:54 CDT 2015


On 07/06/15 19:08, Sebastian Lackner wrote:
> Hello andrea,
>
> good catch, its actually a bug in SystemClockAdviseThread. A patch like:
>
> --- snip ---
> diff --git a/dlls/quartz/systemclock.c b/dlls/quartz/systemclock.c
> index 043299b..ac41a49 100644
> --- a/dlls/quartz/systemclock.c
> +++ b/dlls/quartz/systemclock.c
> @@ -127,6 +127,7 @@ static DWORD WINAPI SystemClockAdviseThread(LPVOID lpParam) {
>         it = nextit;
>       }
>       if (NULL != it) timeOut = (DWORD) ((it->rtBaseTime + it->rtIntervalTime) - curTime) / (REFERENCE_TIME)10000;
> +    else timeOut = INFINITE;
>
>       /** Now Periodics Advice: semi sorted list (sort cannot be used) */
>       for (it = This->pPeriodicAdvise; NULL != it; it = it->next) {
> --- snip ---
>
> Seems to be sufficient to fix it. I will review the code for other errors one more time,
> and then submit the patch.
>

Hi,

I've just tried wine 1.7.45 and things have changed.

Better: the system time has been reduced and it is comparable to CreateWaitableTimer

http://pastebin.com/K55znWFQ

this code check the 4 implementations


time ./a.out 2 2

this does a wait every 2 ms for a total of 5 with IReferenceClock

results

real	0m5.090s
user	0m0.160s
sys	0m0.214s


time ./a.out 2 1

this does a wait every 2 ms for a total of 5 with CreateWaitableTimer

results

real	0m5.157s
user	0m0.040s
sys	0m0.115s



Worse: is the wait is low (guess it depends on CPU speed as well) the actual average wait gets bigger.
So if I wait for 5 seconds every 1 ms, with CreateWaitableTimer I actually do 5000 waits and on 
average they are 1.00006 apart (it is ok as I asked to do 1 ms wait)

On the other had with IReferenceClock I get an average of 1.30225 ms (it should have been 1)


You can use the source code I linked above and compare

./a.out 1 1		// 1ms wait with CreateWaitableTimer (5 sec total)
./a.out 1 2             // 1ms wait with IReferenceClock     (5 sec total)

On an other PC (probably slower) things started getting bad at 2ms wait (which results 2.5ms 
average) and terrible with 1ms wait (9ms on average).


So the patch is very good for bigger periods, but not so good for very small periods.

Regards

Andrea





More information about the wine-devel mailing list