Location via proxy:   [ UP ]  
[Report a bug]   [Manage cookies]                
Skip to content

Commit 35c2a3c

Browse files
committed
Allow ShowBufferUsage() to report the number of reads/writes that have
occurred to temporary files. This replaces the unused NDirectFileRead/NDirectFileWrite counters. Itagaki Takahiro
1 parent 32f159c commit 35c2a3c

File tree

5 files changed

+17
-29
lines changed

5 files changed

+17
-29
lines changed

src/backend/storage/buffer/buf_init.c

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
*
99
*
1010
* IDENTIFICATION
11-
* $PostgreSQL: pgsql/src/backend/storage/buffer/buf_init.c,v 1.80 2008/01/01 19:45:51 momjian Exp $
11+
* $PostgreSQL: pgsql/src/backend/storage/buffer/buf_init.c,v 1.81 2008/09/17 13:15:55 tgl Exp $
1212
*
1313
*-------------------------------------------------------------------------
1414
*/
@@ -29,6 +29,8 @@ long int BufferHitCount;
2929
long int LocalBufferHitCount;
3030
long int BufferFlushCount;
3131
long int LocalBufferFlushCount;
32+
long int BufFileReadCount;
33+
long int BufFileWriteCount;
3234

3335

3436
/*

src/backend/storage/buffer/bufmgr.c

Lines changed: 4 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
*
99
*
1010
* IDENTIFICATION
11-
* $PostgreSQL: pgsql/src/backend/storage/buffer/bufmgr.c,v 1.237 2008/08/11 11:05:11 heikki Exp $
11+
* $PostgreSQL: pgsql/src/backend/storage/buffer/bufmgr.c,v 1.238 2008/09/17 13:15:55 tgl Exp $
1212
*
1313
*-------------------------------------------------------------------------
1414
*/
@@ -64,12 +64,6 @@ bool zero_damaged_pages = false;
6464
int bgwriter_lru_maxpages = 100;
6565
double bgwriter_lru_multiplier = 2.0;
6666

67-
68-
long NDirectFileRead; /* some I/O's are direct file access. bypass
69-
* bufmgr */
70-
long NDirectFileWrite; /* e.g., I/O in psort and hashjoin. */
71-
72-
7367
/* local state for StartBufferIO and related functions */
7468
static volatile BufferDesc *InProgressBuf = NULL;
7569
static bool IsForInput;
@@ -1572,7 +1566,7 @@ ShowBufferUsage(void)
15721566
ReadLocalBufferCount - LocalBufferHitCount, LocalBufferFlushCount, localhitrate);
15731567
appendStringInfo(&str,
15741568
"!\tDirect blocks: %10ld read, %10ld written\n",
1575-
NDirectFileRead, NDirectFileWrite);
1569+
BufFileReadCount, BufFileWriteCount);
15761570

15771571
return str.data;
15781572
}
@@ -1586,8 +1580,8 @@ ResetBufferUsage(void)
15861580
LocalBufferHitCount = 0;
15871581
ReadLocalBufferCount = 0;
15881582
LocalBufferFlushCount = 0;
1589-
NDirectFileRead = 0;
1590-
NDirectFileWrite = 0;
1583+
BufFileReadCount = 0;
1584+
BufFileWriteCount = 0;
15911585
}
15921586

15931587
/*

src/backend/storage/file/buffile.c

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
* Portions Copyright (c) 1994, Regents of the University of California
88
*
99
* IDENTIFICATION
10-
* $PostgreSQL: pgsql/src/backend/storage/file/buffile.c,v 1.31 2008/05/02 01:08:27 tgl Exp $
10+
* $PostgreSQL: pgsql/src/backend/storage/file/buffile.c,v 1.32 2008/09/17 13:15:55 tgl Exp $
1111
*
1212
* NOTES:
1313
*
@@ -36,6 +36,7 @@
3636

3737
#include "storage/fd.h"
3838
#include "storage/buffile.h"
39+
#include "storage/buf_internals.h"
3940

4041
/*
4142
* We break BufFiles into gigabyte-sized segments, regardless of RELSEG_SIZE.
@@ -238,6 +239,8 @@ BufFileLoadBuffer(BufFile *file)
238239
file->nbytes = 0;
239240
file->offsets[file->curFile] += file->nbytes;
240241
/* we choose not to advance curOffset here */
242+
243+
BufFileReadCount++;
241244
}
242245

243246
/*
@@ -300,6 +303,8 @@ BufFileDumpBuffer(BufFile *file)
300303
file->offsets[file->curFile] += bytestowrite;
301304
file->curOffset += bytestowrite;
302305
wpos += bytestowrite;
306+
307+
BufFileWriteCount++;
303308
}
304309
file->dirty = false;
305310

src/include/executor/execdebug.h

Lines changed: 1 addition & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010
* Portions Copyright (c) 1996-2008, PostgreSQL Global Development Group
1111
* Portions Copyright (c) 1994, Regents of the University of California
1212
*
13-
* $PostgreSQL: pgsql/src/include/executor/execdebug.h,v 1.32 2008/01/01 19:45:57 momjian Exp $
13+
* $PostgreSQL: pgsql/src/include/executor/execdebug.h,v 1.33 2008/09/17 13:15:55 tgl Exp $
1414
*
1515
*-------------------------------------------------------------------------
1616
*/
@@ -190,19 +190,4 @@ extern int NIndexTupleInserted;
190190
#define MJ_DEBUG_PROC_NODE(slot)
191191
#endif /* EXEC_MERGEJOINDEBUG */
192192

193-
/* ----------------------------------------------------------------
194-
* DO NOT DEFINE THESE EVER OR YOU WILL BURN!
195-
* ----------------------------------------------------------------
196-
*/
197-
/* ----------------
198-
* NOTYET is placed around any code not yet implemented
199-
* in the executor. Only remove these when actually implementing
200-
* said code.
201-
* ----------------
202-
*/
203-
#undef NOTYET
204-
205-
extern long NDirectFileRead;
206-
extern long NDirectFileWrite;
207-
208193
#endif /* ExecDebugIncluded */

src/include/storage/buf_internals.h

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
* Portions Copyright (c) 1996-2008, PostgreSQL Global Development Group
99
* Portions Copyright (c) 1994, Regents of the University of California
1010
*
11-
* $PostgreSQL: pgsql/src/include/storage/buf_internals.h,v 1.98 2008/08/11 11:05:11 heikki Exp $
11+
* $PostgreSQL: pgsql/src/include/storage/buf_internals.h,v 1.99 2008/09/17 13:15:55 tgl Exp $
1212
*
1313
*-------------------------------------------------------------------------
1414
*/
@@ -180,6 +180,8 @@ extern long int BufferHitCount;
180180
extern long int LocalBufferHitCount;
181181
extern long int BufferFlushCount;
182182
extern long int LocalBufferFlushCount;
183+
extern long int BufFileReadCount;
184+
extern long int BufFileWriteCount;
183185

184186

185187
/*

0 commit comments

Comments
 (0)