From owner-freebsd-threads@FreeBSD.ORG Fri Nov 19 08:00:01 2004 Return-Path: Delivered-To: freebsd-threads@freebsd.org Received: from mx1.FreeBSD.org (mx1.freebsd.org [216.136.204.125]) by hub.freebsd.org (Postfix) with ESMTP id 51AAA16A4CE for ; Fri, 19 Nov 2004 08:00:01 +0000 (GMT) Received: from psych.st-andrews.ac.uk (psych.st-and.ac.uk [138.251.11.1]) by mx1.FreeBSD.org (Postfix) with ESMTP id 1DB6D43D1D for ; Fri, 19 Nov 2004 08:00:00 +0000 (GMT) (envelope-from s_sourceforge@nedprod.com) Received: from kate (res04-ned6.res.st-and.ac.uk [138.251.234.67]) by psych.st-andrews.ac.uk (8.9.1a/8.9.1) with SMTP id HAA17350 for ; Fri, 19 Nov 2004 07:59:58 GMT From: "Niall Douglas" To: freebsd-threads@freebsd.org Date: Fri, 19 Nov 2004 07:59:40 -0000 MIME-Version: 1.0 Message-ID: <419DA7EC.20473.1CFB6AE9@localhost> Priority: normal In-reply-to: <419BA142.9000801@he.iki.fi> X-PM-Encryptor: IDWPGP-PM32, 4 X-mailer: Pegasus Mail for Windows (4.21c) Content-type: text/plain; charset=US-ASCII Content-transfer-encoding: 7BIT Content-description: Mail message body Content-Transfer-Encoding: 7BIT Subject: Re: mutex performance X-BeenThere: freebsd-threads@freebsd.org X-Mailman-Version: 2.1.1 Precedence: list List-Id: Threading on FreeBSD List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 19 Nov 2004 08:00:01 -0000 -----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-----