This is the mail archive of the libc-alpha@sourceware.org mailing list for the glibc project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: [PATCH] Annotate malloc conditions with glibc_likely.


On Tue, Dec 10, 2013 at 09:54:31AM +0000, Will Newton wrote:
> On 9 December 2013 20:44, OndÅej BÃlka <neleai@seznam.cz> wrote:
> > Hi,
> >
> > Another little optimization in malloc is annotate that fastbins are
> > likely case. These should be fast path and given that other path
> > slower it should pay off.
> 
> In general I am not in favour of adding these types of annotations
> unless we can show they improve performance as they make code harder
> to read. They are also something of a blunt instrument - does "likely"
> mean will happen with 75% likelihood? 90%? 99%? I guess the results
> will vary with compiler and architecture as to whether or not the
> annotation helps or not.
>
A malloc is one of hottest place based on profiling data, followed by
assembly routines and code after these is not that frequent.

For most projects you can replace expects by creating test run and using
profile feedback. For libc you would first need to hack gcov for
that/make oprofile feedback reliable/write userspace profiler.

As how much this help actual probability does not matter much as
compiler do not have yet optimization where these make a difference.

Here benefits are mainly that gcc without hints does stupid things like
spilling five registers at start of function even these are unlikely
used.

Then there are icache and branch cache factors (taken path should be
more probable for static prediction and avoiding cache pollution.)
which are more relevant for cold code.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]