From owner-freebsd-hackers Tue Dec 19 16:51: 3 2000 From owner-freebsd-hackers@FreeBSD.ORG Tue Dec 19 16:51:00 2000 Return-Path: Delivered-To: freebsd-hackers@freebsd.org Received: from iguana.aciri.org (iguana.aciri.org [192.150.187.36]) by hub.freebsd.org (Postfix) with ESMTP id 3E68437B400; Tue, 19 Dec 2000 16:51:00 -0800 (PST) Received: (from rizzo@localhost) by iguana.aciri.org (8.11.1/8.11.1) id eBK0okv70621; Tue, 19 Dec 2000 16:50:46 -0800 (PST) (envelope-from rizzo) From: Luigi Rizzo Message-Id: <200012200050.eBK0okv70621@iguana.aciri.org> Subject: Re: Optimizations (was: Why not another style thread? (was Re: cvs commit: src/lib/libc/gen getgrent.c)) In-Reply-To: <20001220110348.P43017@wantadilla.lemis.com> from Greg Lehey at "Dec 20, 2000 11: 3:48 am" To: grog@lemis.com (Greg Lehey) Date: Tue, 19 Dec 2000 16:50:46 -0800 (PST) Cc: freebsd-hackers@FreeBSD.ORG, n@nectar.com, hackers@FreeBSD.ORG X-Mailer: ELM [version 2.4ME+ PL43 (25)] MIME-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit Sender: rizzo@iguana.aciri.org 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? as all optimizations it's compiler dependent, and one case would be when the function call is removed by the compiler (inlined or the like) :) cheers luigi To Unsubscribe: send mail to majordomo@FreeBSD.org with "unsubscribe freebsd-hackers" in the body of the message