From: Tom Lane <tgl@sss.pgh.pa.us>
To: Greg Stark <stark@mit.edu>
Cc: Robert Haas <robertmhaas@gmail.com>
Cc: PostgreSQL-development <pgsql-hackers@postgresql.org>
Subject: Re: can we optimize STACK_DEPTH_SLOP
Date: Thu, 07 Jul 2016 23:46:27 -0400
Message-ID: <17417.1467949587@sss.pgh.pa.us> (raw)
In-Reply-To: <20233.1467910511@sss.pgh.pa.us>
References: <CAM-w4HMwwcwaVvYcAH0_FGtG5GeXdYVRfvG81pXnSJWHnCfosQ@mail.gmail.com>
<32729.1467734050@sss.pgh.pa.us>
<CA+TgmoYubk9mjX9Vjb7dki9JZWwoW-X5pLhwPaN=jv_MD9b_Sw@mail.gmail.com>
<28549.1467748100@sss.pgh.pa.us>
<CAM-w4HN_U4CDuneDkXua4+Txhci5HNxkCRsCG78EkETzDQp-ZQ@mail.gmail.com>
<19108.1467812089@sss.pgh.pa.us>
<CAM-w4HPJr_bAWAmJ95Bwko6c31v6XY5hx8xyn5hL_JGO0OWP3Q@mail.gmail.com>
<CAM-w4HMiJKdjX=7SZj5OTtK7-VkznVbwsC1km=4X=Y0=0rej2w@mail.gmail.com>
<20280.1467855936@sss.pgh.pa.us>
<20233.1467910511@sss.pgh.pa.us>
List-Unsubscribe: <mailto:majordomo@postgresql.org?body=unsub%20pgsql-hackers>
I wrote:
> Based on these numbers, I'd have no fear of reducing STACK_DEPTH_SLOP
> to 256KB on x86_64. It would sure be good to check things on some
> other architectures, though ...
I went to the work of doing the same test on a PPC Mac:
182 Stack [ 8192K/ 40K]
25 Stack [ 8192K/ 48K]
2 Stack [ 8192K/ 56K]
11 Stack [ 8192K/ 60K]
5 Stack [ 8192K/ 64K]
2 Stack [ 8192K/ 108K]
1 Stack [ 8192K/ 576K]
1 Stack [ 8192K/ 2056K]
The last number here is "resident pages", not "dirty pages", because
this older version of OS X doesn't provide the latter. Still, the
numbers seem to track pretty well with the ones I got on x86_64.
Which is a bit odd when you think about it: a 32-bit machine ought
to consume less stack space because pointers are narrower.
Also on my old HPPA dinosaur:
40 addr 0x7b03a000, length 8, physical pages 8, type STACK
166 addr 0x7b03a000, length 10, physical pages 9, type STACK
26 addr 0x7b03a000, length 12, physical pages 11, type STACK
16 addr 0x7b03a000, length 14, physical pages 13, type STACK
1 addr 0x7b03a000, length 15, physical pages 13, type STACK
1 addr 0x7b03a000, length 16, physical pages 15, type STACK
2 addr 0x7b03a000, length 28, physical pages 27, type STACK
1 addr 0x7b03a000, length 190, physical pages 190, type STACK
1 addr 0x7b03a000, length 514, physical pages 514, type STACK
As best I can tell, "length" is the nominal virtual space for the stack,
and "physical pages" is the actually allocated/resident space, both
measured in 4K pages. So that again matches pretty well, although the
stack-efficiency of the recursive regex functions seems to get worse with
each new case I look at.
However ... the thread here
https://www.postgresql.org/message-id/flat/21563.1289064886%40sss.pgh.pa.us
says that depending on your choice of compiler and optimization level,
IA64 can be 4x to 5x worse for stack space than x86_64, even after
spotting it double the memory allocation to handle its two separate
stacks. I don't currently have access to an IA64 machine to check.
Based on what I'm seeing so far, really 100K ought to be more than plenty
of slop for most architectures, but I'm afraid to go there for IA64.
Also, there might be some more places like tzload() that are putting
unreasonably large variables on the stack, but that the regression tests
don't exercise (I've not tested anything replication-related, for
example).
Bottom line: I propose that we keep STACK_DEPTH_SLOP at 512K for IA64
but reduce it to 256K for everything else.
regards, tom lane
--
Sent via pgsql-hackers mailing list (pgsql-hackers@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-hackers
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Reply to all the recipients from your mail client; the link fills in
the headers below: reply via email
Some clients, webmail especially, drop In-Reply-To and References from
a link, and the reply then starts a new thread: use the mbox below.
To: pgsql-hackers@postgresql.org
Cc: tgl@sss.pgh.pa.us, stark@mit.edu, robertmhaas@gmail.com
Subject: Re: can we optimize STACK_DEPTH_SLOP
In-Reply-To: <17417.1467949587@sss.pgh.pa.us>
References: <CAM-w4HMwwcwaVvYcAH0_FGtG5GeXdYVRfvG81pXnSJWHnCfosQ@mail.gmail.com> <32729.1467734050@sss.pgh.pa.us> <CA+TgmoYubk9mjX9Vjb7dki9JZWwoW-X5pLhwPaN=jv_MD9b_Sw@mail.gmail.com> <28549.1467748100@sss.pgh.pa.us> <CAM-w4HN_U4CDuneDkXua4+Txhci5HNxkCRsCG78EkETzDQp-ZQ@mail.gmail.com> <19108.1467812089@sss.pgh.pa.us> <CAM-w4HPJr_bAWAmJ95Bwko6c31v6XY5hx8xyn5hL_JGO0OWP3Q@mail.gmail.com> <CAM-w4HMiJKdjX=7SZj5OTtK7-VkznVbwsC1km=4X=Y0=0rej2w@mail.gmail.com> <20280.1467855936@sss.pgh.pa.us> <20233.1467910511@sss.pgh.pa.us> <17417.1467949587@sss.pgh.pa.us>
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox