From: | Hao Lee <mixtrue(at)gmail(dot)com> |
---|---|
To: | Julien Rouhaud <julien(dot)rouhaud(at)dalibo(dot)com> |
Cc: | Craig Ringer <craig(dot)ringer(at)2ndquadrant(dot)com>, PostgreSQL Hackers <pgsql-hackers(at)postgresql(dot)org> |
Subject: | Re: Do we need the gcc feature "__builtin_expect" to promote the branches prediction? |
Date: | 2017-06-02 12:28:24 |
Message-ID: | CAGoxFiH7wOhTFVuM2-kWxSAPvbgfKCxr3Nm5ETRWcPmyVfGgTA@mail.gmail.com |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-hackers |
Okay. Thanks
On Fri, Jun 2, 2017 at 7:27 PM, Julien Rouhaud <julien(dot)rouhaud(at)dalibo(dot)com>
wrote:
> On 02/06/2017 12:50, Craig Ringer wrote:
> >
> >
> > On 2 Jun. 2017 16:42, "Hao Lee" <mixtrue(at)gmail(dot)com
> > <mailto:mixtrue(at)gmail(dot)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/CAKJS1f8yqRW3qx2CO9r4bqqvA2Vx6
> 8=3awbh8CJWTP9zXeoHMw(at)mail(dot)gmail(dot)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
>
From | Date | Subject | |
---|---|---|---|
Next Message | Robert Haas | 2017-06-02 12:47:53 | Re: Hash Functions |
Previous Message | Teodor Sigaev | 2017-06-02 12:24:05 | Re: Perfomance bug in v10 |