Commit 35c2a3c3 authored by Tom Lane's avatar Tom Lane

Allow ShowBufferUsage() to report the number of reads/writes that have

occurred to temporary files.  This replaces the unused
NDirectFileRead/NDirectFileWrite counters.

Itagaki Takahiro
parent 32f159cc
...@@ -8,7 +8,7 @@ ...@@ -8,7 +8,7 @@
* *
* *
* IDENTIFICATION * IDENTIFICATION
* $PostgreSQL: pgsql/src/backend/storage/buffer/buf_init.c,v 1.80 2008/01/01 19:45:51 momjian Exp $ * $PostgreSQL: pgsql/src/backend/storage/buffer/buf_init.c,v 1.81 2008/09/17 13:15:55 tgl Exp $
* *
*------------------------------------------------------------------------- *-------------------------------------------------------------------------
*/ */
...@@ -29,6 +29,8 @@ long int BufferHitCount; ...@@ -29,6 +29,8 @@ long int BufferHitCount;
long int LocalBufferHitCount; long int LocalBufferHitCount;
long int BufferFlushCount; long int BufferFlushCount;
long int LocalBufferFlushCount; long int LocalBufferFlushCount;
long int BufFileReadCount;
long int BufFileWriteCount;
/* /*
......
...@@ -8,7 +8,7 @@ ...@@ -8,7 +8,7 @@
* *
* *
* IDENTIFICATION * IDENTIFICATION
* $PostgreSQL: pgsql/src/backend/storage/buffer/bufmgr.c,v 1.237 2008/08/11 11:05:11 heikki Exp $ * $PostgreSQL: pgsql/src/backend/storage/buffer/bufmgr.c,v 1.238 2008/09/17 13:15:55 tgl Exp $
* *
*------------------------------------------------------------------------- *-------------------------------------------------------------------------
*/ */
...@@ -64,12 +64,6 @@ bool zero_damaged_pages = false; ...@@ -64,12 +64,6 @@ bool zero_damaged_pages = false;
int bgwriter_lru_maxpages = 100; int bgwriter_lru_maxpages = 100;
double bgwriter_lru_multiplier = 2.0; double bgwriter_lru_multiplier = 2.0;
long NDirectFileRead; /* some I/O's are direct file access. bypass
* bufmgr */
long NDirectFileWrite; /* e.g., I/O in psort and hashjoin. */
/* local state for StartBufferIO and related functions */ /* local state for StartBufferIO and related functions */
static volatile BufferDesc *InProgressBuf = NULL; static volatile BufferDesc *InProgressBuf = NULL;
static bool IsForInput; static bool IsForInput;
...@@ -1572,7 +1566,7 @@ ShowBufferUsage(void) ...@@ -1572,7 +1566,7 @@ ShowBufferUsage(void)
ReadLocalBufferCount - LocalBufferHitCount, LocalBufferFlushCount, localhitrate); ReadLocalBufferCount - LocalBufferHitCount, LocalBufferFlushCount, localhitrate);
appendStringInfo(&str, appendStringInfo(&str,
"!\tDirect blocks: %10ld read, %10ld written\n", "!\tDirect blocks: %10ld read, %10ld written\n",
NDirectFileRead, NDirectFileWrite); BufFileReadCount, BufFileWriteCount);
return str.data; return str.data;
} }
...@@ -1586,8 +1580,8 @@ ResetBufferUsage(void) ...@@ -1586,8 +1580,8 @@ ResetBufferUsage(void)
LocalBufferHitCount = 0; LocalBufferHitCount = 0;
ReadLocalBufferCount = 0; ReadLocalBufferCount = 0;
LocalBufferFlushCount = 0; LocalBufferFlushCount = 0;
NDirectFileRead = 0; BufFileReadCount = 0;
NDirectFileWrite = 0; BufFileWriteCount = 0;
} }
/* /*
......
...@@ -7,7 +7,7 @@ ...@@ -7,7 +7,7 @@
* Portions Copyright (c) 1994, Regents of the University of California * Portions Copyright (c) 1994, Regents of the University of California
* *
* IDENTIFICATION * IDENTIFICATION
* $PostgreSQL: pgsql/src/backend/storage/file/buffile.c,v 1.31 2008/05/02 01:08:27 tgl Exp $ * $PostgreSQL: pgsql/src/backend/storage/file/buffile.c,v 1.32 2008/09/17 13:15:55 tgl Exp $
* *
* NOTES: * NOTES:
* *
...@@ -36,6 +36,7 @@ ...@@ -36,6 +36,7 @@
#include "storage/fd.h" #include "storage/fd.h"
#include "storage/buffile.h" #include "storage/buffile.h"
#include "storage/buf_internals.h"
/* /*
* We break BufFiles into gigabyte-sized segments, regardless of RELSEG_SIZE. * We break BufFiles into gigabyte-sized segments, regardless of RELSEG_SIZE.
...@@ -238,6 +239,8 @@ BufFileLoadBuffer(BufFile *file) ...@@ -238,6 +239,8 @@ BufFileLoadBuffer(BufFile *file)
file->nbytes = 0; file->nbytes = 0;
file->offsets[file->curFile] += file->nbytes; file->offsets[file->curFile] += file->nbytes;
/* we choose not to advance curOffset here */ /* we choose not to advance curOffset here */
BufFileReadCount++;
} }
/* /*
...@@ -300,6 +303,8 @@ BufFileDumpBuffer(BufFile *file) ...@@ -300,6 +303,8 @@ BufFileDumpBuffer(BufFile *file)
file->offsets[file->curFile] += bytestowrite; file->offsets[file->curFile] += bytestowrite;
file->curOffset += bytestowrite; file->curOffset += bytestowrite;
wpos += bytestowrite; wpos += bytestowrite;
BufFileWriteCount++;
} }
file->dirty = false; file->dirty = false;
......
...@@ -10,7 +10,7 @@ ...@@ -10,7 +10,7 @@
* Portions Copyright (c) 1996-2008, PostgreSQL Global Development Group * Portions Copyright (c) 1996-2008, PostgreSQL Global Development Group
* Portions Copyright (c) 1994, Regents of the University of California * Portions Copyright (c) 1994, Regents of the University of California
* *
* $PostgreSQL: pgsql/src/include/executor/execdebug.h,v 1.32 2008/01/01 19:45:57 momjian Exp $ * $PostgreSQL: pgsql/src/include/executor/execdebug.h,v 1.33 2008/09/17 13:15:55 tgl Exp $
* *
*------------------------------------------------------------------------- *-------------------------------------------------------------------------
*/ */
...@@ -190,19 +190,4 @@ extern int NIndexTupleInserted; ...@@ -190,19 +190,4 @@ extern int NIndexTupleInserted;
#define MJ_DEBUG_PROC_NODE(slot) #define MJ_DEBUG_PROC_NODE(slot)
#endif /* EXEC_MERGEJOINDEBUG */ #endif /* EXEC_MERGEJOINDEBUG */
/* ----------------------------------------------------------------
* DO NOT DEFINE THESE EVER OR YOU WILL BURN!
* ----------------------------------------------------------------
*/
/* ----------------
* NOTYET is placed around any code not yet implemented
* in the executor. Only remove these when actually implementing
* said code.
* ----------------
*/
#undef NOTYET
extern long NDirectFileRead;
extern long NDirectFileWrite;
#endif /* ExecDebugIncluded */ #endif /* ExecDebugIncluded */
...@@ -8,7 +8,7 @@ ...@@ -8,7 +8,7 @@
* Portions Copyright (c) 1996-2008, PostgreSQL Global Development Group * Portions Copyright (c) 1996-2008, PostgreSQL Global Development Group
* Portions Copyright (c) 1994, Regents of the University of California * Portions Copyright (c) 1994, Regents of the University of California
* *
* $PostgreSQL: pgsql/src/include/storage/buf_internals.h,v 1.98 2008/08/11 11:05:11 heikki Exp $ * $PostgreSQL: pgsql/src/include/storage/buf_internals.h,v 1.99 2008/09/17 13:15:55 tgl Exp $
* *
*------------------------------------------------------------------------- *-------------------------------------------------------------------------
*/ */
...@@ -180,6 +180,8 @@ extern long int BufferHitCount; ...@@ -180,6 +180,8 @@ extern long int BufferHitCount;
extern long int LocalBufferHitCount; extern long int LocalBufferHitCount;
extern long int BufferFlushCount; extern long int BufferFlushCount;
extern long int LocalBufferFlushCount; extern long int LocalBufferFlushCount;
extern long int BufFileReadCount;
extern long int BufFileWriteCount;
/* /*
......
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