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 intoutput_errno = 0;
120120/* defaults */
121121static int n_connections = 10 ;
122122static 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
11011109for (i = 0 ;i < len ;i ++ )
11021110{
1111+ int test_buffs = conns [i ]* 5 ;
1112+ int test_max_fsm = TEST_FSM (test_buffs );
1113+
11031114snprintf (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" ,
11071119SYSTEMQUOTE ,backend_exec ,boot_options ,
1108- conns [i ]* 5 ,conns [i ],
1120+ test_max_fsm ,
1121+ test_buffs ,conns [i ],
11091122DEVNULL ,DEVNULL ,SYSTEMQUOTE );
11101123status = system (cmd );
11111124if (status == 0 )
@@ -1125,22 +1138,30 @@ static void
11251138test_buffers (void )
11261139{
11271140char 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+ };
11301146static const int len = sizeof (bufs ) /sizeof (int );
11311147int 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 ... " ));
11351152fflush (stdout );
11361153
11371154for (i = 0 ;i < len ;i ++ )
11381155{
1156+ test_max_fsm_pages = TEST_FSM (bufs [i ]);
1157+
11391158snprintf (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" ,
11431163SYSTEMQUOTE ,backend_exec ,boot_options ,
1164+ test_max_fsm_pages ,
11441165bufs [i ],n_connections ,
11451166DEVNULL ,DEVNULL ,SYSTEMQUOTE );
11461167status = system (cmd );
@@ -1150,8 +1171,9 @@ test_buffers(void)
11501171if (i >=len )
11511172i = len - 1 ;
11521173n_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)
11771199snprintf (repltok ,sizeof (repltok ),"shared_buffers = %d" ,n_buffers );
11781200conflines = 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
11811206snprintf (repltok ,sizeof (repltok ),"#port = %d" ,DEF_PGPORT );
11821207conflines = replace_token (conflines ,"#port = 5432" ,repltok );