Increase amount of shared buffers initdb tries to allocate to 4000,
and add logic to try max_fsm_pages up to 200000, plus accompanying minor docs changes.
This commit is contained in:
parent
a598385f3b
commit
a37422e042
|
@ -1,5 +1,5 @@
|
||||||
<!--
|
<!--
|
||||||
$PostgreSQL: pgsql/doc/src/sgml/config.sgml,v 1.40 2005/12/23 00:38:03 momjian Exp $
|
$PostgreSQL: pgsql/doc/src/sgml/config.sgml,v 1.41 2005/12/27 23:54:01 adunstan Exp $
|
||||||
-->
|
-->
|
||||||
<chapter Id="runtime-config">
|
<chapter Id="runtime-config">
|
||||||
<title>Server Configuration</title>
|
<title>Server Configuration</title>
|
||||||
|
@ -672,7 +672,7 @@ SET ENABLE_SEQSCAN TO OFF;
|
||||||
<listitem>
|
<listitem>
|
||||||
<para>
|
<para>
|
||||||
Sets the number of shared memory buffers used by the database
|
Sets the number of shared memory buffers used by the database
|
||||||
server. The default is typically 1000, but may be less if your
|
server. The default is typically 4000, but may be less if your
|
||||||
kernel settings will not support it (as determined during
|
kernel settings will not support it (as determined during
|
||||||
<application>initdb</>). Each buffer is 8192 bytes, unless a
|
<application>initdb</>). Each buffer is 8192 bytes, unless a
|
||||||
different value of <symbol>BLCKSZ</symbol> was chosen when building
|
different value of <symbol>BLCKSZ</symbol> was chosen when building
|
||||||
|
@ -867,7 +867,9 @@ SET ENABLE_SEQSCAN TO OFF;
|
||||||
Sets the maximum number of disk pages for which free space will
|
Sets the maximum number of disk pages for which free space will
|
||||||
be tracked in the shared free-space map. Six bytes of shared memory
|
be tracked in the shared free-space map. Six bytes of shared memory
|
||||||
are consumed for each page slot. This setting must be more than
|
are consumed for each page slot. This setting must be more than
|
||||||
16 * <varname>max_fsm_relations</varname>. The default is 20000.
|
16 * <varname>max_fsm_relations</varname>. The default is 20000,
|
||||||
|
but <application>initdb</> will try to set it as close as possible
|
||||||
|
to 200000, depending on the amount of available memory.
|
||||||
This option can only be set at server start.
|
This option can only be set at server start.
|
||||||
</para>
|
</para>
|
||||||
</listitem>
|
</listitem>
|
||||||
|
|
|
@ -42,7 +42,7 @@
|
||||||
* Portions Copyright (c) 1994, Regents of the University of California
|
* Portions Copyright (c) 1994, Regents of the University of California
|
||||||
* Portions taken from FreeBSD.
|
* Portions taken from FreeBSD.
|
||||||
*
|
*
|
||||||
* $PostgreSQL: pgsql/src/bin/initdb/initdb.c,v 1.101 2005/12/09 15:51:14 petere Exp $
|
* $PostgreSQL: pgsql/src/bin/initdb/initdb.c,v 1.102 2005/12/27 23:54:01 adunstan Exp $
|
||||||
*
|
*
|
||||||
*-------------------------------------------------------------------------
|
*-------------------------------------------------------------------------
|
||||||
*/
|
*/
|
||||||
|
@ -120,6 +120,7 @@ static int output_errno = 0;
|
||||||
/* defaults */
|
/* defaults */
|
||||||
static int n_connections = 10;
|
static int n_connections = 10;
|
||||||
static int n_buffers = 50;
|
static int n_buffers = 50;
|
||||||
|
static int n_fsm_pages = 20000;
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Warning messages for authentication methods
|
* Warning messages for authentication methods
|
||||||
|
@ -1083,6 +1084,13 @@ set_null_conf(void)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
* max_fsm_pages setting used in both the shared_buffers and max_connections
|
||||||
|
* tests.
|
||||||
|
*/
|
||||||
|
|
||||||
|
#define TEST_FSM(x) ( (x) > 1000 ? 50 * (x) : 20000 )
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* check how many connections we can sustain
|
* check how many connections we can sustain
|
||||||
*/
|
*/
|
||||||
|
@ -1100,12 +1108,17 @@ test_connections(void)
|
||||||
|
|
||||||
for (i = 0; i < len; i++)
|
for (i = 0; i < len; i++)
|
||||||
{
|
{
|
||||||
|
int test_buffs = conns[i] * 5;
|
||||||
|
int test_max_fsm = TEST_FSM(test_buffs);
|
||||||
|
|
||||||
snprintf(cmd, sizeof(cmd),
|
snprintf(cmd, sizeof(cmd),
|
||||||
"%s\"%s\" -boot -x0 %s "
|
"%s\"%s\" -boot -x0 %s "
|
||||||
|
"-c max_fsm_pages=%d "
|
||||||
"-c shared_buffers=%d -c max_connections=%d template1 "
|
"-c shared_buffers=%d -c max_connections=%d template1 "
|
||||||
"< \"%s\" > \"%s\" 2>&1%s",
|
"< \"%s\" > \"%s\" 2>&1%s",
|
||||||
SYSTEMQUOTE, backend_exec, boot_options,
|
SYSTEMQUOTE, backend_exec, boot_options,
|
||||||
conns[i] * 5, conns[i],
|
test_max_fsm,
|
||||||
|
test_buffs, conns[i],
|
||||||
DEVNULL, DEVNULL, SYSTEMQUOTE);
|
DEVNULL, DEVNULL, SYSTEMQUOTE);
|
||||||
status = system(cmd);
|
status = system(cmd);
|
||||||
if (status == 0)
|
if (status == 0)
|
||||||
|
@ -1125,22 +1138,30 @@ static void
|
||||||
test_buffers(void)
|
test_buffers(void)
|
||||||
{
|
{
|
||||||
char cmd[MAXPGPATH];
|
char cmd[MAXPGPATH];
|
||||||
static const int bufs[] = {1000, 900, 800, 700, 600, 500,
|
static const int bufs[] = {
|
||||||
400, 300, 200, 100, 50};
|
4000, 3500, 3000, 2500, 2000, 1500,
|
||||||
|
1000, 900, 800, 700, 600, 500,
|
||||||
|
400, 300, 200, 100, 50
|
||||||
|
};
|
||||||
static const int len = sizeof(bufs) / sizeof(int);
|
static const int len = sizeof(bufs) / sizeof(int);
|
||||||
int i,
|
int i,
|
||||||
status;
|
status,
|
||||||
|
test_max_fsm_pages;
|
||||||
|
|
||||||
printf(_("selecting default shared_buffers ... "));
|
printf(_("selecting default shared_buffers/max_fsm_pages ... "));
|
||||||
fflush(stdout);
|
fflush(stdout);
|
||||||
|
|
||||||
for (i = 0; i < len; i++)
|
for (i = 0; i < len; i++)
|
||||||
{
|
{
|
||||||
|
test_max_fsm_pages = TEST_FSM(bufs[i]);
|
||||||
|
|
||||||
snprintf(cmd, sizeof(cmd),
|
snprintf(cmd, sizeof(cmd),
|
||||||
"%s\"%s\" -boot -x0 %s "
|
"%s\"%s\" -boot -x0 %s "
|
||||||
|
"-c max_fsm_pages=%d "
|
||||||
"-c shared_buffers=%d -c max_connections=%d template1 "
|
"-c shared_buffers=%d -c max_connections=%d template1 "
|
||||||
"< \"%s\" > \"%s\" 2>&1%s",
|
"< \"%s\" > \"%s\" 2>&1%s",
|
||||||
SYSTEMQUOTE, backend_exec, boot_options,
|
SYSTEMQUOTE, backend_exec, boot_options,
|
||||||
|
test_max_fsm_pages,
|
||||||
bufs[i], n_connections,
|
bufs[i], n_connections,
|
||||||
DEVNULL, DEVNULL, SYSTEMQUOTE);
|
DEVNULL, DEVNULL, SYSTEMQUOTE);
|
||||||
status = system(cmd);
|
status = system(cmd);
|
||||||
|
@ -1150,8 +1171,9 @@ test_buffers(void)
|
||||||
if (i >= len)
|
if (i >= len)
|
||||||
i = len - 1;
|
i = len - 1;
|
||||||
n_buffers = bufs[i];
|
n_buffers = bufs[i];
|
||||||
|
n_fsm_pages = test_max_fsm_pages;
|
||||||
|
|
||||||
printf("%d\n", n_buffers);
|
printf("%d/%d\n", n_buffers, n_fsm_pages);
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
@ -1177,6 +1199,9 @@ setup_config(void)
|
||||||
snprintf(repltok, sizeof(repltok), "shared_buffers = %d", n_buffers);
|
snprintf(repltok, sizeof(repltok), "shared_buffers = %d", n_buffers);
|
||||||
conflines = replace_token(conflines, "#shared_buffers = 1000", repltok);
|
conflines = replace_token(conflines, "#shared_buffers = 1000", repltok);
|
||||||
|
|
||||||
|
snprintf(repltok, sizeof(repltok), "max_fsm_pages = %d", n_fsm_pages);
|
||||||
|
conflines = replace_token(conflines, "#max_fsm_pages = 20000", repltok);
|
||||||
|
|
||||||
#if DEF_PGPORT != 5432
|
#if DEF_PGPORT != 5432
|
||||||
snprintf(repltok, sizeof(repltok), "#port = %d", DEF_PGPORT);
|
snprintf(repltok, sizeof(repltok), "#port = %d", DEF_PGPORT);
|
||||||
conflines = replace_token(conflines, "#port = 5432", repltok);
|
conflines = replace_token(conflines, "#port = 5432", repltok);
|
||||||
|
|
Loading…
Reference in New Issue