On Thu, Jun 15, 2017 at 10:29:21AM -0400, Robert Haas wrote: > On Wed, Jun 14, 2017 at 6:28 PM, Justin Pryzby <pry...@telsasoft.com> wrote: > > On Tue, Jun 13, 2017 at 12:16:00PM -0400, Robert Haas wrote: > >> It might be worth adding platform-specific code for common platforms. > > > > All I care (which linux happily/happens to support) is maxrss; I was > > probably > > originally interested in this while digging into an issue with hash agg. > > I don't think it needs to go in a separate file. I'd just patch ShowUsage().
diff --git a/src/backend/tcop/postgres.c b/src/backend/tcop/postgres.c index f99dd0a..7f57a84 100644 --- a/src/backend/tcop/postgres.c +++ b/src/backend/tcop/postgres.c @@ -4467,6 +4467,21 @@ ShowUsage(const char *title) r.ru_nvcsw - Save_r.ru_nvcsw, r.ru_nivcsw - Save_r.ru_nivcsw, r.ru_nvcsw, r.ru_nivcsw); + +#if defined(__linux__) + appendStringInfo(&str, + "!\t%ld max resident (kB)\n", + r.ru_maxrss); +#elif defined(BSD) + appendStringInfo(&str, + "!\t%ld max resident, %ld shared, %ld unshared data, %ld unshared stack (kB)\n", + r.ru_maxrss, r.ru_ixrss, r.ru_idrss, r.ru_isrss); +#elif defined(__darwin__) + appendStringInfo(&str, + "!\t%ld max resident, %ld shared, %ld unshared data, %ld unshared stack (kB)\n", + r.ru_maxrss/1024, r.ru_ixrss/1024, r.ru_idrss/1024, r.ru_isrss/1024); +#endif /* __linux__ */ + #endif /* HAVE_GETRUSAGE */ /* remove trailing newline */ Comments ? Testing or suggestions on !linux would be useful. Justin
Add memory fields (sometimes) available from getrusage() diff --git a/src/backend/tcop/postgres.c b/src/backend/tcop/postgres.c index f99dd0a..7f57a84 100644 --- a/src/backend/tcop/postgres.c +++ b/src/backend/tcop/postgres.c @@ -4467,6 +4467,21 @@ ShowUsage(const char *title) r.ru_nvcsw - Save_r.ru_nvcsw, r.ru_nivcsw - Save_r.ru_nivcsw, r.ru_nvcsw, r.ru_nivcsw); + +#if defined(__linux__) + appendStringInfo(&str, + "!\t%ld max resident (kB)\n", + r.ru_maxrss); +#elif defined(BSD) + appendStringInfo(&str, + "!\t%ld max resident, %ld shared, %ld unshared data, %ld unshared stack (kB)\n", + r.ru_maxrss, r.ru_ixrss, r.ru_idrss, r.ru_isrss); +#elif defined(__darwin__) + appendStringInfo(&str, + "!\t%ld max resident, %ld shared, %ld unshared data, %ld unshared stack (kB)\n", + r.ru_maxrss/1024, r.ru_ixrss/1024, r.ru_idrss/1024, r.ru_isrss/1024); +#endif /* __linux__ */ + #endif /* HAVE_GETRUSAGE */ /* remove trailing newline */
-- Sent via pgsql-hackers mailing list (pgsql-hackers@postgresql.org) To make changes to your subscription: http://www.postgresql.org/mailpref/pgsql-hackers