From owner-freebsd-threads@FreeBSD.ORG Fri Nov 19 08:07:20 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 633DE16A4CE for ; Fri, 19 Nov 2004 08:07:20 +0000 (GMT) Received: from silver.he.iki.fi (helenius.fi [193.64.42.241]) by mx1.FreeBSD.org (Postfix) with ESMTP id 5455D43D45 for ; Fri, 19 Nov 2004 08:07:19 +0000 (GMT) (envelope-from pete@he.iki.fi) Received: from [193.64.42.134] (h86.vuokselantie10.fi [193.64.42.134]) by silver.he.iki.fi (8.13.1/8.11.4) with ESMTP id iAJ87ISL079654; Fri, 19 Nov 2004 10:07:18 +0200 (EET) (envelope-from pete@he.iki.fi) Message-ID: <419DA9B9.50105@he.iki.fi> Date: Fri, 19 Nov 2004 10:07:21 +0200 From: Petri Helenius User-Agent: Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.7.2) Gecko/20040803 X-Accept-Language: en-us, en MIME-Version: 1.0 To: Niall Douglas References: <419DA7EC.20473.1CFB6AE9@localhost> In-Reply-To: <419DA7EC.20473.1CFB6AE9@localhost> Content-Type: text/plain; charset=us-ascii; format=flowed Content-Transfer-Encoding: 7bit cc: freebsd-threads@freebsd.org 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:07:20 -0000 Niall Douglas wrote: >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. > > Are these mutexes spinlocks or "real" locks which make the thread actually yield if they have to wait longer? Or should I RTFS? :-) Pete