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

Brian Paul brianp at vmware.com
Tue Mar 3 07:24:04 PST 2015


On 03/02/2015 06:56 PM, Matt Turner wrote:
> On Mon, Mar 2, 2015 at 4:37 PM, Brian Paul <brianp at vmware.com> wrote:
>> On 03/02/2015 04:03 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.
>>
>>
>> I suspect unlikely() would be supported by more compilers than 'cold'.
>
> FWIW, this link [0] says MSVC doesn't implement hot/cold nor unlikely.

Thanks for checking on that.  I was thinking that MSVC had something 
like unlikely/expect but I guess I was misremembering.

MSVC is the compiler I had in mind in my reply to Eric's message.


> Other than MSVC... there's really gcc and clang. I'd opt for the ~10
> line patch :)

Sounds good then.

-Brian



More information about the mesa-dev mailing list