Re: Get memory contexts of an arbitrary backend process

From: Kyotaro Horiguchi <horikyota(dot)ntt(at)gmail(dot)com>
To: torikoshia(at)oss(dot)nttdata(dot)com
Cc: masao(dot)fujii(at)oss(dot)nttdata(dot)com, pgsql-hackers(at)postgresql(dot)org, tgl(at)sss(dot)pgh(dot)pa(dot)us, gkokolatos(at)protonmail(dot)com, kasahara(dot)tatsuhito(at)gmail(dot)com, craig(at)2ndquadrant(dot)com
Subject: Re: Get memory contexts of an arbitrary backend process
Date: 2021-03-31 06:16:12
Message-ID: 20210331.151612.259240960686480846.horikyota.ntt@gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

At Wed, 31 Mar 2021 15:02:02 +0900, torikoshia <torikoshia(at)oss(dot)nttdata(dot)com> wrote in
> On 2021-03-31 04:36, Fujii Masao wrote:
> > On 2021/03/30 22:06, torikoshia wrote:
> >> Modified the patch according to the suggestions.
> > Thanks for updating the patch!
> > I applied the cosmetic changes to the patch and added the example of
> > the function call into the document. Attached is the updated version
> > of the patch. Could you check this version?
> >
>
> Thanks a lot!
>
>
> +The memory contexts will be logged in the log file. For example:
>
> When 'log_destination = stderr' and 'logging_collector = off', it does
> not log in the file but in the stderr.
>
> Description like below would be a bit more accurate but I'm wondering
> it's repeating the same words.
>
> + The memory contexts will be logged based on the log configuration
> set. For example:
>
> How do you think?

How about "The memory contexts will be logged in the server log" ?
I think "server log" doesn't suggest any concrete target.

> +<programlisting>
> +postgres=# SELECT pg_log_backend_memory_contexts(pg_backend_pid());
> + pg_log_backend_memory_contexts
> +--------------------------------
> + t
> +(1 row)
> +
> +The memory contexts will be logged in the log file. For example:
> +LOG: logging memory contexts of PID 10377
> +STATEMENT: SELECT pg_log_backend_memory_contexts(pg_backend_pid());
> +LOG: level: 0; TopMemoryContext: 80800 total in 6 blocks; 14432 free
> (5 chunks); 66368 used
> +LOG: level: 1; pgstat TabStatusArray lookup hash table: 8192 total in
> 1 blocks; 1408 free (0 chunks); 6784 used
>
> The line "The memory contexts will be logged in the log file. For
> example:"
> is neither nor SQL command and its outputs, it might be better to
> differentiate it.
>
>
> What about the following like attached patch?
>
> +<programlisting>
> +postgres=# SELECT pg_log_backend_memory_contexts(pg_backend_pid());
> + pg_log_backend_memory_contexts
> +--------------------------------
> + t
> +(1 row)
> +</programlisting>
> +The memory contexts will be logged in the log file. For example:
> +<screen>
> +LOG: logging memory contexts of PID 10377
> +STATEMENT: SELECT pg_log_backend_memory_contexts(pg_backend_pid());
> +LOG: level: 0; TopMemoryContext: 80800 total in 6 blocks; 14432 free
> (5 chunks); 66368 used
> +LOG: level: 1; pgstat TabStatusArray lookup hash table: 8192 total in
> 1 blocks; 1408 free (0 chunks); 6784 used
> ...(snip)...
> +LOG: level: 1; ErrorContext: 8192 total in 1 blocks; 7928 free (3
> chunks); 264 used
> +LOG: Grand total: 1651920 bytes in 201 blocks; 622360 free (88
> chunks); 1029560 used
> +</screen>

+1 from me. It looks like more compliant with the standard?

regards.

--
Kyotaro Horiguchi
NTT Open Source Software Center

In response to

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Kyotaro Horiguchi 2021-03-31 06:17:51 Re: Remove page-read callback from XLogReaderState.
Previous Message Guillaume Lelarge 2021-03-31 06:14:43 Re: Extensions not dumped when --schema is used