From owner-freebsd-hackers Wed Dec 20 2:20:53 2000 From owner-freebsd-hackers@FreeBSD.ORG Wed Dec 20 02:20:51 2000 Return-Path: Delivered-To: freebsd-hackers@freebsd.org Received: from relay.nuxi.com (nuxi.cs.ucdavis.edu [169.237.7.38]) by hub.freebsd.org (Postfix) with ESMTP id 69A2837B400 for ; Wed, 20 Dec 2000 02:20:51 -0800 (PST) Received: from dragon.nuxi.com (Ipittythefoolthattrustsident@trang.nuxi.com [209.152.133.57]) by relay.nuxi.com (8.9.3/8.9.3) with ESMTP id CAA12803; Wed, 20 Dec 2000 02:20:49 -0800 (PST) (envelope-from obrien@NUXI.com) Received: (from obrien@localhost) by dragon.nuxi.com (8.11.1/8.11.1) id eBKAKfe43015; Wed, 20 Dec 2000 02:20:41 -0800 (PST) (envelope-from obrien) Date: Wed, 20 Dec 2000 02:20:41 -0800 From: "David O'Brien" To: Greg Lehey Cc: freebsd-hackers@FreeBSD.ORG Subject: Re: Optimizations (was: Why not another style thread? (was Re: cvs commit: src/lib/libc/gen getgrent.c)) Message-ID: <20001220022041.B42809@dragon.nuxi.com> Reply-To: /dev/null@NUXI.com References: <20001217153656.F54486@holly.calldei.com> <20001217155648.C63080@hamlet.nectar.com> <20001217160442.H54486@holly.calldei.com> <20001217170316.A63227@hamlet.nectar.com> <200012180501.WAA87838@harmony.village.org> <20001218123108.A65143@hamlet.nectar.com> <200012181840.LAA92561@harmony.village.org> <20001218131112.B65143@hamlet.nectar.com> <20001219160152.E79058@dragon.nuxi.com> <20001220110348.P43017@wantadilla.lemis.com> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline User-Agent: Mutt/1.2.5i In-Reply-To: <20001220110348.P43017@wantadilla.lemis.com>; from grog@lemis.com on Wed, Dec 20, 2000 at 11:03:48AM +1030 X-Operating-System: FreeBSD 5.0-CURRENT Organization: The NUXI BSD group X-Pgp-Rsa-Fingerprint: B7 4D 3E E9 11 39 5F A3 90 76 5D 69 58 D9 98 7A X-Pgp-Rsa-Keyid: 1024/34F9F9D5 Sender: obrien@NUXI.com Sender: owner-freebsd-hackers@FreeBSD.ORG Precedence: bulk X-Loop: FreeBSD.ORG On Wed, Dec 20, 2000 at 11:03:48AM +1030, Greg Lehey wrote: > On Tuesday, 19 December 2000 at 16:01:52 -0800, David O'Brien wrote: > > On Mon, Dec 18, 2000 at 01:11:12PM -0600, Jacques A. Vidrine wrote: > >> /* Case 1 */ /* Case 2 */ > >> if (data) vs. free(data) > >> free(data); > > > > > > Actually from an optimization standpoint, #1 can be worse (ie, harder on > > the processor). You've got a conditional jump there that is using branch > > prediction HW to track (which means there is some other conditional > > branch you're not, you're fetching both the taken and not take paths, > > etc... If the function call isn't expensive, #2 can be "faster". > > In which processors is a function call anywhere near as cheap as a > conditional local branch? It is a known branch, thus no branch prediction resources and pre-fetch of taken and not-take paths has to be done. I am not saying it is definately cheaper but I do raise the point to remind people that there is more to think about with today's processors than the simple CPU's most studied in college. -- -- David (obrien@FreeBSD.org) GNU is Not Unix / Linux Is Not UniX To Unsubscribe: send mail to majordomo@FreeBSD.org with "unsubscribe freebsd-hackers" in the body of the message