| From: | Julien Rouhaud <julien(dot)rouhaud(at)dalibo(dot)com> |
|---|---|
| To: | Craig Ringer <craig(dot)ringer(at)2ndquadrant(dot)com>, Hao Lee <mixtrue(at)gmail(dot)com> |
| Cc: | 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 11:27:36 |
| Message-ID: | d696d555-e8ff-3fbb-7998-1596b188d198@dalibo.com |
| Views: | Whole Thread | Raw Message | Download mbox | Resend email |
| Thread: | |
| Lists: | pgsql-hackers |
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/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
| From | Date | Subject | |
|---|---|---|---|
| Next Message | Amit Kapila | 2017-06-02 12:09:46 | Re: Default Partition for Range |
| Previous Message | Amit Khandekar | 2017-06-02 11:07:14 | Re: UPDATE of partition key |