postgresql.conf.
- shared_buffers = 32000kB => 32MB
- temp_buffers = 8000kB => 8MB
- wal_buffers = 8 => 64kB
The code of initdb was a bit modified to write MB-unit values.
Values greater than 8000kB are rounded out to MB.
GUC_UNIT_XBLOCKS is added for wal_buffers. It is like GUC_UNIT_BLOCKS,
but uses XLOG_BLCKSZ instead of BLCKSZ.
Also, I cleaned up the test of GUC_UNIT_* flags in preparation to
add more unit flags in less bits.
ITAGAKI Takahiro
* Written by Peter Eisentraut <peter_e@gmx.net>.
*
* IDENTIFICATION
- * $PostgreSQL: pgsql/src/backend/utils/misc/guc.c,v 1.352 2006/09/22 21:39:57 tgl Exp $
+ * $PostgreSQL: pgsql/src/backend/utils/misc/guc.c,v 1.353 2006/10/03 21:11:54 momjian Exp $
*
*--------------------------------------------------------------------
*/
GUC_UNIT_BLOCKS
},
&NBuffers,
- 1000, 16, INT_MAX / 2, NULL, NULL
+ 1024, 16, INT_MAX / 2, NULL, NULL
},
{
GUC_UNIT_BLOCKS
},
&num_temp_buffers,
- 1000, 100, INT_MAX / 2, NULL, show_num_temp_buffers
+ 1024, 100, INT_MAX / 2, NULL, show_num_temp_buffers
},
{
{
{"wal_buffers", PGC_POSTMASTER, WAL_SETTINGS,
gettext_noop("Sets the number of disk-page buffers in shared memory for WAL."),
- NULL
+ NULL,
+ GUC_UNIT_XBLOCKS
},
&XLOGbuffers,
8, 4, INT_MAX, NULL, NULL
endptr += 2;
}
- if (used && (flags & GUC_UNIT_BLOCKS))
- val /= (BLCKSZ/1024);
+ if (used)
+ {
+ switch (flags & GUC_UNIT_MEMORY)
+ {
+ case GUC_UNIT_BLOCKS:
+ val /= (BLCKSZ/1024);
+ break;
+ case GUC_UNIT_XBLOCKS:
+ val /= (XLOG_BLCKSZ/1024);
+ break;
+ }
+ }
}
if ((flags & GUC_UNIT_TIME) && endptr != value)
endptr += 1;
}
- if (used && (flags & GUC_UNIT_S))
- val /= MS_PER_S;
- else if (used && (flags & GUC_UNIT_MIN))
- val /= MS_PER_MIN;
+ if (used)
+ {
+ switch (flags & GUC_UNIT_TIME)
+ {
+ case GUC_UNIT_S:
+ val /= MS_PER_S;
+ break;
+ case GUC_UNIT_MIN:
+ val /= MS_PER_MIN;
+ break;
+ }
+ }
}
if (endptr == value || *endptr != '\0' || errno == ERANGE
/* unit */
if (conf->vartype == PGC_INT)
{
- if (conf->flags & GUC_UNIT_KB)
- values[2] = "kB";
- else if (conf->flags & GUC_UNIT_BLOCKS)
- {
- static char buf[8];
+ static char buf[8];
- snprintf(buf, sizeof(buf), "%dkB", BLCKSZ/1024);
- values[2] = buf;
+ switch (conf->flags & (GUC_UNIT_MEMORY | GUC_UNIT_TIME))
+ {
+ case GUC_UNIT_KB:
+ values[2] = "kB";
+ break;
+ case GUC_UNIT_BLOCKS:
+ snprintf(buf, sizeof(buf), "%dkB", BLCKSZ/1024);
+ values[2] = buf;
+ break;
+ case GUC_UNIT_XBLOCKS:
+ snprintf(buf, sizeof(buf), "%dkB", XLOG_BLCKSZ/1024);
+ values[2] = buf;
+ break;
+ case GUC_UNIT_MS:
+ values[2] = "ms";
+ break;
+ case GUC_UNIT_S:
+ values[2] = "s";
+ break;
+ case GUC_UNIT_MIN:
+ values[2] = "min";
+ break;
+ default:
+ values[2] = "";
+ break;
}
- else if (conf->flags & GUC_UNIT_MS)
- values[2] = "ms";
- else if (conf->flags & GUC_UNIT_S)
- values[2] = "s";
- else if (conf->flags & GUC_UNIT_MIN)
- values[2] = "min";
- else
- values[2] = "";
}
else
values[2] = NULL;
if (use_units && result > 0 && (record->flags & GUC_UNIT_MEMORY))
{
- if (record->flags & GUC_UNIT_BLOCKS)
- result *= BLCKSZ/1024;
+ switch (record->flags & GUC_UNIT_MEMORY)
+ {
+ case GUC_UNIT_BLOCKS:
+ result *= BLCKSZ/1024;
+ break;
+ case GUC_UNIT_XBLOCKS:
+ result *= XLOG_BLCKSZ/1024;
+ break;
+ }
if (result % KB_PER_GB == 0)
{
}
else if (use_units && result > 0 && (record->flags & GUC_UNIT_TIME))
{
- if (record->flags & GUC_UNIT_S)
- result = result * MS_PER_S;
- else if (record->flags & GUC_UNIT_MIN)
- result = result * MS_PER_MIN;
+ switch (record->flags & GUC_UNIT_TIME)
+ {
+ case GUC_UNIT_S:
+ result *= MS_PER_S;
+ break;
+ case GUC_UNIT_MIN:
+ result *= MS_PER_MIN;
+ break;
+ }
if (result % MS_PER_D == 0)
{
# - Memory -
-#shared_buffers = 32000kB # min 128kB or max_connections*16kB
+#shared_buffers = 32MB # min 128kB or max_connections*16kB
# (change requires restart)
-#temp_buffers = 8000kB # min 800kB
+#temp_buffers = 8MB # min 800kB
#max_prepared_transactions = 5 # can be 0 or more
# (change requires restart)
# Note: increasing max_prepared_transactions costs ~600 bytes of shared memory
# - Free Space Map -
-#max_fsm_pages = 1600000 # min max_fsm_relations*16, 6 bytes each
+#max_fsm_pages = 1638400 # min max_fsm_relations*16, 6 bytes each
# (change requires restart)
#max_fsm_relations = 1000 # min 100, ~70 bytes each
# (change requires restart)
# fsync_writethrough
# open_sync
#full_page_writes = on # recover from partial page writes
-#wal_buffers = 8 # min 4, 8kB each
+#wal_buffers = 64kB # min 4, 8kB each
# (change requires restart)
#commit_delay = 0 # range 0-100000, in microseconds
#commit_siblings = 5 # range 1-1000
* Portions Copyright (c) 1994, Regents of the University of California
* Portions taken from FreeBSD.
*
- * $PostgreSQL: pgsql/src/bin/initdb/initdb.c,v 1.122 2006/09/14 23:21:47 momjian Exp $
+ * $PostgreSQL: pgsql/src/bin/initdb/initdb.c,v 1.123 2006/10/03 21:11:55 momjian Exp $
*
*-------------------------------------------------------------------------
*/
static const int trial_conns[] = {
100, 50, 40, 30, 20, 10
};
+
+ /*
+ * Candidate values for shared_buffers in kB. When the value is
+ * divisible by 1024, we write it in MB-unit to configuration files.
+ */
static const int trial_bufs[] = {
- 32000, 28000, 24000, 20000, 16000, 12000,
- 8000, 7200, 6400, 5600, 4800, 4000,
- 3200, 2400, 1600, 800, 400
+ 32768, 28672, 24576, 20480, 16384, 12288,
+ 8192, 7200, 6400, 5600, 4800, 4000,
};
char cmd[MAXPGPATH];
n_buffers = test_buffs;
n_fsm_pages = FSM_FOR_BUFS(n_buffers);
- printf("%dkB/%d\n", n_buffers, n_fsm_pages);
+ if (n_buffers % 1024 == 0)
+ printf("%dMB/%d\n", n_buffers/1024, n_fsm_pages);
+ else
+ printf("%dkB/%d\n", n_buffers, n_fsm_pages);
}
/*
snprintf(repltok, sizeof(repltok), "max_connections = %d", n_connections);
conflines = replace_token(conflines, "#max_connections = 100", repltok);
- snprintf(repltok, sizeof(repltok), "shared_buffers = %dkB", n_buffers);
- conflines = replace_token(conflines, "#shared_buffers = 32000kB", repltok);
+ if (n_buffers % 1024 == 0)
+ snprintf(repltok, sizeof(repltok), "shared_buffers = %dMB", n_buffers/1024);
+ else
+ snprintf(repltok, sizeof(repltok), "shared_buffers = %dkB", n_buffers);
+ conflines = replace_token(conflines, "#shared_buffers = 32MB", repltok);
snprintf(repltok, sizeof(repltok), "max_fsm_pages = %d", n_fsm_pages);
- conflines = replace_token(conflines, "#max_fsm_pages = 1600000", repltok);
+ conflines = replace_token(conflines, "#max_fsm_pages = 1638400", repltok);
#if DEF_PGPORT != 5432
snprintf(repltok, sizeof(repltok), "#port = %d", DEF_PGPORT);
*
* Portions Copyright (c) 1996-2006, PostgreSQL Global Development Group
*
- * $PostgreSQL: pgsql/src/include/utils/guc_tables.h,v 1.28 2006/08/14 02:27:27 momjian Exp $
+ * $PostgreSQL: pgsql/src/include/utils/guc_tables.h,v 1.29 2006/10/03 21:11:55 momjian Exp $
*
*-------------------------------------------------------------------------
*/
#define GUC_UNIT_KB 0x0400 /* value is in 1 kB */
#define GUC_UNIT_BLOCKS 0x0800 /* value is in blocks */
-#define GUC_UNIT_MEMORY (GUC_UNIT_KB|GUC_UNIT_BLOCKS)
+#define GUC_UNIT_XBLOCKS 0x0C00 /* value is in xlog blocks */
+#define GUC_UNIT_MEMORY 0x0C00 /* mask for KB, BLOCKS, XBLOCKS */
#define GUC_UNIT_MS 0x1000 /* value is in milliseconds */
#define GUC_UNIT_S 0x2000 /* value is in seconds */
#define GUC_UNIT_MIN 0x4000 /* value is in minutes */
-#define GUC_UNIT_TIME (GUC_UNIT_MS|GUC_UNIT_S|GUC_UNIT_MIN)
+#define GUC_UNIT_TIME 0x7000 /* mask for MS, S, MIN */
/* bit values in status field */
#define GUC_HAVE_TENTATIVE 0x0001 /* tentative value is defined */