[Development] Mutex future directions

Thiago Macieira thiago.macieira at intel.com
Mon May 21 14:58:43 CEST 2012


On segunda-feira, 21 de maio de 2012 08.34.32, bradley.hughes at nokia.com wrote:
> On May 18, 2012, at 8:34 PM, ext Thiago Macieira wrote:
> > Recommendations (priority):
> > 
> > (P0) de-inline QBasicMutex locking functions until we solve some or all of
> > the below problems
> 
> I agree with this, so that it gives a chance to fix the performance
> regressions on Mac at a later date (since it probably won't be fixed before
> 5.0 is released).

Some notes from the IRC discussion this morning between Olivier, Brad and 
myself:

 * QMutex contended performance has dropped considerably on Mac from 4.8 to 
5.0 (it's 10x slower)
 * QMutex contended performance on Mac is now actually similar to the 
pthread_mutex_t performance (read: contended QMutex on 4.8 is 10x faster than 
pthread_mutex_t)
 * changing the QMutex implementation to use the generic Unix codepath on Mac 
makes it 2x slower
 * the non-Linux code in QBasicMutex::lockInternal is considered complex and 
hard to read by both Brad and myself

Brad: could you please provide what is, to the best of your knowledge today, 
the combination of tricks that made 4.8 fast?

 * QMutex de-inlining and the Mac performance issues are orthogonal.
 * QMutex "de-inlining" should be understood more correctly as: removing the 
testAndSet calls from the inline functions. The inline functions should remain 
inline.
 * The de-inlining is important for Valgrind (helgrind / DRD) to work 
properly, even in release mode

Note that there's another trick that QMutex can apply under valgrind but 
QBasicMutex cannot: if the QMutex constructor initialises the d pointer to 
anything non-null and different from 3, the inlined testAndSet will fail, so 
valgrind can properly hijack the lock and unlock functions.

-- 
Thiago Macieira - thiago.macieira (AT) intel.com
  Software Architect - Intel Open Source Technology Center
     Intel Sweden AB - Registration Number: 556189-6027
     Knarrarnäsgatan 15, 164 40 Kista, Stockholm, Sweden
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 190 bytes
Desc: This is a digitally signed message part.
URL: <http://lists.qt-project.org/pipermail/development/attachments/20120521/41e3a53e/attachment.sig>


More information about the Development mailing list