Re: [HACKERS] Do we need the gcc feature "__builtin_expect" topromote the branches prediction?

Поиск
Список
Период
Сортировка
От Hao Lee
Тема Re: [HACKERS] Do we need the gcc feature "__builtin_expect" topromote the branches prediction?
Дата
Msg-id CAGoxFiH7wOhTFVuM2-kWxSAPvbgfKCxr3Nm5ETRWcPmyVfGgTA@mail.gmail.com
обсуждение исходный текст
Ответ на Re: [HACKERS] Do we need the gcc feature "__builtin_expect" topromote the branches prediction?  (Julien Rouhaud <julien.rouhaud@dalibo.com>)
Список pgsql-hackers
Okay. Thanks

On Fri, Jun 2, 2017 at 7:27 PM, Julien Rouhaud <julien.rouhaud@dalibo.com> wrote:
On 02/06/2017 12:50, Craig Ringer wrote:
>
>
> On 2 Jun. 2017 16:42, "Hao Lee" <mixtrue@gmail.com
> <mailto:mixtrue@gmail.com>> wrote:
>
>     Hi all,
>            There is a lot of "if statement" in system, and GCC provides
>     a feature,"__builtin_expect", which  let compilers know which branch
>     is mostly run.
>
>
> Compilers and CPUs are really good at guessing this.
>
> Humans are wrong about it more than we'd like too.

+1

>
> It's surprisingly rarely s good idea to use branch prediction hints.
>
> See the vsrious Linux kernel discussions about this.
>
> If you find concrete sites of frequent or costly branch mis-prediction
> please point them out, with benchmarks.

And also see this thread:
https://www.postgresql.org/message-id/CAKJS1f8yqRW3qx2CO9r4bqqvA2Vx68=3awbh8CJWTP9zXeoHMw@mail.gmail.com

BTW Andres added support for likely/unlikely in aa3ca5e3dd6, but its
usage is still really limited.

--
Julien Rouhaud
http://dalibo.com - http://dalibo.org

В списке pgsql-hackers по дате отправления:

Предыдущее
От: Teodor Sigaev
Дата:
Сообщение: Re: [HACKERS] Perfomance bug in v10
Следующее
От: Robert Haas
Дата:
Сообщение: Re: [HACKERS] Hash Functions