Re: Get memory contexts of an arbitrary backend process - Mailing list pgsql-hackers

From torikoshia
Subject Re: Get memory contexts of an arbitrary backend process
Date
Msg-id f6f6373ae200c8a0e7466e4de9ca65eb@oss.nttdata.com
Whole thread Raw
In response to Re: Get memory contexts of an arbitrary backend process  (Fujii Masao <masao.fujii@oss.nttdata.com>)
Responses Re: Get memory contexts of an arbitrary backend process  (Kyotaro Horiguchi <horikyota.ntt@gmail.com>)
List pgsql-hackers
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?


+<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>


Regards.
Attachment

pgsql-hackers by date:

Previous
From: Amit Kapila
Date:
Subject: Re: extra semicolon in postgres_fdw test cases
Next
From: Thomas Munro
Date:
Subject: Re: PostmasterIsAlive() in recovery (non-USE_POST_MASTER_DEATH_SIGNAL builds)