Commit eaef1113 authored by Tom Lane's avatar Tom Lane

Define a separately configurable XLOG_BLCKSZ symbol for the page size

used within WAL files.  Historically this was the same as the data file
BLCKSZ, but there's no necessary connection, and it's possible that
performance gains might ensue from reducing XLOG_BLCKSZ.  In any case
distinguishing two symbols should improve code clarity.  This commit
does not actually change the page size, only provide the infrastructure
to make it possible to do so.  initdb forced because of addition of a
field to pg_control.
Mark Wong, with some help from Simon Riggs and Tom Lane.
parent c8c864c2
<!-- $PostgreSQL: pgsql/doc/src/sgml/runtime.sgml,v 1.365 2006/03/10 19:10:49 momjian Exp $ -->
<!-- $PostgreSQL: pgsql/doc/src/sgml/runtime.sgml,v 1.366 2006/04/03 23:35:02 tgl Exp $ -->
<chapter Id="runtime">
<title>Operating System Environment</title>
......@@ -1061,7 +1061,7 @@ set semsys:seminfo_semmsl=32
<row>
<entry><xref linkend="guc-wal-buffers"></>
<entry>8200 (assuming 8K <symbol>BLCKSZ</>)</entry>
<entry>8200 (assuming 8K <symbol>XLOG_BLCKSZ</>)</entry>
</row>
<row>
......
This diff is collapsed.
......@@ -6,7 +6,7 @@
* copyright (c) Oliver Elphick <olly@lfix.co.uk>, 2001;
* licence: BSD
*
* $PostgreSQL: pgsql/src/bin/pg_controldata/pg_controldata.c,v 1.27 2005/10/15 02:49:37 momjian Exp $
* $PostgreSQL: pgsql/src/bin/pg_controldata/pg_controldata.c,v 1.28 2006/04/03 23:35:04 tgl Exp $
*/
#include "postgres.h"
......@@ -172,6 +172,7 @@ main(int argc, char *argv[])
/* we don't print floatFormat since can't say much useful about it */
printf(_("Database block size: %u\n"), ControlFile.blcksz);
printf(_("Blocks per segment of large relation: %u\n"), ControlFile.relseg_size);
printf(_("WAL block size: %u\n"), ControlFile.xlog_blcksz);
printf(_("Bytes per WAL segment: %u\n"), ControlFile.xlog_seg_size);
printf(_("Maximum length of identifiers: %u\n"), ControlFile.nameDataLen);
printf(_("Maximum columns in an index: %u\n"), ControlFile.indexMaxKeys);
......
......@@ -23,7 +23,7 @@
* Portions Copyright (c) 1996-2006, PostgreSQL Global Development Group
* Portions Copyright (c) 1994, Regents of the University of California
*
* $PostgreSQL: pgsql/src/bin/pg_resetxlog/pg_resetxlog.c,v 1.40 2006/03/05 15:58:51 momjian Exp $
* $PostgreSQL: pgsql/src/bin/pg_resetxlog/pg_resetxlog.c,v 1.41 2006/04/03 23:35:04 tgl Exp $
*
*-------------------------------------------------------------------------
*/
......@@ -457,6 +457,7 @@ GuessControlValues(void)
ControlFile.floatFormat = FLOATFORMAT_VALUE;
ControlFile.blcksz = BLCKSZ;
ControlFile.relseg_size = RELSEG_SIZE;
ControlFile.xlog_blcksz = XLOG_BLCKSZ;
ControlFile.xlog_seg_size = XLOG_SEG_SIZE;
ControlFile.nameDataLen = NAMEDATALEN;
ControlFile.indexMaxKeys = INDEX_MAX_KEYS;
......@@ -526,6 +527,8 @@ PrintControlValues(bool guessed)
/* we don't print floatFormat since can't say much useful about it */
printf(_("Database block size: %u\n"), ControlFile.blcksz);
printf(_("Blocks per segment of large relation: %u\n"), ControlFile.relseg_size);
printf(_("WAL block size: %u\n"), ControlFile.xlog_blcksz);
printf(_("Bytes per WAL segment: %u\n"), ControlFile.xlog_seg_size);
printf(_("Maximum length of identifiers: %u\n"), ControlFile.nameDataLen);
printf(_("Maximum columns in an index: %u\n"), ControlFile.indexMaxKeys);
printf(_("Date/time type storage: %s\n"),
......@@ -705,9 +708,9 @@ WriteEmptyXLOG(void)
int nbytes;
/* Use malloc() to ensure buffer is MAXALIGNED */
buffer = (char *) malloc(BLCKSZ);
buffer = (char *) malloc(XLOG_BLCKSZ);
page = (XLogPageHeader) buffer;
memset(buffer, 0, BLCKSZ);
memset(buffer, 0, XLOG_BLCKSZ);
/* Set up the XLOG page header */
page->xlp_magic = XLOG_PAGE_MAGIC;
......@@ -756,7 +759,7 @@ WriteEmptyXLOG(void)
}
errno = 0;
if (write(fd, buffer, BLCKSZ) != BLCKSZ)
if (write(fd, buffer, XLOG_BLCKSZ) != XLOG_BLCKSZ)
{
/* if write didn't set errno, assume problem is no disk space */
if (errno == 0)
......@@ -767,11 +770,11 @@ WriteEmptyXLOG(void)
}
/* Fill the rest of the file with zeroes */
memset(buffer, 0, BLCKSZ);
for (nbytes = BLCKSZ; nbytes < XLogSegSize; nbytes += BLCKSZ)
memset(buffer, 0, XLOG_BLCKSZ);
for (nbytes = XLOG_BLCKSZ; nbytes < XLogSegSize; nbytes += XLOG_BLCKSZ)
{
errno = 0;
if (write(fd, buffer, BLCKSZ) != BLCKSZ)
if (write(fd, buffer, XLOG_BLCKSZ) != XLOG_BLCKSZ)
{
if (errno == 0)
errno = ENOSPC;
......
......@@ -11,7 +11,7 @@
* Portions Copyright (c) 1996-2006, PostgreSQL Global Development Group
* Portions Copyright (c) 1994, Regents of the University of California
*
* $PostgreSQL: pgsql/src/include/access/xlog_internal.h,v 1.11 2006/03/24 04:32:13 tgl Exp $
* $PostgreSQL: pgsql/src/include/access/xlog_internal.h,v 1.12 2006/04/03 23:35:04 tgl Exp $
*/
#ifndef XLOG_INTERNAL_H
#define XLOG_INTERNAL_H
......@@ -182,8 +182,8 @@ typedef XLogLongPageHeaderData *XLogLongPageHeader;
/* Check if an xrecoff value is in a plausible range */
#define XRecOffIsValid(xrecoff) \
((xrecoff) % BLCKSZ >= SizeOfXLogShortPHD && \
(BLCKSZ - (xrecoff) % BLCKSZ) >= SizeOfXLogRecord)
((xrecoff) % XLOG_BLCKSZ >= SizeOfXLogShortPHD && \
(XLOG_BLCKSZ - (xrecoff) % XLOG_BLCKSZ) >= SizeOfXLogRecord)
/*
* The XLog directory and control file (relative to $PGDATA)
......
......@@ -8,7 +8,7 @@
* Portions Copyright (c) 1996-2006, PostgreSQL Global Development Group
* Portions Copyright (c) 1994, Regents of the University of California
*
* $PostgreSQL: pgsql/src/include/catalog/pg_control.h,v 1.27 2006/03/05 15:58:54 momjian Exp $
* $PostgreSQL: pgsql/src/include/catalog/pg_control.h,v 1.28 2006/04/03 23:35:05 tgl Exp $
*
*-------------------------------------------------------------------------
*/
......@@ -22,7 +22,7 @@
/* Version identifier for this pg_control format */
#define PG_CONTROL_VERSION 812
#define PG_CONTROL_VERSION 820
/*
* Body of CheckPoint XLOG records. This is declared here because we keep
......@@ -126,9 +126,10 @@ typedef struct ControlFileData
* This data is used to make sure that configuration of this database is
* compatible with the backend executable.
*/
uint32 blcksz; /* block size for this DB */
uint32 blcksz; /* data block size for this DB */
uint32 relseg_size; /* blocks per segment of large relation */
uint32 xlog_blcksz; /* block size within WAL files */
uint32 xlog_seg_size; /* size of each WAL segment */
uint32 nameDataLen; /* catalog name field width */
......
......@@ -6,7 +6,7 @@
* 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.20 2006/01/05 03:01:37 momjian Exp $
* $PostgreSQL: pgsql/src/include/pg_config_manual.h,v 1.21 2006/04/03 23:35:05 tgl Exp $
*------------------------------------------------------------------------
*/
......@@ -43,9 +43,20 @@
*/
#define RELSEG_SIZE (0x40000000 / 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.
*/
#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 BLCKSZ (preferably, a great deal larger than BLCKSZ).
* and larger than XLOG_BLCKSZ (preferably, a great deal larger than
* XLOG_BLCKSZ).
*
* Changing XLOG_SEG_SIZE requires an initdb.
*/
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment