Re: Unimpressed with pg_attribute_always_inline

From: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
To: Peter Geoghegan <pg(at)bowt(dot)ie>
Cc: Peter Eisentraut <peter(dot)eisentraut(at)2ndquadrant(dot)com>, Andres Freund <andres(at)anarazel(dot)de>, Thomas Munro <thomas(dot)munro(at)enterprisedb(dot)com>, PostgreSQL Hackers <pgsql-hackers(at)lists(dot)postgresql(dot)org>
Subject: Re: Unimpressed with pg_attribute_always_inline
Date: 2018-01-09 01:20:09
Message-ID: 24102.1515460809@sss.pgh.pa.us
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

Peter Geoghegan <pg(at)bowt(dot)ie> writes:
> On Mon, Jan 8, 2018 at 5:09 PM, Peter Eisentraut
> <peter(dot)eisentraut(at)2ndquadrant(dot)com> wrote:
>> However, at <https://gcc.gnu.org/onlinedocs/gcc/Inline.html> it says,
>> "GCC does not inline any functions when not optimizing unless you
>> specify the ‘always_inline’ attribute for the function". So,
>> apparently, if the goal is to turn off inlining when not optimizing,
>> then we should just use the normal inline attribute.

> The compiler isn't obligated to inline anything with the normal inline
> attribute. The whole point of always_inline is that the programmer may
> know better than the compiler about inlining in some specific cases,
> and may therefore want to make inlining absolutely mandatory. IIUC,
> that's almost what we want, except that it also inlines with -O0,
> which we do not want.

> Have I missed the point here?

No, you have it right. I checked locally and confirmed Andres' assertion
that by default, gcc (my version anyway) is not persuaded to inline
ExecHashJoinImpl simply by "inline", but "always_inline" persuades it.
Maybe at some level higher than -O2, or with some other weird flag,
it would do what we want; but we probably don't want to mess with global
compiler flags for this.

regards, tom lane

In response to

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Peter Eisentraut 2018-01-09 01:28:57 Re: portal pinning
Previous Message Michael Paquier 2018-01-09 01:15:47 Re: Enhance pg_stat_wal_receiver view to display connected host