[MPlayer-dev-eng] [PATCH] use timer-lx.c on darwin & osx
Nicolas Plourde
nicolas.plourde at sympatico.ca
Tue Apr 26 22:19:07 CEST 2005
On 26-Apr-05, at 1:55 PM, Arpi wrote:
>
> i'm against.
> maybe as an option...
> timer-osx uses a much more precise timer, than linux's usleep
> thing which dosnt work far as accurate on osx as on linux.
> (on linux it's mostly using /dev/rtc to do the job, but on
> osx it doesnt exists so it will fallback to inaccurate usleep)
>
I ran some benchmark using both timer and my result are showing
not much performance lost using timer-darwin.c(not taking cpu load
into account).
But has previously reported by Dieter Shirley <dete at mac.com>,
usec_sleep is called way too often.
quote:
>> The problem, somewhat ironically, is that the Darwin usleep()
>> timer is
>> really quite accurate, much more accurate than the 10ms that mplayer
>> seems to assume. Here's the code from mplayer.c:2440:
>>
>> float min=softsleep?0.021:0.005;
>> current_module="sleep_timer";
>> while(time_frame>min){
>> if(time_frame<=0.020)
>> usec_sleep(0); // sleeps 1 clock tick (10ms)!
>> else
>> usec_sleep(1000000*(time_frame-0.020));
>> time_frame-=GetRelativeTime();
>>
>> What ends up happening with this code is that usec_sleep(0) gets
>> called
>> *hundreds* of times for each frame of video. This isn't a trivial
>> call
>> either, since it touches the kernel. The upshot is that sleeping can
>> take up to 30% of the CPU, more than decoding the video!
here is the "shark" report (original code):
- 22.4% ml_set_interrupts_enabled (mach_kernel)
- 8.3% __memcpy (commpage [libSystem.B.dylib])
7.7% shandler (mach_kernel)
+ 7.6% nanosleep (libSystem.B.dylib)
| - 7.6% usec_sleep (mplayer_darwin_20)
- 4.7% altivec_yuv2_bgra32 (mplayer_darwin_20)
- 3.5% synth_1to1 (mplayer_darwin_20)
- 2.3% msmpeg4_decode_block (mplayer_darwin_20)
- 1.7% __gettimeofday (commpage [libSystem.B.dylib])
- 1.5% int2float (mplayer_darwin_20)
- 1.4% gldDestroyQuery (ATIRadeon8500GLDriver)
- 1.4% idct_add_altivec (mplayer_darwin_20)
- 1.4% put_pixels16_altivec (mplayer_darwin_20)
- 1.1% __fixunsdfdi (libSystem.B.dylib)
and now patched with Dieter recommendation:
- 15.5% __memcpy (commpage [libSystem.B.dylib])
- 8.2% altivec_yuv2_bgra32 (mplayer_darwin_05)
- 5.8% synth_1to1 (mplayer_darwin_05)
- 4.0% msmpeg4_decode_block (mplayer_darwin_05)
- 3.5% ml_set_interrupts_enabled (mach_kernel)
- 2.8% put_pixels16_altivec (mplayer_darwin_05)
- 2.5% gldDestroyQuery (ATIRadeon8500GLDriver)
- 2.3% idct_add_altivec (mplayer_darwin_05)
...
+ 0.1% nanosleep (libSystem.B.dylib)
| - 0.1% usec_sleep (mplayer_darwin_05)
suggestion?
====
Nicolas Plourde <nicolas.plourde at sympatico.ca>
More information about the MPlayer-dev-eng
mailing list