mutex performance

Daniel Eischen deischen at freebsd.org
Wed Nov 17 11:18:10 PST 2004


On Wed, 17 Nov 2004, Petri Helenius wrote:

>
> Do you feel that mutex performance could be improved from the current
> 2-3 million lock/unlock operations per second on uncontested mutexes on
> ~2.4Ghz prescott? Which seems to be about 1000 cycles per lock/unlock.

I'm not sure what you're trying to say above.

> I have a fairly basic producer/consumer application to optimize and I'm
> trying to decide on the performance-optimal synchronization method.

Mutex performance is not optimal since I designed the low-level
locking so that it would work on 80386 which doesn't have cmpxchg.
The mutexes are also pointers instead of actual structures, so
there's an extra indirection and checks for NULL.  libthr mutexes
should be faster in the uncontested case since they do use the
atomic compare/set primitives.

I want to change libpthread locks to drop the 80386 support
and just use the atomic primitives for default mutex types.
In 6.0, we'll also change all the mutexes, CVs, and semaphores
so they aren't pointers -- that will save an indirection and
also allow them to be process shared.

-- 
DE



More information about the freebsd-threads mailing list