Skip to content

Commit 5a90bc1

Browse files
committed
The attached patch contains a couple of fixes in the existing probes and
includes a few new ones. - Fixed compilation errors on OS X for probes that use typedefs - Fixed a number of probes to pass ForkNumber per the relation forks patch - The new probes are those that were taken out from the previous submitted patch and required simple fixes. Will submit the other probes that may require more discussion in a separate patch. Robert Lor
1 parent 5434e46 commit 5a90bc1

File tree

5 files changed

+79
-37
lines changed

5 files changed

+79
-37
lines changed

src/backend/access/transam/xlog.c

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
* Portions Copyright (c) 1996-2008, PostgreSQL Global Development Group
88
* Portions Copyright (c) 1994, Regents of the University of California
99
*
10-
* $PostgreSQL: pgsql/src/backend/access/transam/xlog.c,v 1.323 2008/12/03 08:20:11 heikki Exp $
10+
* $PostgreSQL: pgsql/src/backend/access/transam/xlog.c,v 1.324 2008/12/17 01:39:03 momjian Exp $
1111
*
1212
*-------------------------------------------------------------------------
1313
*/
@@ -48,6 +48,7 @@
4848
#include "utils/builtins.h"
4949
#include "utils/guc.h"
5050
#include "utils/ps_status.h"
51+
#include "pg_trace.h"
5152

5253

5354
/* File path names (all relative to $PGDATA) */
@@ -486,6 +487,8 @@ XLogInsert(RmgrId rmid, uint8 info, XLogRecData *rdata)
486487
if (info & XLR_INFO_MASK)
487488
elog(PANIC, "invalid xlog info mask %02X", info);
488489

490+
TRACE_POSTGRESQL_XLOG_INSERT(rmid, info);
491+
489492
/*
490493
* In bootstrap mode, we don't actually log anything but XLOG resources;
491494
* return a phony record pointer.
@@ -914,6 +917,8 @@ begin:;
914917
XLogwrtRqst FlushRqst;
915918
XLogRecPtr OldSegEnd;
916919

920+
TRACE_POSTGRESQL_XLOG_SWITCH();
921+
917922
LWLockAcquire(WALWriteLock, LW_EXCLUSIVE);
918923

919924
/*
@@ -1313,12 +1318,14 @@ AdvanceXLInsertBuffer(bool new_segment)
13131318
* Have to write buffers while holding insert lock. This is
13141319
* not good, so only write as much as we absolutely must.
13151320
*/
1321+
TRACE_POSTGRESQL_WAL_BUFFER_WRITE_START();
13161322
WriteRqst.Write = OldPageRqstPtr;
13171323
WriteRqst.Flush.xlogid = 0;
13181324
WriteRqst.Flush.xrecoff = 0;
13191325
XLogWrite(WriteRqst, false, false);
13201326
LWLockRelease(WALWriteLock);
13211327
Insert->LogwrtResult = LogwrtResult;
1328+
TRACE_POSTGRESQL_WAL_BUFFER_WRITE_DONE();
13221329
}
13231330
}
13241331
}
@@ -5904,6 +5911,8 @@ CreateCheckPoint(int flags)
59045911
if (log_checkpoints)
59055912
LogCheckpointStart(flags);
59065913

5914+
TRACE_POSTGRESQL_CHECKPOINT_START(flags);
5915+
59075916
/*
59085917
* Before flushing data, we must wait for any transactions that are
59095918
* currently in their commit critical sections. If an xact inserted its
@@ -6069,6 +6078,11 @@ CreateCheckPoint(int flags)
60696078
if (log_checkpoints)
60706079
LogCheckpointEnd();
60716080

6081+
TRACE_POSTGRESQL_CHECKPOINT_DONE(CheckpointStats.ckpt_bufs_written,
6082+
NBuffers, CheckpointStats.ckpt_segs_added,
6083+
CheckpointStats.ckpt_segs_removed,
6084+
CheckpointStats.ckpt_segs_recycled);
6085+
60726086
LWLockRelease(CheckpointLock);
60736087
}
60746088

src/backend/storage/buffer/bufmgr.c

Lines changed: 17 additions & 7 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.242 2008/11/19 10:34:52 heikki Exp $
11+
* $PostgreSQL: pgsql/src/backend/storage/buffer/bufmgr.c,v 1.243 2008/12/17 01:39:03 momjian Exp $
1212
*
1313
*-------------------------------------------------------------------------
1414
*/
@@ -203,8 +203,7 @@ ReadBuffer_common(SMgrRelation smgr, bool isLocalBuf, ForkNumber forkNum,
203203
if (isExtend)
204204
blockNum = smgrnblocks(smgr, forkNum);
205205

206-
TRACE_POSTGRESQL_BUFFER_READ_START(blockNum, smgr->smgr_rnode.spcNode,
207-
smgr->smgr_rnode.dbNode, smgr->smgr_rnode.relNode, isLocalBuf);
206+
TRACE_POSTGRESQL_BUFFER_READ_START(forkNum, blockNum, smgr->smgr_rnode.spcNode, smgr->smgr_rnode.dbNode, smgr->smgr_rnode.relNode, isLocalBuf);
208207

209208
if (isLocalBuf)
210209
{
@@ -253,7 +252,7 @@ ReadBuffer_common(SMgrRelation smgr, bool isLocalBuf, ForkNumber forkNum,
253252
if (VacuumCostActive)
254253
VacuumCostBalance += VacuumCostPageHit;
255254

256-
TRACE_POSTGRESQL_BUFFER_READ_DONE(blockNum,
255+
TRACE_POSTGRESQL_BUFFER_READ_DONE(forkNum, blockNum,
257256
smgr->smgr_rnode.spcNode,
258257
smgr->smgr_rnode.dbNode,
259258
smgr->smgr_rnode.relNode, isLocalBuf, found);
@@ -380,9 +379,9 @@ ReadBuffer_common(SMgrRelation smgr, bool isLocalBuf, ForkNumber forkNum,
380379
if (VacuumCostActive)
381380
VacuumCostBalance += VacuumCostPageMiss;
382381

383-
TRACE_POSTGRESQL_BUFFER_READ_DONE(blockNum, smgr->smgr_rnode.spcNode,
384-
smgr->smgr_rnode.dbNode, smgr->smgr_rnode.relNode,
385-
isLocalBuf, found);
382+
TRACE_POSTGRESQL_BUFFER_READ_DONE(forkNum, blockNum,
383+
smgr->smgr_rnode.spcNode, smgr->smgr_rnode.dbNode,
384+
smgr->smgr_rnode.relNode, isLocalBuf, found);
386385

387386
return BufferDescriptorGetBuffer(bufHdr);
388387
}
@@ -526,6 +525,11 @@ BufferAlloc(SMgrRelation smgr, ForkNumber forkNum,
526525
* happens to be trying to split the page the first one got from
527526
* StrategyGetBuffer.)
528527
*/
528+
529+
TRACE_POSTGRESQL_BUFFER_WRITE_DIRTY_START(forkNum,
530+
blockNum, smgr->smgr_rnode.spcNode,
531+
smgr->smgr_rnode.dbNode, smgr->smgr_rnode.relNode);
532+
529533
if (LWLockConditionalAcquire(buf->content_lock, LW_SHARED))
530534
{
531535
/*
@@ -548,6 +552,11 @@ BufferAlloc(SMgrRelation smgr, ForkNumber forkNum,
548552
/* OK, do the I/O */
549553
FlushBuffer(buf, NULL);
550554
LWLockRelease(buf->content_lock);
555+
556+
TRACE_POSTGRESQL_BUFFER_WRITE_DIRTY_DONE(
557+
forkNum, blockNum, smgr->smgr_rnode.spcNode,
558+
smgr->smgr_rnode.dbNode,
559+
smgr->smgr_rnode.relNode);
551560
}
552561
else
553562
{
@@ -1682,6 +1691,7 @@ CheckPointBuffers(int flags)
16821691
CheckpointStats.ckpt_write_t = GetCurrentTimestamp();
16831692
BufferSync(flags);
16841693
CheckpointStats.ckpt_sync_t = GetCurrentTimestamp();
1694+
TRACE_POSTGRESQL_BUFFER_CHECKPOINT_SYNC_START();
16851695
smgrsync();
16861696
CheckpointStats.ckpt_sync_end_t = GetCurrentTimestamp();
16871697
TRACE_POSTGRESQL_BUFFER_CHECKPOINT_DONE();

src/backend/storage/smgr/md.c

Lines changed: 16 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
*
99
*
1010
* IDENTIFICATION
11-
* $PostgreSQL: pgsql/src/backend/storage/smgr/md.c,v 1.141 2008/11/14 11:09:50 heikki Exp $
11+
* $PostgreSQL: pgsql/src/backend/storage/smgr/md.c,v 1.142 2008/12/17 01:39:04 momjian Exp $
1212
*
1313
*-------------------------------------------------------------------------
1414
*/
@@ -27,6 +27,7 @@
2727
#include "storage/smgr.h"
2828
#include "utils/hsearch.h"
2929
#include "utils/memutils.h"
30+
#include "pg_trace.h"
3031

3132

3233
/* interval for calling AbsorbFsyncRequests in mdsync */
@@ -560,6 +561,8 @@ mdread(SMgrRelation reln, ForkNumber forknum, BlockNumber blocknum,
560561
int nbytes;
561562
MdfdVec *v;
562563

564+
TRACE_POSTGRESQL_SMGR_MD_READ_START(forknum, blocknum, reln->smgr_rnode.spcNode, reln->smgr_rnode.dbNode, reln->smgr_rnode.relNode);
565+
563566
v = _mdfd_getseg(reln, forknum, blocknum, false, EXTENSION_FAIL);
564567

565568
seekpos = (off_t) BLCKSZ * (blocknum % ((BlockNumber) RELSEG_SIZE));
@@ -571,7 +574,11 @@ mdread(SMgrRelation reln, ForkNumber forknum, BlockNumber blocknum,
571574
errmsg("could not seek to block %u of relation %s: %m",
572575
blocknum, relpath(reln->smgr_rnode, forknum))));
573576

574-
if ((nbytes = FileRead(v->mdfd_vfd, buffer, BLCKSZ)) != BLCKSZ)
577+
nbytes = FileRead(v->mdfd_vfd, buffer, BLCKSZ);
578+
579+
TRACE_POSTGRESQL_SMGR_MD_READ_DONE(forknum, blocknum, reln->smgr_rnode.spcNode, reln->smgr_rnode.dbNode, reln->smgr_rnode.relNode, relpath(reln->smgr_rnode, forknum), nbytes, BLCKSZ);
580+
581+
if (nbytes != BLCKSZ)
575582
{
576583
if (nbytes < 0)
577584
ereport(ERROR,
@@ -618,6 +625,8 @@ mdwrite(SMgrRelation reln, ForkNumber forknum, BlockNumber blocknum,
618625
Assert(blocknum < mdnblocks(reln, forknum));
619626
#endif
620627

628+
TRACE_POSTGRESQL_SMGR_MD_WRITE_START(forknum, blocknum, reln->smgr_rnode.spcNode, reln->smgr_rnode.dbNode, reln->smgr_rnode.relNode);
629+
621630
v = _mdfd_getseg(reln, forknum, blocknum, isTemp, EXTENSION_FAIL);
622631

623632
seekpos = (off_t) BLCKSZ * (blocknum % ((BlockNumber) RELSEG_SIZE));
@@ -629,7 +638,11 @@ mdwrite(SMgrRelation reln, ForkNumber forknum, BlockNumber blocknum,
629638
errmsg("could not seek to block %u of relation %s: %m",
630639
blocknum, relpath(reln->smgr_rnode, forknum))));
631640

632-
if ((nbytes = FileWrite(v->mdfd_vfd, buffer, BLCKSZ)) != BLCKSZ)
641+
nbytes = FileWrite(v->mdfd_vfd, buffer, BLCKSZ);
642+
643+
TRACE_POSTGRESQL_SMGR_MD_WRITE_DONE(forknum, blocknum, reln->smgr_rnode.spcNode, reln->smgr_rnode.dbNode, reln->smgr_rnode.relNode, relpath(reln->smgr_rnode, forknum), nbytes, BLCKSZ);
644+
645+
if (nbytes != BLCKSZ)
633646
{
634647
if (nbytes < 0)
635648
ereport(ERROR,

src/backend/utils/Gen_dummy_probes.sed

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
#
44
# Copyright (c) 2008, PostgreSQL Global Development Group
55
#
6-
# $PostgreSQL: pgsql/src/backend/utils/Gen_dummy_probes.sed,v 1.2 2008/08/01 13:16:09 alvherre Exp $
6+
# $PostgreSQL: pgsql/src/backend/utils/Gen_dummy_probes.sed,v 1.3 2008/12/17 01:39:04 momjian Exp $
77
#-------------------------------------------------------------------------
88

99
/^[ ]*probe /!d
@@ -17,5 +17,7 @@ s/([^,)]\{1,\}, [^,)]\{1,\}, [^,)]\{1,\})/(INT1, INT2, INT3)/
1717
s/([^,)]\{1,\}, [^,)]\{1,\}, [^,)]\{1,\}, [^,)]\{1,\})/(INT1, INT2, INT3, INT4)/
1818
s/([^,)]\{1,\}, [^,)]\{1,\}, [^,)]\{1,\}, [^,)]\{1,\}, [^,)]\{1,\})/(INT1, INT2, INT3, INT4, INT5)/
1919
s/([^,)]\{1,\}, [^,)]\{1,\}, [^,)]\{1,\}, [^,)]\{1,\}, [^,)]\{1,\}, [^,)]\{1,\})/(INT1, INT2, INT3, INT4, INT5, INT6)/
20+
s/([^,)]\{1,\}, [^,)]\{1,\}, [^,)]\{1,\}, [^,)]\{1,\}, [^,)]\{1,\}, [^,)]\{1,\}, [^,)]\{1,\})/(INT1, INT2, INT3, INT4, INT5, INT6, INT7)/
21+
s/([^,)]\{1,\}, [^,)]\{1,\}, [^,)]\{1,\}, [^,)]\{1,\}, [^,)]\{1,\}, [^,)]\{1,\}, [^,)]\{1,\}, [^,)]\{1,\})/(INT1, INT2, INT3, INT4, INT5, INT6, INT7, INT8)/
2022
P
2123
s/(.*$/_ENABLED() (0)/

src/backend/utils/probes.d

Lines changed: 28 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -3,26 +3,25 @@
33
*
44
* Copyright (c) 2006-2008, PostgreSQL Global Development Group
55
*
6-
* $PostgreSQL: pgsql/src/backend/utils/probes.d,v 1.3 2008/08/01 13:16:09 alvherre Exp $
6+
* $PostgreSQL: pgsql/src/backend/utils/probes.d,v 1.4 2008/12/17 01:39:04 momjian Exp $
77
* ----------
88
*/
99

1010

1111
/* typedefs used in PostgreSQL */
12-
typedef unsigned int LocalTransactionId;
13-
typedef int LWLockId;
14-
typedef int LWLockMode;
15-
typedef int LOCKMODE;
16-
typedef unsigned int BlockNumber;
17-
typedef unsigned int Oid;
18-
12+
#define LocalTransactionId unsigned int
13+
#define LWLockId int
14+
#define LWLockMode int
15+
#define LOCKMODE int
16+
#define BlockNumber unsigned int
17+
#define Oid unsigned int
18+
#define ForkNumber int
1919
#define bool char
2020

2121
provider postgresql {
2222

2323
/*
24-
* Due to a bug in Mac OS X 10.5, using built-in typedefs (e.g. uintptr_t,
25-
* uint32_t, etc.) cause compilation errors.
24+
* Note: Do not use built-in typedefs (e.g. uintptr_t, uint32_t, etc) * as they cause compilation errors in Mac OS X 10.5.
2625
*/
2726

2827
probe transaction__start(LocalTransactionId);
@@ -36,13 +35,8 @@ provider postgresql {
3635
probe lwlock__condacquire(LWLockId, LWLockMode);
3736
probe lwlock__condacquire__fail(LWLockId, LWLockMode);
3837

39-
/* The following probe declarations cause compilation errors
40-
* on Mac OS X but not on Solaris. Need further investigation.
41-
* probe lock__wait__start(unsigned int, LOCKMODE);
42-
* probe lock__wait__done(unsigned int, LOCKMODE);
43-
*/
44-
probe lock__wait__start(unsigned int, int);
45-
probe lock__wait__done(unsigned int, int);
38+
probe lock__wait__start(unsigned int, LOCKMODE);
39+
probe lock__wait__done(unsigned int, LOCKMODE);
4640

4741
probe query__parse__start(const char *);
4842
probe query__parse__done(const char *);
@@ -59,27 +53,26 @@ provider postgresql {
5953
probe sort__start(int, bool, int, int, bool);
6054
probe sort__done(unsigned long, long);
6155

62-
/* The following probe declarations cause compilation errors
63-
* on Mac OS X but not on Solaris. Need further investigation.
64-
* probe buffer__read__start(BlockNumber, Oid, Oid, Oid, bool);
65-
* probe buffer__read__done(BlockNumber, Oid, Oid, Oid, bool, bool);
66-
*/
67-
probe buffer__read__start(unsigned int, unsigned int, unsigned int, unsigned int, bool);
68-
probe buffer__read__done(unsigned int, unsigned int, unsigned int, unsigned int, bool, bool);
69-
56+
probe buffer__read__start(ForkNumber, BlockNumber, Oid, Oid, Oid, bool);
57+
probe buffer__read__done(ForkNumber, BlockNumber, Oid, Oid, Oid, bool, bool);
7058
probe buffer__flush__start(Oid, Oid, Oid);
7159
probe buffer__flush__done(Oid, Oid, Oid);
7260

7361
probe buffer__hit(bool);
7462
probe buffer__miss(bool);
7563
probe buffer__checkpoint__start(int);
64+
probe buffer__checkpoint__sync__start();
7665
probe buffer__checkpoint__done();
7766
probe buffer__sync__start(int, int);
7867
probe buffer__sync__written(int);
7968
probe buffer__sync__done(int, int, int);
69+
probe buffer__write__dirty__start(ForkNumber, BlockNumber, Oid, Oid, Oid);
70+
probe buffer__write__dirty__done(ForkNumber, BlockNumber, Oid, Oid, Oid);
8071

8172
probe deadlock__found();
8273

74+
probe checkpoint__start(int);
75+
probe checkpoint__done(int, int, int, int, int);
8376
probe clog__checkpoint__start(bool);
8477
probe clog__checkpoint__done(bool);
8578
probe subtrans__checkpoint__start(bool);
@@ -88,4 +81,14 @@ provider postgresql {
8881
probe multixact__checkpoint__done(bool);
8982
probe twophase__checkpoint__start();
9083
probe twophase__checkpoint__done();
84+
85+
probe smgr__md__read__start(ForkNumber, BlockNumber, Oid, Oid, Oid);
86+
probe smgr__md__read__done(ForkNumber, BlockNumber, Oid, Oid, Oid, const char *, int, int);
87+
probe smgr__md__write__start(ForkNumber, BlockNumber, Oid, Oid, Oid);
88+
probe smgr__md__write__done(ForkNumber, BlockNumber, Oid, Oid, Oid, const char *, int, int);
89+
90+
probe xlog__insert(unsigned char, unsigned char);
91+
probe xlog__switch();
92+
probe wal__buffer__write__start();
93+
probe wal__buffer__write__done();
9194
};

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy