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.

"Likely" means "this is the code path where performance matters". If
you have to choose between adding 5ns to a codepath that normally
takes 30ns or to a codepath that normally takes 1000ns, you always
want to add it to the latter, no matter what the actual probabilities
are, unless the 30ns code path is a stupid error codepath that should
never happen in correct code.

Rich


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