mutex performance

Niall Douglas s_sourceforge at nedprod.com
Fri Nov 19 00:00:01 PST 2004


-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

On 17 Nov 2004 at 21:06, 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 have a fairly basic producer/consumer application to optimize and
> I'm trying to decide on the performance-optimal synchronization
> method.

In my library TnFOX (http://www.nedprod.com/TnFOX/) where I've 
completely rewritten mutexs for speed:

                        FXAtomicInt   FXMutex
    SMP Build, 1 thread :  51203277  18389113
    SMP Build, 2 threads:   4793978   5337603
Non-SMP Build, 1 thread : 103305785  27352297
Non-SMP Build, 2 threads:  54929964  10978153

This is on a dual Athon 1700 (1.43Ghz), so that's 77.76 cycles per 
lock/unlock with SMP build and 52.28 cycles on non-SMP build. The 
difference between SMP and non-SMP is that the former uses the lock 
prefix on the x86 instructions.

So yes, I think there is some scope for improvement.

BTW 64 bit on ARM could be implemented using a spin lock to ensure 
exclusion during the two 32 bit operations. You just now need three 
32 bit words per 64 bit quantity, which is why FXAtomicInt has just 
such an entity in TnFOX.

Cheers,
Niall





-----BEGIN PGP SIGNATURE-----
Version: idw's PGP-Frontend 4.9.6.1 / 9-2003 + PGP 8.0.2

iQA/AwUBQZ2n7MEcvDLFGKbPEQKqbgCgltsn6ev7/pt4KIz8/Wm5S5jewEQAniWH
0JHu+0Z68UhS8dqKQpUeQ2aO
=WfiD
-----END PGP SIGNATURE-----


More information about the freebsd-threads mailing list