On 02/06/2017 12:50, Craig Ringer wrote: > > > On 2 Jun. 2017 16:42, "Hao Lee" <mixt...@gmail.com > <mailto:mixt...@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=3awbh8cjwtp9zxeo...@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 -- Sent via pgsql-hackers mailing list (pgsql-hackers@postgresql.org) To make changes to your subscription: http://www.postgresql.org/mailpref/pgsql-hackers