Skip to content

Commit ea9c4a1

Browse files
committed
Add more temporary code to record stack usage at server process exit.
After a look at preliminary results from commit 88cf37d, I realized it'd be a good idea to spew out the maximum depth measurement seen by check_stack_depth. So add some quick-n-dirty code to do that. Like the previous commit, this will be reverted once we've gathered a set of buildfarm runs with it.
1 parent 769159f commit ea9c4a1

File tree

2 files changed

+24
-0
lines changed

2 files changed

+24
-0
lines changed

src/backend/storage/ipc/ipc.c

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,9 @@
3535
#include "storage/ipc.h"
3636
#include "tcop/tcopprot.h"
3737

38+
extern long max_measured_stack_depth;
39+
extern long max_measured_register_stack_depth;
40+
3841

3942
/*
4043
* This flag is set during proc_exit() to change ereport()'s behavior,
@@ -121,6 +124,15 @@ report_stack_size(void)
121124
(int) getpid());
122125
(void) system(sysbuf);
123126
#endif
127+
128+
#if defined(__ia64__) || defined(__ia64)
129+
fprintf(stderr, "max measured stack depths %ldkB, %ldkB\n",
130+
(max_measured_stack_depth + 1023) / 1024,
131+
(max_measured_register_stack_depth + 1023) / 1024);
132+
#else
133+
fprintf(stderr, "max measured stack depth %ldkB\n",
134+
(max_measured_stack_depth + 1023) / 1024);
135+
#endif
124136
}
125137

126138

src/backend/tcop/postgres.c

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -96,6 +96,9 @@ int max_stack_depth = 100;
9696
/* wait N seconds to allow attach from a debugger */
9797
int PostAuthDelay = 0;
9898

99+
/* Exported for use by proc_exit */
100+
long max_measured_stack_depth = 0;
101+
long max_measured_register_stack_depth = 0;
99102

100103

101104
/* ----------------
@@ -3137,6 +3140,11 @@ stack_is_too_deep(void)
31373140
if (stack_depth < 0)
31383141
stack_depth = -stack_depth;
31393142

3143+
/* Track max measured depth for reporting by proc_exit */
3144+
if (stack_depth > max_measured_stack_depth &&
3145+
stack_base_ptr != NULL)
3146+
max_measured_stack_depth = stack_depth;
3147+
31403148
/*
31413149
* Trouble?
31423150
*
@@ -3160,6 +3168,10 @@ stack_is_too_deep(void)
31603168
#if defined(__ia64__) || defined(__ia64)
31613169
stack_depth = (long) (ia64_get_bsp() - register_stack_base_ptr);
31623170

3171+
if (stack_depth > max_measured_register_stack_depth &&
3172+
register_stack_base_ptr != NULL)
3173+
max_measured_register_stack_depth = stack_depth;
3174+
31633175
if (stack_depth > max_stack_depth_bytes &&
31643176
register_stack_base_ptr != NULL)
31653177
return true;

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy