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

Commit 88cf37d

Browse files
committed
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>
1 parent e8bde9e commit 88cf37d

File tree

1 file changed

+47
-0
lines changed
  • src/backend/storage/ipc

1 file changed

+47
-0
lines changed

src/backend/storage/ipc/ipc.c

+47
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,10 @@
2222
#include <signal.h>
2323
#include <unistd.h>
2424
#include <sys/stat.h>
25+
#if defined(__hpux)
26+
#include <sys/param.h>
27+
#include <sys/pstat.h>
28+
#endif
2529

2630
#include "miscadmin.h"
2731
#ifdef PROFILE_PID_DIR
@@ -80,6 +84,46 @@ static int on_proc_exit_index,
8084
before_shmem_exit_index;
8185

8286

87+
/* Report process's stack consumption to stderr */
88+
static void
89+
report_stack_size(void)
90+
{
91+
#if defined(__hpux)
92+
/* HPUX: examine process's memory map with pstat_getprocvm() */
93+
int targetpid = getpid();
94+
struct pst_vm_status buf;
95+
int res;
96+
int ndx;
97+
98+
for (ndx = 0;; ndx++)
99+
{
100+
res = pstat_getprocvm(&buf, sizeof(buf), targetpid, ndx);
101+
if (res < 0)
102+
{
103+
perror("getprocvm");
104+
break;
105+
}
106+
if (res != 1)
107+
break;
108+
if (buf.pst_type != PS_STACK)
109+
continue;
110+
fprintf(stderr, "%d: stack addr 0x%lx, length %ld, physical pages %ld\n",
111+
targetpid,
112+
buf.pst_vaddr,
113+
buf.pst_length,
114+
buf.pst_phys_pages);
115+
}
116+
#else /* non HPUX */
117+
/* Otherwise: try to use pmap. No error if that doesn't work. */
118+
char sysbuf[128];
119+
120+
snprintf(sysbuf, sizeof(sysbuf), "pmap -x %d | grep -i stack 1>&2",
121+
(int) getpid());
122+
(void) system(sysbuf);
123+
#endif
124+
}
125+
126+
83127
/* ----------------------------------------------------------------
84128
* proc_exit
85129
*
@@ -101,6 +145,9 @@ proc_exit(int code)
101145
/* Clean up everything that must be cleaned up */
102146
proc_exit_prepare(code);
103147

148+
/* report stack size to stderr */
149+
report_stack_size();
150+
104151
#ifdef PROFILE_PID_DIR
105152
{
106153
/*

0 commit comments

Comments
 (0)