Skip site navigation (1)Skip section navigation (2)
Date:      Tue, 19 Dec 2000 16:50:46 -0800 (PST)
From:      Luigi Rizzo <rizzo@aciri.org>
To:        grog@lemis.com (Greg Lehey)
Cc:        freebsd-hackers@FreeBSD.ORG, n@nectar.com, hackers@FreeBSD.ORG
Subject:   Re: Optimizations (was: Why not another style thread? (was Re: cvs commit: src/lib/libc/gen getgrent.c))
Message-ID:  <200012200050.eBK0okv70621@iguana.aciri.org>
In-Reply-To: <20001220110348.P43017@wantadilla.lemis.com> from Greg Lehey at "Dec 20, 2000 11: 3:48 am"

next in thread | previous in thread | raw e-mail | index | archive | help
> 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




Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?200012200050.eBK0okv70621>