Re: Linux likely() unlikely() for PostgreSQL - Mailing list pgsql-hackers

From Peter Geoghegan
Subject Re: Linux likely() unlikely() for PostgreSQL
Date
Msg-id CAH2-WzmzVM6boze-J20-uaaPgx1geNz5nKESwvzPt8KHr58_Dw@mail.gmail.com
Whole thread Raw
In response to Re: Linux likely() unlikely() for PostgreSQL  (Tom Lane <tgl@sss.pgh.pa.us>)
Responses Re: Linux likely() unlikely() for PostgreSQL
List pgsql-hackers
On Sun, Jun 30, 2024 at 11:23 AM Tom Lane <tgl@sss.pgh.pa.us> wrote:
> The real win would be if constructs like
>
>         if (trouble)
>                 ereport(ERROR, ...);
>
> could be interpreted as
>
>         if (unlikely(trouble))
>                 ereport(ERROR, ...);
>
> But I surely don't want to make thousands of such changes manually.
> And it's possible that smart compilers already realize this, using
> a heuristic that any path that ends in pg_unreachable() must be
> unlikely.  Is there a way to encourage compilers to believe that?

Isn't that what commit 913ec71d68 did, by adding a call to
pg_attribute_cold to ereport?

--
Peter Geoghegan



pgsql-hackers by date:

Previous
From: Tom Lane
Date:
Subject: Re: PostgreSQL does not compile on macOS SDK 15.0
Next
From: David Rowley
Date:
Subject: Re: Linux likely() unlikely() for PostgreSQL