Re: can we optimize STACK_DEPTH_SLOP

From: Greg Stark <stark(at)mit(dot)edu>
To: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
Cc: Robert Haas <robertmhaas(at)gmail(dot)com>, PostgreSQL-development <pgsql-hackers(at)postgresql(dot)org>
Subject: Re: can we optimize STACK_DEPTH_SLOP
Date: 2016-07-06 03:32:03
Message-ID: CAM-w4HN_U4CDuneDkXua4+Txhci5HNxkCRsCG78EkETzDQp-ZQ@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

On Tue, Jul 5, 2016 at 8:48 PM, Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us> wrote:
> Unfortunately the way I did (1) only works on systems with pmap; I'm not
> sure how to make it more portable.

I did a similar(ish) test which is admittedly not as exhaustive as
using pmap. I instrumented check_stack_depth() itself to keep track of
a high water mark (and based on Robert's thought process) to keep
track of the largest increment over the previous checked stack depth.
This doesn't cover any cases where there's no check_stack_depth() call
in the call stack at all (but then if there's no check_stack_depth
call at all it's hard to see how any setting of STACK_DEPTH_SLOP is
necessarily going to help).

I see similar results to you. The regexp test shows:
LOG: disconnection: highest stack depth: 392256 largest stack increment: 35584

And the:
STATEMENT: select infinite_recurse();
LOG: disconnection: highest stack depth: 2097584 largest stack increment: 1936

There were a couple other tests with similar stack increase increments
to the regular expression test:

STATEMENT: alter table atacc2 add constraint foo check (test>0) no inherit;
LOG: disconnection: highest stack depth: 39232 largest stack increment: 34224
STATEMENT: SELECT chr(0);
LOG: disconnection: highest stack depth: 44144 largest stack increment: 34512

But aside from those two the next largest increment between two
success check_stack_depth calls was about 12kB:

STATEMENT: select array_elem_check(121.00);
LOG: disconnection: highest stack depth: 24256 largest stack increment: 12896

This was all on x86_64 too.

--
greg

Attachment Content-Type Size
instrument_stack_depth.diff text/plain 1.2 KB

In response to

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Pavel Stehule 2016-07-06 04:17:35 Re: Forthcoming SQL standards about JSON and Multi-Dimensional Arrays (FYI)
Previous Message Peter Eisentraut 2016-07-06 03:17:48 Re: Forthcoming SQL standards about JSON and Multi-Dimensional Arrays (FYI)