[PATCH] lib/tevent: Add trace point callback

simo idra at samba.org
Fri Jun 8 06:44:53 MDT 2012


On Fri, 2012-06-08 at 14:10 +0200, Volker Lendecke wrote: 
> On Fri, Jun 08, 2012 at 08:01:13AM -0400, simo wrote:
> > On Fri, 2012-06-08 at 13:53 +0200, Volker Lendecke wrote: 
> > > On Fri, Jun 08, 2012 at 07:36:10AM -0400, simo wrote:
> > > > On Fri, 2012-06-08 at 13:32 +0200, Volker Lendecke wrote: 
> > > > > On Fri, Jun 08, 2012 at 07:29:34AM -0400, simo wrote:
> > > > > > I guess it would also be a good idea to inline
> > > > > > tevent_trace_point_callback()
> > > > > 
> > > > > Are you sure? What about the branch prediction cache?
> > > > 
> > > > It really depends on how much this will end up being used.
> > > > Perhaps right now it is not a big deal, but tracing functions have the
> > > > bad habit of ending up being used in critical paths in the long run :)
> > > 
> > > Right. That's why I think there's a trade-off. How expensive
> > > is calling a function vs a branch prediction miss? We have
> > > an if-statement in that function that has the same outcome
> > > throughout the whole program run. Do we benefit from a
> > > correct branch prediction more than we do from a
> > > non-executed call/return?
> > 
> > I am not sure I see your point, as it is the function call is always
> > executed, the inline would remove that part. The if statement will
> > always be executed (eventually branch predicted) but in the main
> > function.
> 
> My understanding of the branch prediction cache and function
> inlining might be wrong, so please excuse if I am talking
> rubbish.
> 
> Function inlining if I understood it right makes a copy of
> the function that is being called everywhere. This means
> that we have the if-statement multiple times in the object
> code. If I understood the branch prediction cache right, it
> caches the result of an if-condition, indexed by instruction
> pointer. If we have the if-condition multiple times due to
> inlining, we pollute the cache more than we do when
> executing the condition in one place.
> 
> If that understanding is wrong, please update my knowledge.

I see what you mean, and it is a good question. I do not have the answer
but I am not sure that a miss would cause that much more work in the
case when tracing is off.

Simo.

-- 
Simo Sorce
Samba Team GPL Compliance Officer <simo at samba.org>
Principal Software Engineer at Red Hat, Inc. <simo at redhat.com>



More information about the samba-technical mailing list