Extend yesterday's patch making BLCKSZ and RELSEG_SIZE configurable to also

let XLOG_BLCKSZ and XLOG_SEG_SIZE be set via configure.  Per a proposal by
Mark Wong, though I thought it better to call the switches after "wal" rather
than "xlog".
This commit is contained in:
Tom Lane 2008-05-02 19:52:37 +00:00
parent b3fb2d6505
commit cf9f6c8d8e
6 changed files with 220 additions and 31 deletions

116
configure vendored
View File

@ -1373,8 +1373,10 @@ Optional Packages:
--with-libraries=DIRS look for additional libraries in DIRS
--with-libs=DIRS alternative spelling of --with-libraries
--with-pgport=PORTNUM set default port number [5432]
--with-blocksize=BLOCKSIZE set block size in kB [8]
--with-segsize=SEGSIZE set segment size in GB [1]
--with-blocksize=BLOCKSIZE set table block size in kB [8]
--with-segsize=SEGSIZE set table segment size in GB [1]
--with-wal-blocksize=BLOCKSIZE set WAL block size in kB [8]
--with-wal-segsize=SEGSIZE set WAL segment size in MB [16]
--with-tcl build Tcl modules (PL/Tcl)
--with-tclconfig=DIR tclConfig.sh is in DIR
--with-perl build Perl modules (PL/Perl)
@ -2603,7 +2605,7 @@ _ACEOF
#
# File segment size
# Relation segment size
#
{ echo "$as_me:$LINENO: checking for segment size" >&5
echo $ECHO_N "checking for segment size... $ECHO_C" >&6; }
@ -2647,6 +2649,114 @@ cat >>confdefs.h <<_ACEOF
_ACEOF
#
# WAL block size
#
{ echo "$as_me:$LINENO: checking for WAL block size" >&5
echo $ECHO_N "checking for WAL block size... $ECHO_C" >&6; }
pgac_args="$pgac_args with_wal_blocksize"
# Check whether --with-wal-blocksize was given.
if test "${with_wal_blocksize+set}" = set; then
withval=$with_wal_blocksize;
case $withval in
yes)
{ { echo "$as_me:$LINENO: error: argument required for --with-wal-blocksize option" >&5
echo "$as_me: error: argument required for --with-wal-blocksize option" >&2;}
{ (exit 1); exit 1; }; }
;;
no)
{ { echo "$as_me:$LINENO: error: argument required for --with-wal-blocksize option" >&5
echo "$as_me: error: argument required for --with-wal-blocksize option" >&2;}
{ (exit 1); exit 1; }; }
;;
*)
wal_blocksize=$withval
;;
esac
else
wal_blocksize=8
fi
case ${wal_blocksize} in
1) XLOG_BLCKSZ=1024;;
2) XLOG_BLCKSZ=2048;;
4) XLOG_BLCKSZ=4096;;
8) XLOG_BLCKSZ=8192;;
16) XLOG_BLCKSZ=16384;;
32) XLOG_BLCKSZ=32768;;
64) XLOG_BLCKSZ=65536;;
*) { { echo "$as_me:$LINENO: error: Invalid WAL block size. Allowed values are 1,2,4,8,16,32,64." >&5
echo "$as_me: error: Invalid WAL block size. Allowed values are 1,2,4,8,16,32,64." >&2;}
{ (exit 1); exit 1; }; }
esac
{ echo "$as_me:$LINENO: result: ${wal_blocksize}kB" >&5
echo "${ECHO_T}${wal_blocksize}kB" >&6; }
cat >>confdefs.h <<_ACEOF
#define XLOG_BLCKSZ ${XLOG_BLCKSZ}
_ACEOF
#
# WAL segment size
#
{ echo "$as_me:$LINENO: checking for WAL segment size" >&5
echo $ECHO_N "checking for WAL segment size... $ECHO_C" >&6; }
pgac_args="$pgac_args with_wal_segsize"
# Check whether --with-wal-segsize was given.
if test "${with_wal_segsize+set}" = set; then
withval=$with_wal_segsize;
case $withval in
yes)
{ { echo "$as_me:$LINENO: error: argument required for --with-wal-segsize option" >&5
echo "$as_me: error: argument required for --with-wal-segsize option" >&2;}
{ (exit 1); exit 1; }; }
;;
no)
{ { echo "$as_me:$LINENO: error: argument required for --with-wal-segsize option" >&5
echo "$as_me: error: argument required for --with-wal-segsize option" >&2;}
{ (exit 1); exit 1; }; }
;;
*)
wal_segsize=$withval
;;
esac
else
wal_segsize=16
fi
case ${wal_segsize} in
1) ;;
2) ;;
4) ;;
8) ;;
16) ;;
32) ;;
64) ;;
*) { { echo "$as_me:$LINENO: error: Invalid WAL segment size. Allowed values are 1,2,4,8,16,32,64." >&5
echo "$as_me: error: Invalid WAL segment size. Allowed values are 1,2,4,8,16,32,64." >&2;}
{ (exit 1); exit 1; }; }
esac
{ echo "$as_me:$LINENO: result: ${wal_segsize}MB" >&5
echo "${ECHO_T}${wal_segsize}MB" >&6; }
cat >>confdefs.h <<_ACEOF
#define XLOG_SEG_SIZE (${wal_segsize} * 1024 * 1024)
_ACEOF
#
# C compiler
#

View File

@ -1,5 +1,5 @@
dnl Process this file with autoconf to produce a configure script.
dnl $PostgreSQL: pgsql/configure.in,v 1.558 2008/05/02 01:08:26 tgl Exp $
dnl $PostgreSQL: pgsql/configure.in,v 1.559 2008/05/02 19:52:37 tgl Exp $
dnl
dnl Developers, please strive to achieve this order:
dnl
@ -221,7 +221,7 @@ AC_SUBST(enable_dtrace)
# Block size
#
AC_MSG_CHECKING([for block size])
PGAC_ARG_REQ(with, blocksize, [ --with-blocksize=BLOCKSIZE set block size in kB [[8]]],
PGAC_ARG_REQ(with, blocksize, [ --with-blocksize=BLOCKSIZE set table block size in kB [[8]]],
[blocksize=$withval],
[blocksize=8])
case ${blocksize} in
@ -250,10 +250,10 @@ AC_DEFINE_UNQUOTED([BLCKSZ], ${BLCKSZ}, [
])
#
# File segment size
# Relation segment size
#
AC_MSG_CHECKING([for segment size])
PGAC_ARG_REQ(with, segsize, [ --with-segsize=SEGSIZE set segment size in GB [[1]]],
PGAC_ARG_REQ(with, segsize, [ --with-segsize=SEGSIZE set table segment size in GB [[1]]],
[segsize=$withval],
[segsize=1])
# this expression is set up to avoid unnecessary integer overflow
@ -280,6 +280,61 @@ AC_DEFINE_UNQUOTED([RELSEG_SIZE], ${RELSEG_SIZE}, [
Changing RELSEG_SIZE requires an initdb.
])
#
# WAL block size
#
AC_MSG_CHECKING([for WAL block size])
PGAC_ARG_REQ(with, wal-blocksize, [ --with-wal-blocksize=BLOCKSIZE set WAL block size in kB [[8]]],
[wal_blocksize=$withval],
[wal_blocksize=8])
case ${wal_blocksize} in
1) XLOG_BLCKSZ=1024;;
2) XLOG_BLCKSZ=2048;;
4) XLOG_BLCKSZ=4096;;
8) XLOG_BLCKSZ=8192;;
16) XLOG_BLCKSZ=16384;;
32) XLOG_BLCKSZ=32768;;
64) XLOG_BLCKSZ=65536;;
*) AC_MSG_ERROR([Invalid WAL block size. Allowed values are 1,2,4,8,16,32,64.])
esac
AC_MSG_RESULT([${wal_blocksize}kB])
AC_DEFINE_UNQUOTED([XLOG_BLCKSZ], ${XLOG_BLCKSZ}, [
Size of a WAL file block. This need have no particular relation to BLCKSZ.
XLOG_BLCKSZ must be a power of 2, and if your system supports O_DIRECT I/O,
XLOG_BLCKSZ must be a multiple of the alignment requirement for direct-I/O
buffers, else direct I/O may fail.
Changing XLOG_BLCKSZ requires an initdb.
])
#
# WAL segment size
#
AC_MSG_CHECKING([for WAL segment size])
PGAC_ARG_REQ(with, wal-segsize, [ --with-wal-segsize=SEGSIZE set WAL segment size in MB [[16]]],
[wal_segsize=$withval],
[wal_segsize=16])
case ${wal_segsize} in
1) ;;
2) ;;
4) ;;
8) ;;
16) ;;
32) ;;
64) ;;
*) AC_MSG_ERROR([Invalid WAL segment size. Allowed values are 1,2,4,8,16,32,64.])
esac
AC_MSG_RESULT([${wal_segsize}MB])
AC_DEFINE_UNQUOTED([XLOG_SEG_SIZE], [(${wal_segsize} * 1024 * 1024)], [
XLOG_SEG_SIZE is the size of a single WAL file. This must be a power of 2
and larger than XLOG_BLCKSZ (preferably, a great deal larger than
XLOG_BLCKSZ).
Changing XLOG_SEG_SIZE requires an initdb.
])
#
# C compiler
#

View File

@ -1,4 +1,4 @@
<!-- $PostgreSQL: pgsql/doc/src/sgml/installation.sgml,v 1.308 2008/05/02 01:08:26 tgl Exp $ -->
<!-- $PostgreSQL: pgsql/doc/src/sgml/installation.sgml,v 1.309 2008/05/02 19:52:37 tgl Exp $ -->
<chapter id="installation">
<title><![%standalone-include[<productname>PostgreSQL</>]]>
@ -1103,6 +1103,34 @@ su - postgres
</listitem>
</varlistentry>
<varlistentry>
<term><option>--with-wal-segsize=<replaceable>SEGSIZE</replaceable></option></term>
<listitem>
<para>
Set the <firstterm>WAL segment size</>, in megabytes. This is
the size of each individual file in the WAL log. It may be useful
to adjust this size to control the granularity of WAL log shipping.
The default size is 16 megabytes.
The value must be a power of 2 between 1 and 64 (megabytes).
Note that changing this value requires an initdb.
</para>
</listitem>
</varlistentry>
<varlistentry>
<term><option>--with-wal-blocksize=<replaceable>BLOCKSIZE</replaceable></option></term>
<listitem>
<para>
Set the <firstterm>WAL block size</>, in kilobytes. This is the unit
of storage and I/O within the WAL log. The default, 8 kilobytes,
is suitable for most situations; but other values may be useful
in special cases.
The value must be a power of 2 between 1 and 64 (kilobytes).
Note that changing this value requires an initdb.
</para>
</listitem>
</varlistentry>
<varlistentry>
<term><option>--disable-spinlocks</option></term>
<listitem>

View File

@ -1,4 +1,4 @@
<!-- $PostgreSQL: pgsql/doc/src/sgml/wal.sgml,v 1.52 2007/12/29 17:55:07 momjian Exp $ -->
<!-- $PostgreSQL: pgsql/doc/src/sgml/wal.sgml,v 1.53 2008/05/02 19:52:37 tgl Exp $ -->
<chapter id="wal">
<title>Reliability and the Write-Ahead Log</title>
@ -487,8 +487,11 @@
<para>
<acronym>WAL</acronym> logs are stored in the directory
<filename>pg_xlog</filename> under the data directory, as a set of
segment files, normally each 16 MB in size. Each segment is divided into
pages, normally 8 kB each. The log record headers are described in
segment files, normally each 16 MB in size (but the size can be changed
by altering the <option>--with-wal-segsize</> configure option when
building the server). Each segment is divided into pages, normally
8 kB each (this size can be changed via the <option>--with-wal-blocksize</>
configure option). The log record headers are described in
<filename>access/xlog.h</filename>; the record content is dependent
on the type of event that is being logged. Segment files are given
ever-increasing numbers as names, starting at

View File

@ -747,6 +747,18 @@
first (like Motorola and SPARC, unlike Intel and VAX). */
#undef WORDS_BIGENDIAN
/* Size of a WAL file block. This need have no particular relation to BLCKSZ.
XLOG_BLCKSZ must be a power of 2, and if your system supports O_DIRECT I/O,
XLOG_BLCKSZ must be a multiple of the alignment requirement for direct-I/O
buffers, else direct I/O may fail. Changing XLOG_BLCKSZ requires an initdb.
*/
#undef XLOG_BLCKSZ
/* XLOG_SEG_SIZE is the size of a single WAL file. This must be a power of 2
and larger than XLOG_BLCKSZ (preferably, a great deal larger than
XLOG_BLCKSZ). Changing XLOG_SEG_SIZE requires an initdb. */
#undef XLOG_SEG_SIZE
/* Number of bits in a file offset, on hosts where this is settable. */
#undef _FILE_OFFSET_BITS

View File

@ -6,29 +6,10 @@
* for developers. If you edit any of these, be sure to do a *full*
* rebuild (and an initdb if noted).
*
* $PostgreSQL: pgsql/src/include/pg_config_manual.h,v 1.32 2008/05/02 01:08:27 tgl Exp $
* $PostgreSQL: pgsql/src/include/pg_config_manual.h,v 1.33 2008/05/02 19:52:37 tgl Exp $
*------------------------------------------------------------------------
*/
/*
* Size of a WAL file block. This need have no particular relation to BLCKSZ.
* XLOG_BLCKSZ must be a power of 2, and if your system supports O_DIRECT I/O,
* XLOG_BLCKSZ must be a multiple of the alignment requirement for direct-I/O
* buffers, else direct I/O may fail.
*
* Changing XLOG_BLCKSZ requires an initdb.
*/
#define XLOG_BLCKSZ 8192
/*
* XLOG_SEG_SIZE is the size of a single WAL file. This must be a power of 2
* and larger than XLOG_BLCKSZ (preferably, a great deal larger than
* XLOG_BLCKSZ).
*
* Changing XLOG_SEG_SIZE requires an initdb.
*/
#define XLOG_SEG_SIZE (16*1024*1024)
/*
* Maximum length for identifiers (e.g. table names, column names,
* function names). It must be a multiple of sizeof(int) (typically