Date: Tue, 30 Oct 2007 09:26:10 -0400 From: Ken Smith <kensmith@cse.Buffalo.EDU> To: David Xu <davidxu@FreeBSD.org> Cc: Daniel Eischen <deischen@FreeBSD.org>, cvs-src@FreeBSD.org, Kris Kennaway <kris@FreeBSD.org>, src-committers@FreeBSD.org, cvs-all@FreeBSD.org Subject: Re: cvs commit: src/lib/libthr/thread thr_mutex.c src/lib/libkse/thread thr_mutex.c src/include pthread.h Message-ID: <1193750770.25313.7.camel@opus.cse.buffalo.edu> In-Reply-To: <47272EC0.1030204@freebsd.org> References: <200710292101.l9TL1mAE049561@repoman.freebsd.org> <47268F17.1000106@freebsd.org> <Pine.GSO.4.64.0710292207140.19572@sea.ntplx.net> <4726E9AB.4050209@FreeBSD.org> <4726F130.2060709@freebsd.org> <4726F7E9.2060403@FreeBSD.org> <4726FB01.4060704@freebsd.org> <47270410.2020802@FreeBSD.org> <47272EC0.1030204@freebsd.org>
next in thread | previous in thread | raw e-mail | index | archive | help
--=-kHHNAJEx+o+huuu0J7Zp Content-Type: text/plain Content-Transfer-Encoding: quoted-printable On Tue, 2007-10-30 at 21:16 +0800, David Xu wrote: > Kris Kennaway wrote: > >=20 > > PTHREAD_ADAPTIVE_MUTEX_INITIALIZER_NP is just in <pthread.h>. > >=20 > > /* > > * Static initialization values. > > */ > > #define PTHREAD_MUTEX_INITIALIZER NULL > > #define PTHREAD_ADAPTIVE_MUTEX_INITIALIZER_NP NULL > > #define PTHREAD_COND_INITIALIZER NULL > > #define PTHREAD_RWLOCK_INITIALIZER NULL > >=20 > >>>> I remembered mysql uses this macro to initialize spin mutex, and you > >>>> indead needs a patch to let it work > >>> > >>> > >>> No, with the code I committed mysql detects and uses it out of the=20 > >>> box, without requiring any patches. It is easy to measure the=20 > >>> resulting 30% performance improvement at high loads ;-) > >>> > >> see above, I didn't see any code set PTHREAD_MUTEX_ADAPTIVE_NP type. > >=20 > > The code is already in mysql for use with glibc. It basically does > >=20 > > #ifdef PTHREAD_ADAPTIVE_MUTEX_INITIALIZER_NP > > /* > > * Use PTHREAD_MUTEX_ADAPTIVE_NP for the mutexes we know will benefit > > * from it > > */ > > ... > > #endif > >=20 > > so it just works. > >=20 >=20 > I can not find code in libthr setting mutex's member field m_type to > PTHREAD_MUTEX_ADAPTIVE_NP by your change, so how can it work as > expected ? >=20 Wouldn't you expect that it's mysql that's setting the mutex's member field? Something like this chunk of code from mysql perhaps? #ifdef PTHREAD_ADAPTIVE_MUTEX_INITIALIZER_NP /* Set mutex type to "fast" a.k.a "adaptive" In this case the thread may steal the mutex from some other thread that is waiting for the same mutex. This will save us some context switches but may cause a thread to 'starve forever' while waiting for the mutex (not likely if the code within the mutex is short). */ pthread_mutexattr_init(&my_fast_mutexattr); pthread_mutexattr_settype(&my_fast_mutexattr, PTHREAD_MUTEX_ADAPTIVE_NP); #endif --=20 Ken Smith - From there to here, from here to | kensmith@cse.buffalo.edu there, funny things are everywhere. | - Theodore Geisel | --=-kHHNAJEx+o+huuu0J7Zp Content-Type: application/pgp-signature; name=signature.asc Content-Description: This is a digitally signed message part -----BEGIN PGP SIGNATURE----- Version: GnuPG v1.4.7 (FreeBSD) iD8DBQBHJzDe/G14VSmup/YRAlKyAJ4kyUpYt50vTgSeU91hhPZqx0lFegCfbOJF PeaDIStrTnIGiIJDBVxip88= =K1GU -----END PGP SIGNATURE----- --=-kHHNAJEx+o+huuu0J7Zp--
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?1193750770.25313.7.camel>