From owner-cvs-all@FreeBSD.ORG Tue Oct 30 13:26:30 2007 Return-Path: Delivered-To: cvs-all@FreeBSD.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id F170716A469; Tue, 30 Oct 2007 13:26:29 +0000 (UTC) (envelope-from kensmith@cse.Buffalo.EDU) Received: from phoebe.cse.buffalo.edu (phoebe.cse.buffalo.edu [128.205.32.89]) by mx1.freebsd.org (Postfix) with ESMTP id ADC4613C4A3; Tue, 30 Oct 2007 13:26:29 +0000 (UTC) (envelope-from kensmith@cse.Buffalo.EDU) Received: from [128.205.32.4] (opus.cse.buffalo.edu [128.205.32.4]) (authenticated bits=0) by phoebe.cse.buffalo.edu (8.14.1/8.13.7) with ESMTP id l9UDQAK2021908 (version=TLSv1/SSLv3 cipher=RC4-MD5 bits=128 verify=NO); Tue, 30 Oct 2007 09:26:10 -0400 (EDT) (envelope-from kensmith@cse.buffalo.edu) From: Ken Smith To: David Xu In-Reply-To: <47272EC0.1030204@freebsd.org> References: <200710292101.l9TL1mAE049561@repoman.freebsd.org> <47268F17.1000106@freebsd.org> <4726E9AB.4050209@FreeBSD.org> <4726F130.2060709@freebsd.org> <4726F7E9.2060403@FreeBSD.org> <4726FB01.4060704@freebsd.org> <47270410.2020802@FreeBSD.org> <47272EC0.1030204@freebsd.org> Content-Type: multipart/signed; micalg=pgp-sha1; protocol="application/pgp-signature"; boundary="=-kHHNAJEx+o+huuu0J7Zp" Organization: U. Buffalo CSE Department Date: Tue, 30 Oct 2007 09:26:10 -0400 Message-Id: <1193750770.25313.7.camel@opus.cse.buffalo.edu> Mime-Version: 1.0 X-Mailer: Evolution 2.10.2 FreeBSD GNOME Team Port X-DCC-Buffalo.EDU-Metrics: phoebe.cse.buffalo.edu 1029; Body=0 Fuz1=0 Fuz2=0 X-Spam-Status: No, score=0.0 required=5.0 tests=none autolearn=failed version=3.2.3 X-Spam-Checker-Version: SpamAssassin 3.2.3 (2007-08-08) on phoebe.cse.buffalo.edu Cc: Daniel Eischen , cvs-src@FreeBSD.org, Kris Kennaway , 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 X-BeenThere: cvs-all@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: CVS commit messages for the entire tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 30 Oct 2007 13:26:30 -0000 --=-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 . > >=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--