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 think it's fine to show zeros for unsupported fields; that's what getusage(2)
and time(1) do after all.
pryzbyj@pryzbyj:~$ sh -c 'command time -v find /dev' 2>&1 >/dev/null |grep -Fw 0
User time (seconds): 0.00
System time (seconds): 0.00
Elapsed (wall clock) time (h:mm:ss or m:ss): 0:00.00
Average shared text size (kbytes): 0
Average unshared data size (kbytes): 0
Average stack size (kbytes): 0
Average total size (kbytes): 0
Average resident set size (kbytes): 0
Major (requiring I/O) page faults: 0
Swaps: 0
File system inputs: 0
File system outputs: 0
Socket messages sent: 0
Socket messages received: 0
Signals delivered: 0
> it would be a good idea to install code specific to Linux that
> displays all and only those values that are meaningful on Linux, and
> (less importantly) similarly for macOS. Linux is such a common
> platform that reporting bogus zero values and omitting other fields
> that are actually meaningful does not seem like a very good plan.
That has the issue that it varies not just by OS but also by OS version. For
example PG already shows context switches and FS in/out puts, but they're
nonzero only since linux 2.6 (yes, 2.4 is ancient and unsupported but still).
ru_nvcsw (since Linux 2.6)
ru_inblock (since Linux 2.6.22)
..and other fields are "currently unused", but maybe supported in the past or
future(?)
ru_ixrss (unmaintained)
This field is currently unused on Linux.
Are you thinking of something like this, maybe hidden away in a separate file
somewhere?
#if defined(__linux__) || 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__ */
Justin
--
Sent via pgsql-hackers mailing list ([email protected])
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-hackers