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

2017-06-05 Thread Craig Ringer
On 6 June 2017 at 10:44, Hao Lee wrote: > and another things come into my mind, in some scenario, as we know that the > native library is not the most effective way to do that, such as, allocation > a large amount of memories by using "alloc()"... and "memmove()", so on. As >

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

2017-06-05 Thread Hao Lee
and another things come into my mind, in some scenario, as we know that the native library is not the most effective way to do that, such as, allocation a large amount of memories by using "alloc()"... and "memmove()", so on. As the SIMD instruction became the standard in CPU, therefore, we can

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

2017-06-02 Thread Andres Freund
Hi, On 2017-06-02 16:40:56 +0800, Hao Lee 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. as we known, miss-prediction will lead the performance > lost(because the CPU

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

2017-06-02 Thread Hao Lee
Okay. Thanks On Fri, Jun 2, 2017 at 7:27 PM, Julien Rouhaud wrote: > On 02/06/2017 12:50, Craig Ringer wrote: > > > > > > On 2 Jun. 2017 16:42, "Hao Lee" > > wrote: > > > > Hi all, > >There is a lot of "if

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

2017-06-02 Thread Julien Rouhaud
On 02/06/2017 12:50, Craig Ringer wrote: > > > On 2 Jun. 2017 16:42, "Hao Lee" > wrote: > > Hi all, >There is a lot of "if statement" in system, and GCC provides > a feature,"__builtin_expect", which let compilers know which

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

2017-06-02 Thread Craig Ringer
On 2 Jun. 2017 16:42, "Hao Lee" 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