mirror of
https://git.postgresql.org/git/postgresql.git
synced 2025-01-24 18:55:04 +08:00
Add some temporary code to record stack usage at server process exit.
This patch is meant to gather information from the buildfarm members, and will be reverted in a day or so. The idea is to try to find out the high-water stack consumption while running the regression tests, particularly on IA64 which is suspected to use much more stack than other architectures. On machines with pmap, we can use that; but the IA64 farm members are running HPUX, so also include some bespoke code for HPUX. (I've tested the latter on HPUX 10/HPPA; not entirely sure it will work on HPUX 11/IA64, but we'll soon find out.) Discussion: <CAM-w4HMwwcwaVvYcAH0_FGtG5GeXdYVRfvG81pXnSJWHnCfosQ@mail.gmail.com>
This commit is contained in:
parent
e8bde9e253
commit
88cf37d2a8
@ -22,6 +22,10 @@
|
|||||||
#include <signal.h>
|
#include <signal.h>
|
||||||
#include <unistd.h>
|
#include <unistd.h>
|
||||||
#include <sys/stat.h>
|
#include <sys/stat.h>
|
||||||
|
#if defined(__hpux)
|
||||||
|
#include <sys/param.h>
|
||||||
|
#include <sys/pstat.h>
|
||||||
|
#endif
|
||||||
|
|
||||||
#include "miscadmin.h"
|
#include "miscadmin.h"
|
||||||
#ifdef PROFILE_PID_DIR
|
#ifdef PROFILE_PID_DIR
|
||||||
@ -80,6 +84,46 @@ static int on_proc_exit_index,
|
|||||||
before_shmem_exit_index;
|
before_shmem_exit_index;
|
||||||
|
|
||||||
|
|
||||||
|
/* Report process's stack consumption to stderr */
|
||||||
|
static void
|
||||||
|
report_stack_size(void)
|
||||||
|
{
|
||||||
|
#if defined(__hpux)
|
||||||
|
/* HPUX: examine process's memory map with pstat_getprocvm() */
|
||||||
|
int targetpid = getpid();
|
||||||
|
struct pst_vm_status buf;
|
||||||
|
int res;
|
||||||
|
int ndx;
|
||||||
|
|
||||||
|
for (ndx = 0;; ndx++)
|
||||||
|
{
|
||||||
|
res = pstat_getprocvm(&buf, sizeof(buf), targetpid, ndx);
|
||||||
|
if (res < 0)
|
||||||
|
{
|
||||||
|
perror("getprocvm");
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
if (res != 1)
|
||||||
|
break;
|
||||||
|
if (buf.pst_type != PS_STACK)
|
||||||
|
continue;
|
||||||
|
fprintf(stderr, "%d: stack addr 0x%lx, length %ld, physical pages %ld\n",
|
||||||
|
targetpid,
|
||||||
|
buf.pst_vaddr,
|
||||||
|
buf.pst_length,
|
||||||
|
buf.pst_phys_pages);
|
||||||
|
}
|
||||||
|
#else /* non HPUX */
|
||||||
|
/* Otherwise: try to use pmap. No error if that doesn't work. */
|
||||||
|
char sysbuf[128];
|
||||||
|
|
||||||
|
snprintf(sysbuf, sizeof(sysbuf), "pmap -x %d | grep -i stack 1>&2",
|
||||||
|
(int) getpid());
|
||||||
|
(void) system(sysbuf);
|
||||||
|
#endif
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
/* ----------------------------------------------------------------
|
/* ----------------------------------------------------------------
|
||||||
* proc_exit
|
* proc_exit
|
||||||
*
|
*
|
||||||
@ -101,6 +145,9 @@ proc_exit(int code)
|
|||||||
/* Clean up everything that must be cleaned up */
|
/* Clean up everything that must be cleaned up */
|
||||||
proc_exit_prepare(code);
|
proc_exit_prepare(code);
|
||||||
|
|
||||||
|
/* report stack size to stderr */
|
||||||
|
report_stack_size();
|
||||||
|
|
||||||
#ifdef PROFILE_PID_DIR
|
#ifdef PROFILE_PID_DIR
|
||||||
{
|
{
|
||||||
/*
|
/*
|
||||||
|
Loading…
Reference in New Issue
Block a user