From owner-freebsd-hackers Tue Dec 19 16:34: 6 2000 From owner-freebsd-hackers@FreeBSD.ORG Tue Dec 19 16:34:02 2000 Return-Path: Delivered-To: freebsd-hackers@freebsd.org Received: from wantadilla.lemis.com (wantadilla.lemis.com [192.109.197.80]) by hub.freebsd.org (Postfix) with ESMTP id 914C637B402; Tue, 19 Dec 2000 16:34:00 -0800 (PST) Received: by wantadilla.lemis.com (Postfix, from userid 1004) id 829D46AB68; Wed, 20 Dec 2000 11:03:48 +1030 (CST) Date: Wed, 20 Dec 2000 11:03:48 +1030 From: Greg Lehey To: freebsd-hackers@FreeBSD.ORG Cc: "Jacques A. Vidrine" , hackers@FreeBSD.ORG Subject: Optimizations (was: Why not another style thread? (was Re: cvs commit: src/lib/libc/gen getgrent.c)) Message-ID: <20001220110348.P43017@wantadilla.lemis.com> References: <20001217153129.B63080@hamlet.nectar.com> <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> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline User-Agent: Mutt/1.2.5i In-Reply-To: <20001219160152.E79058@dragon.nuxi.com>; from obrien@FreeBSD.ORG on Tue, Dec 19, 2000 at 04:01:52PM -0800 Organization: LEMIS, PO Box 460, Echunga SA 5153, Australia Phone: +61-8-8388-8286 Fax: +61-8-8388-8725 Mobile: +61-418-838-708 WWW-Home-Page: http://www.lemis.com/~grog X-PGP-Fingerprint: 6B 7B C3 8C 61 CD 54 AF 13 24 52 F8 6D A4 95 EF Sender: owner-freebsd-hackers@FreeBSD.ORG Precedence: bulk X-Loop: FreeBSD.ORG 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? Greg -- Finger grog@lemis.com for PGP public key See complete headers for address and phone numbers To Unsubscribe: send mail to majordomo@FreeBSD.org with "unsubscribe freebsd-hackers" in the body of the message