Location via proxy:   [ UP ]  
[Report a bug]   [Manage cookies]                
Skip to content

Commit c039ba0

Browse files
committed
Add memory info to getrusage output
Add the maxrss field to the getrusage output (log_*_stats). This was previously omitted because of portability concerns, but we feel this might not be a concern anymore. based on patch by Justin Pryzby <pryzby@telsasoft.com>
1 parent 0cb8b75 commit c039ba0

File tree

1 file changed

+12
-5
lines changed

1 file changed

+12
-5
lines changed

src/backend/tcop/postgres.c

+12-5
Original file line numberDiff line numberDiff line change
@@ -4421,11 +4421,8 @@ ShowUsage(const char *title)
44214421
}
44224422

44234423
/*
4424-
* the only stats we don't show here are for memory usage -- i can't
4425-
* figure out how to interpret the relevant fields in the rusage struct,
4426-
* and they change names across o/s platforms, anyway. if you can figure
4427-
* out what the entries mean, you can somehow extract resident set size,
4428-
* shared text size, and unshared data and stack sizes.
4424+
* The only stats we don't show here are ixrss, idrss, isrss. It takes
4425+
* some work to interpret them, and most platforms don't fill them in.
44294426
*/
44304427
initStringInfo(&str);
44314428

@@ -4445,6 +4442,16 @@ ShowUsage(const char *title)
44454442
(long) sys.tv_sec,
44464443
(long) sys.tv_usec);
44474444
#if defined(HAVE_GETRUSAGE)
4445+
appendStringInfo(&str,
4446+
"!\t%ld kB max resident size\n",
4447+
#if defined(__darwin__)
4448+
/* in bytes on macOS */
4449+
r.ru_maxrss/1024
4450+
#else
4451+
/* in kilobytes on most other platforms */
4452+
r.ru_maxrss
4453+
#endif
4454+
);
44484455
appendStringInfo(&str,
44494456
"!\t%ld/%ld [%ld/%ld] filesystem blocks in/out\n",
44504457
r.ru_inblock - Save_r.ru_inblock,

0 commit comments

Comments
 (0)