Re: Creating a function for exposing memory usage of backend process
Andres Freund <andres@anarazel.de>
From: Andres Freund <andres@anarazel.de>
To: Tom Lane <tgl@sss.pgh.pa.us>
Cc: Michael Paquier <michael@paquier.xyz>, Fujii Masao <masao.fujii@oss.nttdata.com>, torikoshia <torikoshia@oss.nttdata.com>, PostgreSQL-development <pgsql-hackers@postgresql.org>, Robert Haas <robertmhaas@gmail.com>, Kasahara Tatsuhito <kasahara.tatsuhito@gmail.com>
Date: 2020-08-20T01:43:01Z
Lists: pgsql-hackers
Hi, On 2020-08-19 21:29:06 -0400, Tom Lane wrote: > Andres Freund <andres@anarazel.de> writes: > > On 2020-08-19 11:01:37 -0400, Tom Lane wrote: > >> I agree with that, but I think this patch has a bigger problem: > >> why bother at all? It seems like a waste of code space and future > >> maintenance effort, because there is no use-case. > > > I don't agree with this at all. I think there's plenty use cases. It's > > e.g. very common to try to figure out why the memory usage of a process > > is high. Is it memory not returned to the OS? Is it caches that have > > grown too much etc. > > Oh, I agree completely that there are lots of use-cases for finding > out what a process' memory map looks like. But this patch fails to > address any of them in a usable way. Even just being able to see the memory usage in a queryable way is a huge benefit. The difference over having to parse the log, then parse the memory usage dump, and then aggregate the data in there in a meaningful way is *huge*. We've been slacking around lowering our memory usage, and I think the fact that it's annoying to analyze is a partial reason for that. I totally agree that it's not *enough*, but in contrast to you I think it's a good step. Subsequently we should add a way to get any backends memory usage. It's not too hard to imagine how to serialize it in a way that can be easily deserialized by another backend. I am imagining something like sending a procsignal that triggers (probably at CFR() time) a backend to write its own memory usage into pg_memusage/<pid> or something roughly like that. Greetings, Andres Freund
Commits
-
Add regression test for pg_backend_memory_contexts.
- adc8fc6167aa 14.0 landed
-
Move codes for pg_backend_memory_contexts from mmgr/mcxt.c to adt/mcxtfuncs.c.
- 50db5964ee33 14.0 landed
-
Prevent non-superusers from reading pg_backend_memory_contexts, by default.
- 29dd6d8bc631 14.0 landed
-
Add pg_backend_memory_contexts system view.
- 3e98c0bafb28 14.0 landed
-
Fix yet another issue with step generation in partition pruning.
- 199cec977950 14.0 cited