Location via proxy:   [ UP ]  
[Report a bug]   [Manage cookies]                
Skip to content

Commit a37422e

Browse files
committed
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.
1 parent a598385 commit a37422e

File tree

2 files changed

+38
-11
lines changed

2 files changed

+38
-11
lines changed

doc/src/sgml/config.sgml

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
<!--
2-
$PostgreSQL: pgsql/doc/src/sgml/config.sgml,v 1.40 2005/12/23 00:38:03 momjian Exp $
2+
$PostgreSQL: pgsql/doc/src/sgml/config.sgml,v 1.41 2005/12/27 23:54:01 adunstan Exp $
33
-->
44
<chapter Id="runtime-config">
55
<title>Server Configuration</title>
@@ -672,7 +672,7 @@ SET ENABLE_SEQSCAN TO OFF;
672672
<listitem>
673673
<para>
674674
Sets the number of shared memory buffers used by the database
675-
server. The default is typically 1000, but may be less if your
675+
server. The default is typically 4000, but may be less if your
676676
kernel settings will not support it (as determined during
677677
<application>initdb</>). Each buffer is 8192 bytes, unless a
678678
different value of <symbol>BLCKSZ</symbol> was chosen when building
@@ -867,8 +867,10 @@ SET ENABLE_SEQSCAN TO OFF;
867867
Sets the maximum number of disk pages for which free space will
868868
be tracked in the shared free-space map. Six bytes of shared memory
869869
are consumed for each page slot. This setting must be more than
870-
16 * <varname>max_fsm_relations</varname>. The default is 20000.
871-
This option can only be set at server start.
870+
16 * <varname>max_fsm_relations</varname>. The default is 20000,
871+
but <application>initdb</> will try to set it as close as possible
872+
to 200000, depending on the amount of available memory.
873+
This option can only be set at server start.
872874
</para>
873875
</listitem>
874876
</varlistentry>

src/bin/initdb/initdb.c

Lines changed: 32 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@
4242
* Portions Copyright (c) 1994, Regents of the University of California
4343
* Portions taken from FreeBSD.
4444
*
45-
* $PostgreSQL: pgsql/src/bin/initdb/initdb.c,v 1.101 2005/12/09 15:51:14 petere Exp $
45+
* $PostgreSQL: pgsql/src/bin/initdb/initdb.c,v 1.102 2005/12/27 23:54:01 adunstan Exp $
4646
*
4747
*-------------------------------------------------------------------------
4848
*/
@@ -120,6 +120,7 @@ static int output_errno = 0;
120120
/* defaults */
121121
static int n_connections = 10;
122122
static int n_buffers = 50;
123+
static int n_fsm_pages = 20000;
123124

124125
/*
125126
* Warning messages for authentication methods
@@ -1083,6 +1084,13 @@ set_null_conf(void)
10831084
}
10841085
}
10851086

1087+
/*
1088+
* max_fsm_pages setting used in both the shared_buffers and max_connections
1089+
* tests.
1090+
*/
1091+
1092+
#define TEST_FSM(x) ( (x) > 1000 ? 50 * (x) : 20000 )
1093+
10861094
/*
10871095
* check how many connections we can sustain
10881096
*/
@@ -1100,12 +1108,17 @@ test_connections(void)
11001108

11011109
for (i = 0; i < len; i++)
11021110
{
1111+
int test_buffs = conns[i] * 5;
1112+
int test_max_fsm = TEST_FSM(test_buffs);
1113+
11031114
snprintf(cmd, sizeof(cmd),
11041115
"%s\"%s\" -boot -x0 %s "
1116+
"-c max_fsm_pages=%d "
11051117
"-c shared_buffers=%d -c max_connections=%d template1 "
11061118
"< \"%s\" > \"%s\" 2>&1%s",
11071119
SYSTEMQUOTE, backend_exec, boot_options,
1108-
conns[i] * 5, conns[i],
1120+
test_max_fsm,
1121+
test_buffs, conns[i],
11091122
DEVNULL, DEVNULL, SYSTEMQUOTE);
11101123
status = system(cmd);
11111124
if (status == 0)
@@ -1125,22 +1138,30 @@ static void
11251138
test_buffers(void)
11261139
{
11271140
char cmd[MAXPGPATH];
1128-
static const int bufs[] = {1000, 900, 800, 700, 600, 500,
1129-
400, 300, 200, 100, 50};
1141+
static const int bufs[] = {
1142+
4000, 3500, 3000, 2500, 2000, 1500,
1143+
1000, 900, 800, 700, 600, 500,
1144+
400, 300, 200, 100, 50
1145+
};
11301146
static const int len = sizeof(bufs) / sizeof(int);
11311147
int i,
1132-
status;
1148+
status,
1149+
test_max_fsm_pages;
11331150

1134-
printf(_("selecting default shared_buffers ... "));
1151+
printf(_("selecting default shared_buffers/max_fsm_pages ... "));
11351152
fflush(stdout);
11361153

11371154
for (i = 0; i < len; i++)
11381155
{
1156+
test_max_fsm_pages = TEST_FSM(bufs[i]);
1157+
11391158
snprintf(cmd, sizeof(cmd),
11401159
"%s\"%s\" -boot -x0 %s "
1160+
"-c max_fsm_pages=%d "
11411161
"-c shared_buffers=%d -c max_connections=%d template1 "
11421162
"< \"%s\" > \"%s\" 2>&1%s",
11431163
SYSTEMQUOTE, backend_exec, boot_options,
1164+
test_max_fsm_pages,
11441165
bufs[i], n_connections,
11451166
DEVNULL, DEVNULL, SYSTEMQUOTE);
11461167
status = system(cmd);
@@ -1150,8 +1171,9 @@ test_buffers(void)
11501171
if (i >= len)
11511172
i = len - 1;
11521173
n_buffers = bufs[i];
1174+
n_fsm_pages = test_max_fsm_pages;
11531175

1154-
printf("%d\n", n_buffers);
1176+
printf("%d/%d\n", n_buffers, n_fsm_pages);
11551177
}
11561178

11571179
/*
@@ -1177,6 +1199,9 @@ setup_config(void)
11771199
snprintf(repltok, sizeof(repltok), "shared_buffers = %d", n_buffers);
11781200
conflines = replace_token(conflines, "#shared_buffers = 1000", repltok);
11791201

1202+
snprintf(repltok, sizeof(repltok), "max_fsm_pages = %d", n_fsm_pages);
1203+
conflines = replace_token(conflines, "#max_fsm_pages = 20000", repltok);
1204+
11801205
#if DEF_PGPORT != 5432
11811206
snprintf(repltok, sizeof(repltok), "#port = %d", DEF_PGPORT);
11821207
conflines = replace_token(conflines, "#port = 5432", repltok);

0 commit comments

Comments
 (0)