[PATCH 2/7] Add 'likely' and 'unlikely' macros

Peter Harris pharris at opentext.com
Fri May 15 15:34:08 PDT 2015


On 2015-05-15 01:48, Alan Coopersmith wrote:
> 
> Speaking of which, something I've wondered about for a while, but never
> had time to test, is if telling the server to optimize for valid requests
> would make a difference, such as:

>  #define REQUEST_AT_LEAST_SIZE(req) \
> -    if ((sizeof(req) >> 2) > client->req_len )\
> +    if (_X_UNLIKELY((sizeof(req) >> 2) > client->req_len )) \
>           return(BadLength)

> If anyone wants to try it out and report back, please do so!

Slightly less than 1% improvement on x11perf -noop. Stable over multiple
runs:

  before           after         Operation
----------   -----------------   --------------------
13800000.0   13900000.0 (1.01)   X protocol NoOperation

I didn't try the full patch or a full x11perf run, but it seems unlikely
that it would be significant on a real load.

Test environment:
Intel(R) Xeon(R) CPU E5-1607 v2 @ 3.00GHz
gcc 4.9.2-10ubuntu13
Relevant CFLAGS: -m64 -mtune=generic -O2 -flto

Peter Harris
-- 
               Open Text Connectivity Solutions Group
Peter Harris                    http://connectivity.opentext.com/
Research and Development        Phone: +1 905 762 6001
pharris at opentext.com            Toll Free: 1 877 359 4866


More information about the xorg-devel mailing list