[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: Using __builtin_expect (likely/unlikely macros)
From: |
Alex Gramiak |
Subject: |
Re: Using __builtin_expect (likely/unlikely macros) |
Date: |
Tue, 16 Apr 2019 10:10:39 -0600 |
User-agent: |
Gnus/5.13 (Gnus v5.13) Emacs/26.2 (gnu/linux) |
Paul Eggert <address@hidden> writes:
>> BTW I think instead of marking branches as likely or unlikely, I'd
>> prefer to tell GCC that some functions "should be slow"
>> (e.g. emacs_abort) so it optimizes the code paths that don't go through
>> those functions to the detriment of those that do.
>
> GCC has the function attribute 'cold' for that. This is less intrusive than
> __builtin_expect and so would be preferable. Still, the GCC manual says that
> __attribute__ ((cold)) is ignored when profile feedback is available, which is
> another indication that people who care about performance should be using
> -fprofile-use etc. And as far as I know __attribute__ ((cold)) is rarely used:
> even glibc uses it only once, in obscure code never used on GNU/Linux.
> Presumably this is partly because the attribute didn't exist until about five
> years ago.
It would still be good to use it for default builds, no? The GCC
documentation states:
It is thus useful to mark functions used to handle unlikely
conditions, such as perror, as cold to improve optimization of hot
functions that do call marked functions in rare occasions.
So the error/signal calls, wrong_type_argument, etc. would be good
places for this. It doesn't indicate anything to the programmer at call
sites, but that point is controversial, so slapping a few attributes
down seems like a better way to go.
- Re: Using __builtin_expect (likely/unlikely macros), (continued)
- Re: Using __builtin_expect (likely/unlikely macros), Alex Gramiak, 2019/04/14
- Re: Using __builtin_expect (likely/unlikely macros), Paul Eggert, 2019/04/15
- Re: Using __builtin_expect (likely/unlikely macros), Alex Gramiak, 2019/04/15
- Re: Using __builtin_expect (likely/unlikely macros), Eli Zaretskii, 2019/04/15
- Re: Using __builtin_expect (likely/unlikely macros), Alex Gramiak, 2019/04/16
- Re: Using __builtin_expect (likely/unlikely macros), Eli Zaretskii, 2019/04/16
- Re: Using __builtin_expect (likely/unlikely macros), Alex Gramiak, 2019/04/16
- Re: Using __builtin_expect (likely/unlikely macros), Paul Eggert, 2019/04/15
- Re: Using __builtin_expect (likely/unlikely macros), Stefan Monnier, 2019/04/16
- Re: Using __builtin_expect (likely/unlikely macros), Paul Eggert, 2019/04/16
- Re: Using __builtin_expect (likely/unlikely macros),
Alex Gramiak <=
- Re: Using __builtin_expect (likely/unlikely macros), Paul Eggert, 2019/04/16
- Re: Using __builtin_expect (likely/unlikely macros), Alex Gramiak, 2019/04/16
- Re: Using __builtin_expect (likely/unlikely macros), Alex Gramiak, 2019/04/16
- Re: Using __builtin_expect (likely/unlikely macros), Stefan Monnier, 2019/04/16
- Re: Using __builtin_expect (likely/unlikely macros), Konstantin Kharlamov, 2019/04/16
- Re: Using __builtin_expect (likely/unlikely macros), Paul Eggert, 2019/04/18
- Re: Using __builtin_expect (likely/unlikely macros), Konstantin Kharlamov, 2019/04/18
- Re: Using __builtin_expect (likely/unlikely macros), Andy Moreton, 2019/04/18
- Re: Using __builtin_expect (likely/unlikely macros), Paul Eggert, 2019/04/18
- Re: Using __builtin_expect (likely/unlikely macros), Andy Moreton, 2019/04/18