Re: An unlikely() experiment

From: Andres Freund <andres(at)anarazel(dot)de>
To: David Rowley <david(dot)rowley(at)2ndquadrant(dot)com>
Cc: PostgreSQL-development <pgsql-hackers(at)postgresql(dot)org>
Subject: Re: An unlikely() experiment
Date: 2016-07-19 21:24:23
Message-ID: 20160719212423.qyfrfafdiy34haui@alap3.anarazel.de
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

On 2015-12-20 14:21:14 +1300, David Rowley wrote:
> On 20 December 2015 at 03:06, Andres Freund <andres(at)anarazel(dot)de> wrote:
> > One way to do this would be to add elog_on() / ereport_on() macros,
> > directly containing the error message. Like
> > #define elog_on(cond, elevel, ...) \
> > do { \
> > if (unlikely(cond)) \
> > { \
> > elog(elevel, __VA_ARGS__) \
> > } \
> > } while(0)
> >
>
> Interesting idea. Would you think that would be something we could do a
> complete replace on, or are you thinking just for the hotter code paths?

More or less complete. Generally, logging shouldn't be a hot code
path. A single wrong branch won't be noticeable in case we're logging
something, not to speak of an actual error case. As far as I can see
there's unfortunately no way to declare a branch unlikely from inside
that branch, otherwise I'd have said we should just stick an unlikely
equivalent in the elog/ereport definition itself.

- Andres

In response to

Browse pgsql-hackers by date

  From Date Subject
Next Message Kevin Grittner 2016-07-19 21:38:19 Re: Document that vacuum can't truncate if old_snapshot_threshold >= 0
Previous Message Peter Eisentraut 2016-07-19 20:57:58 Re: sslmode=require fallback