[MPlayer-dev-eng] [PATCH] use pthreads for caching
Rich Felker
dalias at aerifal.cx
Sat Jan 27 21:41:08 CET 2007
On Sat, Jan 27, 2007 at 05:45:20PM +0200, Uoti Urpala wrote:
> On Sat, 2007-01-27 at 10:09 -0500, Rich Felker wrote:
> > Yes. It's not a matter of the implementation being fast or slow. It's
> > fundamentally impossible to make synchronization fast. Each "lock"
> > prefix requires a couple hundred cycles on my machine, and I'm told
> > it's even worse on machines with higher clocks.
>
> Where did you get those numbers?
Timing my spinlock implementation with an without the lock prefix on
the xchg opcode, in a setting with no contention (no threads).
> On a 1837 MHz machine with up to date
> software this loop
>
> for (int i=0; i < 100000000; i++) {
> pthread_mutex_lock(&mut);
> pthread_mutex_unlock(&mut);
> }
>
> takes about 3.9 seconds. That means 72 cycles per loop, and less than 36
> cycles per call - and that's with function call overhead included.
Have threads actually been initialized yet? If not, the lock is
probably a no-op.
Rich
More information about the MPlayer-dev-eng
mailing list