]> granicus.if.org Git - postgresql/commitdiff
Add more temporary code to record stack usage at server process exit.
authorTom Lane <tgl@sss.pgh.pa.us>
Fri, 8 Jul 2016 20:38:22 +0000 (16:38 -0400)
committerTom Lane <tgl@sss.pgh.pa.us>
Fri, 8 Jul 2016 20:38:22 +0000 (16:38 -0400)
After a look at preliminary results from commit 88cf37d2a86d5b66,
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.

src/backend/storage/ipc/ipc.c
src/backend/tcop/postgres.c

index b71d10ea8f4b365fe857534b6f0123cb59a0b11c..1b349e12db0230f69a839707091a1a6d7d150dee 100644 (file)
@@ -35,6 +35,9 @@
 #include "storage/ipc.h"
 #include "tcop/tcopprot.h"
 
+extern long max_measured_stack_depth;
+extern long max_measured_register_stack_depth;
+
 
 /*
  * This flag is set during proc_exit() to change ereport()'s behavior,
@@ -121,6 +124,15 @@ report_stack_size(void)
                         (int) getpid());
        (void) system(sysbuf);
 #endif
+
+#if defined(__ia64__) || defined(__ia64)
+       fprintf(stderr, "max measured stack depths %ldkB, %ldkB\n",
+                       (max_measured_stack_depth + 1023) / 1024,
+                       (max_measured_register_stack_depth + 1023) / 1024);
+#else
+       fprintf(stderr, "max measured stack depth %ldkB\n",
+                       (max_measured_stack_depth + 1023) / 1024);
+#endif
 }
 
 
index b185c1b5eb69fba2654b65a8b80bfe74f03ff600..38cabf650a1a464c90d70475ec1c13ad56abeb93 100644 (file)
@@ -96,6 +96,9 @@ int                   max_stack_depth = 100;
 /* wait N seconds to allow attach from a debugger */
 int                    PostAuthDelay = 0;
 
+/* Exported for use by proc_exit */
+long           max_measured_stack_depth = 0;
+long           max_measured_register_stack_depth = 0;
 
 
 /* ----------------
@@ -3137,6 +3140,11 @@ stack_is_too_deep(void)
        if (stack_depth < 0)
                stack_depth = -stack_depth;
 
+       /* Track max measured depth for reporting by proc_exit */
+       if (stack_depth > max_measured_stack_depth &&
+               stack_base_ptr != NULL)
+               max_measured_stack_depth = stack_depth;
+
        /*
         * Trouble?
         *
@@ -3160,6 +3168,10 @@ stack_is_too_deep(void)
 #if defined(__ia64__) || defined(__ia64)
        stack_depth = (long) (ia64_get_bsp() - register_stack_base_ptr);
 
+       if (stack_depth > max_measured_register_stack_depth &&
+               register_stack_base_ptr != NULL)
+               max_measured_register_stack_depth = stack_depth;
+
        if (stack_depth > max_stack_depth_bytes &&
                register_stack_base_ptr != NULL)
                return true;