default of max_stack_depth

Started by Fujii Masaoover 15 years ago4 messageshackers
Jump to latest
#1Fujii Masao
masao.fujii@gmail.com

Hi,

The document says that the max_stack_depth is 2MB by default.
OTOH, in the source code, the variable max_stack_depth is
initialized with 100 (kB), and guc.c also uses 100 as the
default. Why?

This seems confusing to me though I know that
InitializeGUCOptions() sets max_stack_depth to 2MB.

Regards,

--
Fujii Masao
NIPPON TELEGRAPH AND TELEPHONE CORPORATION
NTT Open Source Software Center

#2Tom Lane
tgl@sss.pgh.pa.us
In reply to: Fujii Masao (#1)
Re: default of max_stack_depth

Fujii Masao <masao.fujii@gmail.com> writes:

The document says that the max_stack_depth is 2MB by default.
OTOH, in the source code, the variable max_stack_depth is
initialized with 100 (kB), and guc.c also uses 100 as the
default. Why?

The initial value needs to be small until we have been able to probe
rlimit and figure out what is safe.

regards, tom lane

#3Fujii Masao
masao.fujii@gmail.com
In reply to: Tom Lane (#2)
Re: default of max_stack_depth

On Fri, Aug 6, 2010 at 11:02 PM, Tom Lane <tgl@sss.pgh.pa.us> wrote:

Fujii Masao <masao.fujii@gmail.com> writes:

The document says that the max_stack_depth is 2MB by default.
OTOH, in the source code, the variable max_stack_depth is
initialized with 100 (kB), and guc.c also uses 100 as the
default. Why?

The initial value needs to be small until we have been able to probe
rlimit and figure out what is safe.

Thanks! How about adding the comment about that as follows?

*** a/src/backend/utils/misc/guc.c
--- b/src/backend/utils/misc/guc.c
***************
*** 1520,1525 **** static struct config_int ConfigureNamesInt[] =
--- 1520,1531 ----
                16384, 1024, MAX_KILOBYTES, NULL, NULL
        },
+       /*
+        * Note: the real default of max_stack_depth is calculated in
+        * InitializeGUCOptions(). We use 100 as the sufficiently small
+        * initial value until we have been able to probe rlimit and
+        * figure out what is safe.
+        */
        {
                {"max_stack_depth", PGC_SUSET, RESOURCES_MEM,
                        gettext_noop("Sets the maximum stack depth, in
kilobytes."),

Regards,

--
Fujii Masao
NIPPON TELEGRAPH AND TELEPHONE CORPORATION
NTT Open Source Software Center

#4Tom Lane
tgl@sss.pgh.pa.us
In reply to: Fujii Masao (#3)
Re: default of max_stack_depth

Fujii Masao <masao.fujii@gmail.com> writes:

On Fri, Aug 6, 2010 at 11:02 PM, Tom Lane <tgl@sss.pgh.pa.us> wrote:

The initial value needs to be small until we have been able to probe
rlimit and figure out what is safe.

Thanks! How about adding the comment about that as follows?

I added this:

/*
* We use the hopefully-safely-small value of 100kB as the compiled-in
* default for max_stack_depth. InitializeGUCOptions will increase it if
* possible, depending on the actual platform-specific stack limit.
*/

although I don't entirely see the point. We are certainly not going to
comment every variable whose compiled-in default gets changed by later
processing.

regards, tom lane