diff options
author | Tom Lane <tgl@sss.pgh.pa.us> | 2002-08-06 02:36:35 +0000 |
---|---|---|
committer | Tom Lane <tgl@sss.pgh.pa.us> | 2002-08-06 02:36:35 +0000 |
commit | 5df307c7782518c4a3c19ffd05c7cb591b97e23c (patch) | |
tree | 0ff988dc5b7b115e9f6bbf29852dd4bad7fcaeea /src/include | |
parent | 35cd432b185938c33967c9fa48223ce33e1c66bd (diff) | |
download | postgresql-5df307c7782518c4a3c19ffd05c7cb591b97e23c.tar.gz postgresql-5df307c7782518c4a3c19ffd05c7cb591b97e23c.zip |
Restructure local-buffer handling per recent pghackers discussion.
The local buffer manager is no longer used for newly-created relations
(unless they are TEMP); a new non-TEMP relation goes through the shared
bufmgr and thus will participate normally in checkpoints. But TEMP relations
use the local buffer manager throughout their lifespan. Also, operations
in TEMP relations are not logged in WAL, thus improving performance.
Since it's no longer necessary to fsync relations as they move out of the
local buffers into shared buffers, quite a lot of smgr.c/md.c/fd.c code
is no longer needed and has been removed: there's no concept of a dirty
relation anymore in md.c/fd.c, and we never fsync anything but WAL.
Still TODO: improve local buffer management algorithms so that it would
be reasonable to increase NLocBuffer.
Diffstat (limited to 'src/include')
-rw-r--r-- | src/include/access/xlog.h | 3 | ||||
-rw-r--r-- | src/include/storage/buf_internals.h | 15 | ||||
-rw-r--r-- | src/include/storage/bufmgr.h | 8 | ||||
-rw-r--r-- | src/include/storage/fd.h | 4 | ||||
-rw-r--r-- | src/include/storage/smgr.h | 23 | ||||
-rw-r--r-- | src/include/utils/rel.h | 6 | ||||
-rw-r--r-- | src/include/utils/relcache.h | 6 |
7 files changed, 26 insertions, 39 deletions
diff --git a/src/include/access/xlog.h b/src/include/access/xlog.h index 4b661f53d32..132fef26c88 100644 --- a/src/include/access/xlog.h +++ b/src/include/access/xlog.h @@ -6,7 +6,7 @@ * Portions Copyright (c) 1996-2002, PostgreSQL Global Development Group * Portions Copyright (c) 1994, Regents of the University of California * - * $Id: xlog.h,v 1.33 2002/08/05 01:24:16 thomas Exp $ + * $Id: xlog.h,v 1.34 2002/08/06 02:36:35 tgl Exp $ */ #ifndef XLOG_H #define XLOG_H @@ -182,6 +182,7 @@ extern StartUpID ThisStartUpID; /* current SUI */ extern bool InRecovery; extern XLogRecPtr MyLastRecPtr; extern bool MyXactMadeXLogEntry; +extern bool MyXactMadeTempRelUpdate; extern XLogRecPtr ProcLastRecEnd; /* these variables are GUC parameters related to XLOG */ diff --git a/src/include/storage/buf_internals.h b/src/include/storage/buf_internals.h index bd0907ed952..6f8c4ad841d 100644 --- a/src/include/storage/buf_internals.h +++ b/src/include/storage/buf_internals.h @@ -7,7 +7,7 @@ * Portions Copyright (c) 1996-2002, PostgreSQL Global Development Group * Portions Copyright (c) 1994, Regents of the University of California * - * $Id: buf_internals.h,v 1.57 2002/06/20 20:29:52 momjian Exp $ + * $Id: buf_internals.h,v 1.58 2002/08/06 02:36:35 tgl Exp $ * *------------------------------------------------------------------------- */ @@ -149,6 +149,15 @@ typedef struct _bmtrace #endif /* BMTRACE */ +/* counters in buf_init.c */ +extern long int ReadBufferCount; +extern long int ReadLocalBufferCount; +extern long int BufferHitCount; +extern long int LocalBufferHitCount; +extern long int BufferFlushCount; +extern long int LocalBufferFlushCount; + + /* * Bufmgr Interface: */ @@ -177,8 +186,6 @@ extern BufferDesc *LocalBufferDescriptors; extern BufferDesc *LocalBufferAlloc(Relation reln, BlockNumber blockNum, bool *foundPtr); extern void WriteLocalBuffer(Buffer buffer, bool release); -extern int FlushLocalBuffer(Buffer buffer, bool sync, bool release); -extern void LocalBufferSync(void); -extern void ResetLocalBufferPool(void); +extern void AtEOXact_LocalBuffers(bool isCommit); #endif /* BUFMGR_INTERNALS_H */ diff --git a/src/include/storage/bufmgr.h b/src/include/storage/bufmgr.h index a6952fa1f69..7aebaa73da6 100644 --- a/src/include/storage/bufmgr.h +++ b/src/include/storage/bufmgr.h @@ -7,7 +7,7 @@ * Portions Copyright (c) 1996-2002, PostgreSQL Global Development Group * Portions Copyright (c) 1994, Regents of the University of California * - * $Id: bufmgr.h,v 1.61 2002/07/02 05:47:37 momjian Exp $ + * $Id: bufmgr.h,v 1.62 2002/08/06 02:36:35 tgl Exp $ * *------------------------------------------------------------------------- */ @@ -152,20 +152,18 @@ extern void WriteBuffer(Buffer buffer); extern void WriteNoReleaseBuffer(Buffer buffer); extern Buffer ReleaseAndReadBuffer(Buffer buffer, Relation relation, BlockNumber blockNum); -extern int FlushBuffer(Buffer buffer, bool sync, bool release); extern void InitBufferPool(void); extern void InitBufferPoolAccess(void); extern char *ShowBufferUsage(void); extern void ResetBufferUsage(void); -extern void ResetBufferPool(bool isCommit); -extern bool BufferPoolCheckLeak(void); +extern void AtEOXact_Buffers(bool isCommit); extern void FlushBufferPool(void); extern BlockNumber BufferGetBlockNumber(Buffer buffer); extern BlockNumber RelationGetNumberOfBlocks(Relation relation); extern int FlushRelationBuffers(Relation rel, BlockNumber firstDelBlock); extern void DropRelationBuffers(Relation rel); -extern void DropRelFileNodeBuffers(RelFileNode rnode); +extern void DropRelFileNodeBuffers(RelFileNode rnode, bool istemp); extern void DropBuffers(Oid dbid); #ifdef NOT_USED extern void PrintPinnedBufs(void); diff --git a/src/include/storage/fd.h b/src/include/storage/fd.h index 13f5100c661..a13cec41ea6 100644 --- a/src/include/storage/fd.h +++ b/src/include/storage/fd.h @@ -7,7 +7,7 @@ * Portions Copyright (c) 1996-2002, PostgreSQL Global Development Group * Portions Copyright (c) 1994, Regents of the University of California * - * $Id: fd.h,v 1.35 2002/06/20 20:29:52 momjian Exp $ + * $Id: fd.h,v 1.36 2002/08/06 02:36:35 tgl Exp $ * *------------------------------------------------------------------------- */ @@ -62,8 +62,6 @@ extern int FileRead(File file, char *buffer, int amount); extern int FileWrite(File file, char *buffer, int amount); extern long FileSeek(File file, long offset, int whence); extern int FileTruncate(File file, long offset); -extern int FileSync(File file); -extern void FileMarkDirty(File file); /* Operations that allow use of regular stdio --- USE WITH CAUTION */ extern FILE *AllocateFile(char *name, char *mode); diff --git a/src/include/storage/smgr.h b/src/include/storage/smgr.h index 474bfbc9326..d5a96ea0c99 100644 --- a/src/include/storage/smgr.h +++ b/src/include/storage/smgr.h @@ -7,7 +7,7 @@ * Portions Copyright (c) 1996-2002, PostgreSQL Global Development Group * Portions Copyright (c) 1994, Regents of the University of California * - * $Id: smgr.h,v 1.35 2002/06/20 20:29:52 momjian Exp $ + * $Id: smgr.h,v 1.36 2002/08/06 02:36:35 tgl Exp $ * *------------------------------------------------------------------------- */ @@ -36,13 +36,8 @@ extern int smgrread(int16 which, Relation reln, BlockNumber blocknum, char *buffer); extern int smgrwrite(int16 which, Relation reln, BlockNumber blocknum, char *buffer); -extern int smgrflush(int16 which, Relation reln, BlockNumber blocknum, - char *buffer); extern int smgrblindwrt(int16 which, RelFileNode rnode, - BlockNumber blkno, char *buffer, bool dofsync); -extern int smgrblindmarkdirty(int16 which, RelFileNode rnode, - BlockNumber blkno); -extern int smgrmarkdirty(int16 which, Relation reln, BlockNumber blkno); + BlockNumber blkno, char *buffer); extern BlockNumber smgrnblocks(int16 which, Relation reln); extern BlockNumber smgrtruncate(int16 which, Relation reln, BlockNumber nblocks); @@ -67,11 +62,7 @@ extern int mdopen(Relation reln); extern int mdclose(Relation reln); extern int mdread(Relation reln, BlockNumber blocknum, char *buffer); extern int mdwrite(Relation reln, BlockNumber blocknum, char *buffer); -extern int mdflush(Relation reln, BlockNumber blocknum, char *buffer); -extern int mdmarkdirty(Relation reln, BlockNumber blkno); -extern int mdblindwrt(RelFileNode rnode, BlockNumber blkno, - char *buffer, bool dofsync); -extern int mdblindmarkdirty(RelFileNode rnode, BlockNumber blkno); +extern int mdblindwrt(RelFileNode rnode, BlockNumber blkno, char *buffer); extern BlockNumber mdnblocks(Relation reln); extern BlockNumber mdtruncate(Relation reln, BlockNumber nblocks); extern int mdcommit(void); @@ -87,13 +78,7 @@ extern int mmopen(Relation reln); extern int mmclose(Relation reln); extern int mmread(Relation reln, BlockNumber blocknum, char *buffer); extern int mmwrite(Relation reln, BlockNumber blocknum, char *buffer); -extern int mmflush(Relation reln, BlockNumber blocknum, char *buffer); -extern int mmblindwrt(char *dbname, char *relname, Oid dbid, Oid relid, - BlockNumber blkno, char *buffer, - bool dofsync); -extern int mmmarkdirty(Relation reln, BlockNumber blkno); -extern int mmblindmarkdirty(char *dbname, char *relname, Oid dbid, Oid relid, - BlockNumber blkno); +extern int mmblindwrt(RelFileNode rnode, BlockNumber blkno, char *buffer); extern BlockNumber mmnblocks(Relation reln); extern BlockNumber mmtruncate(Relation reln, BlockNumber nblocks); extern int mmcommit(void); diff --git a/src/include/utils/rel.h b/src/include/utils/rel.h index 3dce1757ed4..d913f28aba3 100644 --- a/src/include/utils/rel.h +++ b/src/include/utils/rel.h @@ -7,7 +7,7 @@ * Portions Copyright (c) 1996-2002, PostgreSQL Global Development Group * Portions Copyright (c) 1994, Regents of the University of California * - * $Id: rel.h,v 1.60 2002/06/20 20:29:53 momjian Exp $ + * $Id: rel.h,v 1.61 2002/08/06 02:36:35 tgl Exp $ * *------------------------------------------------------------------------- */ @@ -112,10 +112,10 @@ typedef struct RelationData BlockNumber rd_targblock; /* current insertion target block, or * InvalidBlockNumber */ int rd_refcnt; /* reference count */ - bool rd_myxactonly; /* rel uses the local buffer mgr */ + bool rd_isnew; /* rel was created in current xact */ + bool rd_istemp; /* rel uses the local buffer mgr */ bool rd_isnailed; /* rel is nailed in cache */ bool rd_indexfound; /* true if rd_indexlist is valid */ - bool rd_uniqueindex; /* true if rel is a UNIQUE index */ Form_pg_class rd_rel; /* RELATION tuple */ TupleDesc rd_att; /* tuple descriptor */ Oid rd_id; /* relation's object id */ diff --git a/src/include/utils/relcache.h b/src/include/utils/relcache.h index fd22a65296d..c0495284912 100644 --- a/src/include/utils/relcache.h +++ b/src/include/utils/relcache.h @@ -7,7 +7,7 @@ * Portions Copyright (c) 1996-2002, PostgreSQL Global Development Group * Portions Copyright (c) 1994, Regents of the University of California * - * $Id: relcache.h,v 1.33 2002/08/02 22:36:05 tgl Exp $ + * $Id: relcache.h,v 1.34 2002/08/06 02:36:35 tgl Exp $ * *------------------------------------------------------------------------- */ @@ -61,9 +61,7 @@ extern void RelationIdInvalidateRelationCacheByRelationId(Oid relationId); extern void RelationCacheInvalidate(void); -extern void RelationPurgeLocalRelation(bool xactComitted); - -extern void AtEOXactRelationCache(bool commit); +extern void AtEOXact_RelationCache(bool commit); /* * Routines to help manage rebuilding of relcache init file |