Re: Improve logging when using Huge Pages

From: Justin Pryzby <pryzby(at)telsasoft(dot)com>
To: Nathan Bossart <nathandbossart(at)gmail(dot)com>
Cc: Alvaro Herrera <alvherre(at)alvh(dot)no-ip(dot)org>, Andres Freund <andres(at)anarazel(dot)de>, Michael Paquier <michael(at)paquier(dot)xyz>, Kyotaro Horiguchi <horikyota(dot)ntt(at)gmail(dot)com>, thomas(dot)munro(at)gmail(dot)com, tgl(at)sss(dot)pgh(dot)pa(dot)us, john(dot)naylor(at)enterprisedb(dot)com, noriyoshi(dot)shinoda(at)hpe(dot)com, jchampion(at)timescale(dot)com, sawada(dot)mshk(at)gmail(dot)com, masao(dot)fujii(at)oss(dot)nttdata(dot)com, pgsql-hackers(at)postgresql(dot)org, rjuju123(at)gmail(dot)com
Subject: Re: Improve logging when using Huge Pages
Date: 2023-02-15 01:32:56
Message-ID: 20230215013256.GP1653@telsasoft.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

On Mon, Feb 13, 2023 at 08:18:52PM -0800, Nathan Bossart wrote:
> On Mon, Feb 13, 2023 at 05:22:45PM -0600, Justin Pryzby wrote:
> > + Reports whether huge pages are in use by the current process.
> > + See <xref linkend="guc-huge-pages"/> for more information.
>
> nitpick: Should this say "server" instead of "current process"?

It should probably say "instance" :)

> > +static char *huge_pages_active = "unknown"; /* dynamically set */
>
> nitpick: Does this need to be initialized here?

None of the GUCs' C vars need to be initialized, since the guc machinery
will do it.

...but the convention is that they *are* initialized - and that's now
partially enforced.

See:
d9d873bac67047cfacc9f5ef96ee488f2cb0f1c3
7d25958453a60337bcb7bcc986e270792c007ea4
a73952b795632b2cf5acada8476e7cf75857e9be

> > + {
> > + {"huge_pages_active", PGC_INTERNAL, PRESET_OPTIONS,
> > + gettext_noop("Indicates whether huge pages are in use."),
> > + NULL,
> > + GUC_NOT_IN_SAMPLE | GUC_DISALLOW_IN_FILE | GUC_RUNTIME_COMPUTED
> > + },
> > + &huge_pages_active,
> > + "unknown",
> > + NULL, NULL, NULL
> > + },
>
> I'm curious why you chose to make this a string instead of an enum. There
> might be little practical difference, but since there are only three
> possible values, I wonder if it'd be better form to make it an enum.

It takes more code to write as an enum - see 002.txt. I'm not convinced
this is better.

But your comment made me fix its <type>, and reconsider the strings,
which I changed to active={unknown/true/false} rather than {unk/on/off}.
It could also be active={unknown/yes/no}...

--
Justin

Attachment Content-Type Size
v4-0001-add-GUC-huge_pages_active.patch text/x-diff 7.5 KB
v4-0002-f-convert-to-an-enum.txt text/x-diff 7.0 KB

In response to

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Andres Freund 2023-02-15 02:00:28 Re: Use pg_pwritev_with_retry() instead of write() in dir_open_for_write() to avoid partial writes?
Previous Message Kyotaro Horiguchi 2023-02-15 01:28:37 Re: Use pg_pwritev_with_retry() instead of write() in dir_open_for_write() to avoid partial writes?