[Mesa-dev] [PATCH excerpt] mesa: Wrap unlikely() around conditions leading to _mesa_error().

Kenneth Graunke kenneth at whitecape.org
Wed Mar 4 02:34:25 PST 2015


On Monday, March 02, 2015 03:03:00 PM Eric Anholt wrote:
> Kenneth Graunke <kenneth at whitecape.org> writes:
> 
> > Generated by the following Coccinelle semantic patch:
> >
> > @@
> > expression E;
> > @@
> > if (
> > -E
> > +unlikely(E)
> >  )
> > { ... _mesa_error(...) ... }
> >
> > Improves performance in OglBatch7 (a CPU-bound microbenchmark) on
> > an i7 4750HQ (Haswell) by 1.08546% +/- 0.519734% (n=292).
> >
> > Signed-off-by: Kenneth Graunke <kenneth at whitecape.org>
> 
> Neat!
> 
> I think you're supposed to be able to get the same result by marking
> _mesa_error as attribute cold.  Then nobody can forget to mark their
> conditions as unlikely in the future.

Oh, neat!  I wasn't aware of __attribute__((cold)).

I tried it out and ran some measurements, this time on Baytrail (since
it should more more sensitive to CPU improvements like this).  Oddly,
the results were different:

attribute cold on _mesa_error: -1.60367% +/- 0.43555%
unlikely on all _mesa_error callers: -2.92994% +/- 0.0632798%

I haven't dug into the assembly yet to try and see why.

(It's also bizarre to me that these /hurt/ performance on Baytrail, on
a CPU-limited microbenchmark that never hits _mesa_error, both with or
without the performance governor set.  More mysteries...)

I'll have to try measuring on Haswell.
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 819 bytes
Desc: This is a digitally signed message part.
URL: <http://lists.freedesktop.org/archives/mesa-dev/attachments/20150304/5fa400bf/attachment.sig>


More information about the mesa-dev mailing list