Code changes to separate out the symbol for SLRU_BLCKSZ from standard BLCKSZ. Same reasons as for doing this for XLOG_BLCKSZ.
If no objections, I'll add this to pg_* binaries and the control file also. -- Simon Riggs EnterpriseDB http://www.enterprisedb.com
Index: src/backend/access/transam/clog.c =================================================================== RCS file: /projects/cvsroot/pgsql/src/backend/access/transam/clog.c,v retrieving revision 1.38 diff -c -r1.38 clog.c *** src/backend/access/transam/clog.c 24 Mar 2006 04:32:12 -0000 1.38 --- src/backend/access/transam/clog.c 17 May 2006 08:46:53 -0000 *************** *** 36,43 **** /* ! * Defines for CLOG page sizes. A page is the same BLCKSZ as is used ! * everywhere else in Postgres. * * Note: because TransactionIds are 32 bits and wrap around at 0xFFFFFFFF, * CLOG page numbering also wraps around at 0xFFFFFFFF/CLOG_XACTS_PER_PAGE, --- 36,42 ---- /* ! * Defines for CLOG page access * * Note: because TransactionIds are 32 bits and wrap around at 0xFFFFFFFF, * CLOG page numbering also wraps around at 0xFFFFFFFF/CLOG_XACTS_PER_PAGE, *************** *** 49,55 **** /* We need two bits per xact, so four xacts fit in a byte */ #define CLOG_BITS_PER_XACT 2 #define CLOG_XACTS_PER_BYTE 4 ! #define CLOG_XACTS_PER_PAGE (BLCKSZ * CLOG_XACTS_PER_BYTE) #define CLOG_XACT_BITMASK ((1 << CLOG_BITS_PER_XACT) - 1) #define TransactionIdToPage(xid) ((xid) / (TransactionId) CLOG_XACTS_PER_PAGE) --- 48,54 ---- /* We need two bits per xact, so four xacts fit in a byte */ #define CLOG_BITS_PER_XACT 2 #define CLOG_XACTS_PER_BYTE 4 ! #define CLOG_XACTS_PER_PAGE (SLRU_BLCKSZ * CLOG_XACTS_PER_BYTE) #define CLOG_XACT_BITMASK ((1 << CLOG_BITS_PER_XACT) - 1) #define TransactionIdToPage(xid) ((xid) / (TransactionId) CLOG_XACTS_PER_PAGE) *************** *** 245,251 **** /* Zero so-far-unused positions in the current byte */ *byteptr &= (1 << bshift) - 1; /* Zero the rest of the page */ ! MemSet(byteptr + 1, 0, BLCKSZ - byteno - 1); ClogCtl->shared->page_dirty[slotno] = true; } --- 244,250 ---- /* Zero so-far-unused positions in the current byte */ *byteptr &= (1 << bshift) - 1; /* Zero the rest of the page */ ! MemSet(byteptr + 1, 0, SLRU_BLCKSZ - byteno - 1); ClogCtl->shared->page_dirty[slotno] = true; } Index: src/backend/access/transam/multixact.c =================================================================== RCS file: /projects/cvsroot/pgsql/src/backend/access/transam/multixact.c,v retrieving revision 1.17 diff -c -r1.17 multixact.c *** src/backend/access/transam/multixact.c 24 Mar 2006 04:32:12 -0000 1.17 --- src/backend/access/transam/multixact.c 17 May 2006 08:46:58 -0000 *************** *** 59,66 **** /* ! * Defines for MultiXactOffset page sizes. A page is the same BLCKSZ as is ! * used everywhere else in Postgres. * * Note: because both MultiXactOffsets and TransactionIds are 32 bits and * wrap around at 0xFFFFFFFF, MultiXact page numbering also wraps around at --- 59,65 ---- /* ! * Defines for MULTIXACT page access * * Note: because both MultiXactOffsets and TransactionIds are 32 bits and * wrap around at 0xFFFFFFFF, MultiXact page numbering also wraps around at *************** *** 72,79 **** */ /* We need four bytes per offset and also four bytes per member */ ! #define MULTIXACT_OFFSETS_PER_PAGE (BLCKSZ / sizeof(MultiXactOffset)) ! #define MULTIXACT_MEMBERS_PER_PAGE (BLCKSZ / sizeof(TransactionId)) #define MultiXactIdToOffsetPage(xid) \ ((xid) / (MultiXactOffset) MULTIXACT_OFFSETS_PER_PAGE) --- 71,78 ---- */ /* We need four bytes per offset and also four bytes per member */ ! #define MULTIXACT_OFFSETS_PER_PAGE (SLRU_BLCKSZ / sizeof(MultiXactOffset)) ! #define MULTIXACT_MEMBERS_PER_PAGE (SLRU_BLCKSZ / sizeof(TransactionId)) #define MultiXactIdToOffsetPage(xid) \ ((xid) / (MultiXactOffset) MULTIXACT_OFFSETS_PER_PAGE) *************** *** 1406,1412 **** offptr = (MultiXactOffset *) MultiXactOffsetCtl->shared->page_buffer[slotno]; offptr += entryno; ! MemSet(offptr, 0, BLCKSZ - (entryno * sizeof(MultiXactOffset))); MultiXactOffsetCtl->shared->page_dirty[slotno] = true; } --- 1405,1411 ---- offptr = (MultiXactOffset *) MultiXactOffsetCtl->shared->page_buffer[slotno]; offptr += entryno; ! MemSet(offptr, 0, SLRU_BLCKSZ - (entryno * sizeof(MultiXactOffset))); MultiXactOffsetCtl->shared->page_dirty[slotno] = true; } *************** *** 1436,1442 **** xidptr = (TransactionId *) MultiXactMemberCtl->shared->page_buffer[slotno]; xidptr += entryno; ! MemSet(xidptr, 0, BLCKSZ - (entryno * sizeof(TransactionId))); MultiXactMemberCtl->shared->page_dirty[slotno] = true; } --- 1435,1441 ---- xidptr = (TransactionId *) MultiXactMemberCtl->shared->page_buffer[slotno]; xidptr += entryno; ! MemSet(xidptr, 0, SLRU_BLCKSZ - (entryno * sizeof(TransactionId))); MultiXactMemberCtl->shared->page_dirty[slotno] = true; } Index: src/backend/access/transam/slru.c =================================================================== RCS file: /projects/cvsroot/pgsql/src/backend/access/transam/slru.c,v retrieving revision 1.36 diff -c -r1.36 slru.c *** src/backend/access/transam/slru.c 5 Mar 2006 15:58:21 -0000 1.36 --- src/backend/access/transam/slru.c 17 May 2006 08:47:00 -0000 *************** *** 59,68 **** /* ! * Define segment size. A page is the same BLCKSZ as is used everywhere ! * else in Postgres. The segment size can be chosen somewhat arbitrarily; ! * we make it 32 pages by default, or 256Kb, i.e. 1M transactions for CLOG ! * or 64K transactions for SUBTRANS. * * Note: because TransactionIds are 32 bits and wrap around at 0xFFFFFFFF, * page numbering also wraps around at 0xFFFFFFFF/xxxx_XACTS_PER_PAGE (where --- 59,67 ---- /* ! * The segment size can be chosen somewhat arbitrarily; we we make it 32 pages ! * by default, or 256Kb, i.e. 1M transactions for CLOG or 64K transactions ! * for SUBTRANS. (see pg_config_manual.h for definition) * * Note: because TransactionIds are 32 bits and wrap around at 0xFFFFFFFF, * page numbering also wraps around at 0xFFFFFFFF/xxxx_XACTS_PER_PAGE (where *************** *** 75,81 **** * hex digits. This sets a lower bound on the segment size (64K transactions * for 32-bit TransactionIds). */ ! #define SLRU_PAGES_PER_SEGMENT 32 #define SlruFileName(ctl, path, seg) \ snprintf(path, MAXPGPATH, "%s/%04X", (ctl)->Dir, seg) --- 74,80 ---- * hex digits. This sets a lower bound on the segment size (64K transactions * for 32-bit TransactionIds). */ ! #define SLRU_PAGES_PER_SEGMENT ( SLRU_SEG_SIZE / SLRU_BLCKSZ ) #define SlruFileName(ctl, path, seg) \ snprintf(path, MAXPGPATH, "%s/%04X", (ctl)->Dir, seg) *************** *** 263,269 **** SlruRecentlyUsed(shared, slotno); /* Set the buffer to zeroes */ ! MemSet(shared->page_buffer[slotno], 0, BLCKSZ); /* Assume this page is now the latest active page */ shared->latest_page_number = pageno; --- 262,268 ---- SlruRecentlyUsed(shared, slotno); /* Set the buffer to zeroes */ ! MemSet(shared->page_buffer[slotno], 0, SLRU_BLCKSZ); /* Assume this page is now the latest active page */ shared->latest_page_number = pageno; *************** *** 539,545 **** SlruShared shared = ctl->shared; int segno = pageno / SLRU_PAGES_PER_SEGMENT; int rpageno = pageno % SLRU_PAGES_PER_SEGMENT; ! int offset = rpageno * BLCKSZ; char path[MAXPGPATH]; int fd; --- 538,544 ---- SlruShared shared = ctl->shared; int segno = pageno / SLRU_PAGES_PER_SEGMENT; int rpageno = pageno % SLRU_PAGES_PER_SEGMENT; ! int offset = rpageno * SLRU_BLCKSZ; char path[MAXPGPATH]; int fd; *************** *** 565,571 **** ereport(LOG, (errmsg("file \"%s\" doesn't exist, reading as zeroes", path))); ! MemSet(shared->page_buffer[slotno], 0, BLCKSZ); return true; } --- 564,570 ---- ereport(LOG, (errmsg("file \"%s\" doesn't exist, reading as zeroes", path))); ! MemSet(shared->page_buffer[slotno], 0, SLRU_BLCKSZ); return true; } *************** *** 578,584 **** } errno = 0; ! if (read(fd, shared->page_buffer[slotno], BLCKSZ) != BLCKSZ) { slru_errcause = SLRU_READ_FAILED; slru_errno = errno; --- 577,583 ---- } errno = 0; ! if (read(fd, shared->page_buffer[slotno], SLRU_BLCKSZ) != SLRU_BLCKSZ) { slru_errcause = SLRU_READ_FAILED; slru_errno = errno; *************** *** 616,622 **** SlruShared shared = ctl->shared; int segno = pageno / SLRU_PAGES_PER_SEGMENT; int rpageno = pageno % SLRU_PAGES_PER_SEGMENT; ! int offset = rpageno * BLCKSZ; char path[MAXPGPATH]; int fd = -1; --- 615,621 ---- SlruShared shared = ctl->shared; int segno = pageno / SLRU_PAGES_PER_SEGMENT; int rpageno = pageno % SLRU_PAGES_PER_SEGMENT; ! int offset = rpageno * SLRU_BLCKSZ; char path[MAXPGPATH]; int fd = -1; *************** *** 695,701 **** } errno = 0; ! if (write(fd, shared->page_buffer[slotno], BLCKSZ) != BLCKSZ) { /* if write didn't set errno, assume problem is no disk space */ if (errno == 0) --- 694,700 ---- } errno = 0; ! if (write(fd, shared->page_buffer[slotno], SLRU_BLCKSZ) != SLRU_BLCKSZ) { /* if write didn't set errno, assume problem is no disk space */ if (errno == 0) *************** *** 741,747 **** { int segno = pageno / SLRU_PAGES_PER_SEGMENT; int rpageno = pageno % SLRU_PAGES_PER_SEGMENT; ! int offset = rpageno * BLCKSZ; char path[MAXPGPATH]; SlruFileName(ctl, path, segno); --- 740,746 ---- { int segno = pageno / SLRU_PAGES_PER_SEGMENT; int rpageno = pageno % SLRU_PAGES_PER_SEGMENT; ! int offset = rpageno * SLRU_BLCKSZ; char path[MAXPGPATH]; SlruFileName(ctl, path, segno); Index: src/backend/access/transam/subtrans.c =================================================================== RCS file: /projects/cvsroot/pgsql/src/backend/access/transam/subtrans.c,v retrieving revision 1.16 diff -c -r1.16 subtrans.c *** src/backend/access/transam/subtrans.c 5 Mar 2006 15:58:22 -0000 1.16 --- src/backend/access/transam/subtrans.c 17 May 2006 08:47:00 -0000 *************** *** 34,41 **** /* ! * Defines for SubTrans page sizes. A page is the same BLCKSZ as is used ! * everywhere else in Postgres. * * Note: because TransactionIds are 32 bits and wrap around at 0xFFFFFFFF, * SubTrans page numbering also wraps around at --- 34,40 ---- /* ! * Defines for SUBTRANS page access * * Note: because TransactionIds are 32 bits and wrap around at 0xFFFFFFFF, * SubTrans page numbering also wraps around at *************** *** 46,52 **** */ /* We need four bytes per xact */ ! #define SUBTRANS_XACTS_PER_PAGE (BLCKSZ / sizeof(TransactionId)) #define TransactionIdToPage(xid) ((xid) / (TransactionId) SUBTRANS_XACTS_PER_PAGE) #define TransactionIdToEntry(xid) ((xid) % (TransactionId) SUBTRANS_XACTS_PER_PAGE) --- 45,51 ---- */ /* We need four bytes per xact */ ! #define SUBTRANS_XACTS_PER_PAGE (SLRU_BLCKSZ / sizeof(TransactionId)) #define TransactionIdToPage(xid) ((xid) / (TransactionId) SUBTRANS_XACTS_PER_PAGE) #define TransactionIdToEntry(xid) ((xid) % (TransactionId) SUBTRANS_XACTS_PER_PAGE) Index: src/include/pg_config_manual.h =================================================================== RCS file: /projects/cvsroot/pgsql/src/include/pg_config_manual.h,v retrieving revision 1.21 diff -c -r1.21 pg_config_manual.h *** src/include/pg_config_manual.h 3 Apr 2006 23:35:05 -0000 1.21 --- src/include/pg_config_manual.h 17 May 2006 08:47:02 -0000 *************** *** 63,68 **** --- 63,85 ---- #define XLOG_SEG_SIZE (16*1024*1024) /* + * Size of an SLRU segment file. This need have no particular relation to BLCKSZ. + * SLRU_BLCKSZ must be a power of 2 + * + * Changing SLRU_BLCKSZ requires an initdb. + */ + #define SLRU_BLCKSZ 8192 + + /* + * SLRU_SEG_SIZE is the size of a single SLRU segment file. This must be a power + * of 2 and larger than SLRU_BLCKSZ (preferably, a great deal larger than + * SLRU_BLCKSZ). + * + * Changing SLRU_SEG_SIZE requires an initdb. + */ + #define SLRU_SEG_SIZE (256*1024*1024) + + /* * Maximum number of arguments to a function. * * The minimum value is 8 (index creation uses 8-argument functions).
---------------------------(end of broadcast)--------------------------- TIP 9: In versions below 8.0, the planner will ignore your desire to choose an index scan if your joining column's datatypes do not match