Re: Semaphores slow???

From: J . A . Magallon (jamagallon@able.es)
Date: Wed Dec 27 2000 - 10:26:55 EST


On 2000.12.27 Rogier Wolff wrote:
> We have a typical semaphore application that has a producer and a
> consumer.
>
> Without the semaphores we are limited by the rest of the stuff to
> 10000 times around the loop per second. That's good.
>
> When we put the "push the semaphore" call in there, the rate drops to
> around 8000 per second. I'm not happy about that, but ok. When we add
> the "wait for bufferspace" semaphore wait in there, the rate drops to
> 4000 per second. This is way too low.
>

Look (s==write_sem, bs==write_buffer_sem):

cons prod
====================
            wait(bs)
post(bs)
wait(s) <wake>
            <work>
            post(s)
<wake> wait(bs)
<work>
post(bs)
wait(s) <wake>
            <work>
            post(s)
<wake> wait(bs)
<work>
post(bs)
wait(s) <wake>
.................

So there is no way that <work> can be done at the same time on
producer and consumer. So if you measure the loops per sec of the
producer (for example), in 'free run' you get 10k, in synchro run
with consumer you have just the half, because really prod and cons
are running sequentially, one after the other.

You need to thighten the mutexed zone for the thing to work in parallel
in an efficient way.

-- 
J.A. Magallon                                         $> cd pub
mailto:jamagallon@able.es                             $> more beer

Linux werewolf 2.2.19-pre3-aa3 #3 SMP Wed Dec 27 10:25:32 CET 2000 i686

- To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majordomo@vger.kernel.org Please read the FAQ at http://www.tux.org/lkml/



This archive was generated by hypermail 2b29 : Sun Dec 31 2000 - 21:00:09 EST