Re: Improve logging when using Huge Pages

From: Justin Pryzby <pryzby(at)telsasoft(dot)com>
To: Andres Freund <andres(at)anarazel(dot)de>
Cc: 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-01-25 01:37:29
Message-ID: 20230125013728.GK13860@telsasoft.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

On Mon, Jan 23, 2023 at 05:33:35PM -0800, Andres Freund wrote:
> Hi,
>
> On 2023-01-23 19:21:00 -0600, Justin Pryzby wrote:
> > Michael seemed to support this idea and nobody verbalized hatred of it,
> > so I implemented it. In v15, we have shared_memory_size_in_huge_pages,
> > so this adds effective_huge_pages.
> >
> > Feel free to suggest a better name.
>
> Hm. Should this be a GUC? There's a reason shared_memory_size_in_huge_pages is
> one - it's so it's accessible via -C. But here we could make it a function or
> whatnot as well.

I have no strong opinion, but a few minor arguments in favour of a GUC:

- the implementation parallels huge_pages, huge_page_size, and
shared_memory_size_in_huge_pages;
- it's short;
- it's glob()able with the others:

postgres=# \dconfig *huge*
List of configuration parameters
Parameter | Value
----------------------------------+-------
effective_huge_pages | off
huge_pages | try
huge_page_size | 0
shared_memory_size_in_huge_pages | 12

> I'm ok with this being a GUC, it doesn't feel elegant, but I suspect there's
> no realistic elegant answer.

BTW, I didn't realize it when I made the suggestion, nor when I wrote
the patch, but a GUC was implemented in the v2 patch.
https://www.postgresql.org/message-id/TU4PR8401MB1152CB4FEB99658BC6B35543EECF9%40TU4PR8401MB1152.NAMPRD84.PROD.OUTLOOK.COM

The original proposal was to change the elog(DEBUG1, "mmap..") to LOG,
and the thread seems to have derailed out of concern for a hypothetical
user who was adverse to an additional line of log messages during server
start.

I don't share that concern, but GUC or function seems better anyway,
since the log message is not easily available (except maybe, sometimes,
shortly after the server restart). I'm currently checking for huge
pages in a nagios script by grepping /proc/pid/smaps (I *could* make use
of a logfile if that was available, but it's better if it's a persistent
state/variable).

Whether it's a GUC or a function, I propose to name it hugepages_active.
If there's no objections, I'll add to the CF.

--
Justin

In response to

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Justin Pryzby 2023-01-25 01:42:03 Re: Add LZ4 compression in pg_dump
Previous Message Michael Paquier 2023-01-25 01:32:10 Re: 011_crash_recovery.pl intermittently fails