Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commite36e6b1

Browse files
committed
Add a few more DTrace probes to the backend.
Robert Lor
1 parent26e6991 commite36e6b1

File tree

16 files changed

+231
-41
lines changed

16 files changed

+231
-41
lines changed

‎src/backend/Makefile

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
# Portions Copyright (c) 1996-2008, PostgreSQL Global Development Group
66
# Portions Copyright (c) 1994, Regents of the University of California
77
#
8-
# $PostgreSQL: pgsql/src/backend/Makefile,v 1.128 2008/03/17 19:44:40 petere Exp $
8+
# $PostgreSQL: pgsql/src/backend/Makefile,v 1.129 2008/08/01 13:16:08 alvherre Exp $
99
#
1010
#-------------------------------------------------------------------------
1111

@@ -147,7 +147,7 @@ $(top_builddir)/src/include/utils/probes.h: utils/probes.h
147147

148148
ifeq ($(PORTNAME), solaris)
149149
utils/probes.o: utils/probes.d$(SUBDIROBJS)
150-
$(DTRACE)$(DTRACEFLAGS) -G -s$(call expand_subsys,$^) -o$@
150+
$(DTRACE)$(DTRACEFLAGS) -C -G -s$(call expand_subsys,$^) -o$@
151151
endif
152152

153153

‎src/backend/access/transam/clog.c

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@
2626
* Portions Copyright (c) 1996-2008, PostgreSQL Global Development Group
2727
* Portions Copyright (c) 1994, Regents of the University of California
2828
*
29-
* $PostgreSQL: pgsql/src/backend/access/transam/clog.c,v 1.46 2008/01/0119:45:46 momjian Exp $
29+
* $PostgreSQL: pgsql/src/backend/access/transam/clog.c,v 1.47 2008/08/0113:16:08 alvherre Exp $
3030
*
3131
*-------------------------------------------------------------------------
3232
*/
@@ -35,6 +35,7 @@
3535
#include"access/clog.h"
3636
#include"access/slru.h"
3737
#include"access/transam.h"
38+
#include"pg_trace.h"
3839
#include"postmaster/bgwriter.h"
3940

4041
/*
@@ -313,7 +314,9 @@ void
313314
ShutdownCLOG(void)
314315
{
315316
/* Flush dirty CLOG pages to disk */
317+
TRACE_POSTGRESQL_CLOG_CHECKPOINT_START(false);
316318
SimpleLruFlush(ClogCtl, false);
319+
TRACE_POSTGRESQL_CLOG_CHECKPOINT_DONE(false);
317320
}
318321

319322
/*
@@ -323,7 +326,9 @@ void
323326
CheckPointCLOG(void)
324327
{
325328
/* Flush dirty CLOG pages to disk */
329+
TRACE_POSTGRESQL_CLOG_CHECKPOINT_START(true);
326330
SimpleLruFlush(ClogCtl, true);
331+
TRACE_POSTGRESQL_CLOG_CHECKPOINT_DONE(true);
327332
}
328333

329334

‎src/backend/access/transam/multixact.c

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@
4242
* Portions Copyright (c) 1996-2008, PostgreSQL Global Development Group
4343
* Portions Copyright (c) 1994, Regents of the University of California
4444
*
45-
* $PostgreSQL: pgsql/src/backend/access/transam/multixact.c,v 1.27 2008/01/0119:45:46 momjian Exp $
45+
* $PostgreSQL: pgsql/src/backend/access/transam/multixact.c,v 1.28 2008/08/0113:16:08 alvherre Exp $
4646
*
4747
*-------------------------------------------------------------------------
4848
*/
@@ -53,10 +53,11 @@
5353
#include"access/transam.h"
5454
#include"access/xact.h"
5555
#include"miscadmin.h"
56+
#include"pg_trace.h"
5657
#include"storage/backendid.h"
5758
#include"storage/lmgr.h"
58-
#include"utils/memutils.h"
5959
#include"storage/procarray.h"
60+
#include"utils/memutils.h"
6061

6162

6263
/*
@@ -1497,8 +1498,10 @@ void
14971498
ShutdownMultiXact(void)
14981499
{
14991500
/* Flush dirty MultiXact pages to disk */
1501+
TRACE_POSTGRESQL_MULTIXACT_CHECKPOINT_START(false);
15001502
SimpleLruFlush(MultiXactOffsetCtl, false);
15011503
SimpleLruFlush(MultiXactMemberCtl, false);
1504+
TRACE_POSTGRESQL_MULTIXACT_CHECKPOINT_DONE(false);
15021505
}
15031506

15041507
/*
@@ -1526,6 +1529,8 @@ MultiXactGetCheckptMulti(bool is_shutdown,
15261529
void
15271530
CheckPointMultiXact(void)
15281531
{
1532+
TRACE_POSTGRESQL_MULTIXACT_CHECKPOINT_START(true);
1533+
15291534
/* Flush dirty MultiXact pages to disk */
15301535
SimpleLruFlush(MultiXactOffsetCtl, true);
15311536
SimpleLruFlush(MultiXactMemberCtl, true);
@@ -1540,6 +1545,8 @@ CheckPointMultiXact(void)
15401545
*/
15411546
if (!InRecovery)
15421547
TruncateMultiXact();
1548+
1549+
TRACE_POSTGRESQL_MULTIXACT_CHECKPOINT_DONE(true);
15431550
}
15441551

15451552
/*

‎src/backend/access/transam/subtrans.c

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@
2222
* Portions Copyright (c) 1996-2008, PostgreSQL Global Development Group
2323
* Portions Copyright (c) 1994, Regents of the University of California
2424
*
25-
* $PostgreSQL: pgsql/src/backend/access/transam/subtrans.c,v 1.22 2008/03/26 18:48:59 alvherre Exp $
25+
* $PostgreSQL: pgsql/src/backend/access/transam/subtrans.c,v 1.23 2008/08/01 13:16:08 alvherre Exp $
2626
*
2727
*-------------------------------------------------------------------------
2828
*/
@@ -31,6 +31,7 @@
3131
#include"access/slru.h"
3232
#include"access/subtrans.h"
3333
#include"access/transam.h"
34+
#include"pg_trace.h"
3435
#include"utils/snapmgr.h"
3536

3637

@@ -265,7 +266,9 @@ ShutdownSUBTRANS(void)
265266
* This is not actually necessary from a correctness point of view. We do
266267
* it merely as a debugging aid.
267268
*/
269+
TRACE_POSTGRESQL_SUBTRANS_CHECKPOINT_START(false);
268270
SimpleLruFlush(SubTransCtl, false);
271+
TRACE_POSTGRESQL_SUBTRANS_CHECKPOINT_DONE(false);
269272
}
270273

271274
/*
@@ -281,7 +284,9 @@ CheckPointSUBTRANS(void)
281284
* it merely to improve the odds that writing of dirty pages is done by
282285
* the checkpoint process and not by backends.
283286
*/
287+
TRACE_POSTGRESQL_SUBTRANS_CHECKPOINT_START(true);
284288
SimpleLruFlush(SubTransCtl, true);
289+
TRACE_POSTGRESQL_SUBTRANS_CHECKPOINT_DONE(true);
285290
}
286291

287292

‎src/backend/access/transam/twophase.c

Lines changed: 7 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/access/transam/twophase.c,v 1.43 2008/05/19 18:16:26 heikki Exp $
10+
*$PostgreSQL: pgsql/src/backend/access/transam/twophase.c,v 1.44 2008/08/01 13:16:08 alvherre Exp $
1111
*
1212
* NOTES
1313
*Each global transaction is associated with a global transaction
@@ -51,6 +51,7 @@
5151
#include"catalog/pg_type.h"
5252
#include"funcapi.h"
5353
#include"miscadmin.h"
54+
#include"pg_trace.h"
5455
#include"pgstat.h"
5556
#include"storage/fd.h"
5657
#include"storage/procarray.h"
@@ -1387,6 +1388,9 @@ CheckPointTwoPhase(XLogRecPtr redo_horizon)
13871388
*/
13881389
if (max_prepared_xacts <=0)
13891390
return;/* nothing to do */
1391+
1392+
TRACE_POSTGRESQL_TWOPHASE_CHECKPOINT_START();
1393+
13901394
xids= (TransactionId*)palloc(max_prepared_xacts*sizeof(TransactionId));
13911395
nxids=0;
13921396

@@ -1444,6 +1448,8 @@ CheckPointTwoPhase(XLogRecPtr redo_horizon)
14441448
}
14451449

14461450
pfree(xids);
1451+
1452+
TRACE_POSTGRESQL_TWOPHASE_CHECKPOINT_DONE();
14471453
}
14481454

14491455
/*

‎src/backend/postmaster/pgstat.c

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@
1313
*
1414
*Copyright (c) 2001-2008, PostgreSQL Global Development Group
1515
*
16-
*$PostgreSQL: pgsql/src/backend/postmaster/pgstat.c,v 1.176 2008/06/30 10:58:47 heikki Exp $
16+
*$PostgreSQL: pgsql/src/backend/postmaster/pgstat.c,v 1.177 2008/08/01 13:16:08 alvherre Exp $
1717
* ----------
1818
*/
1919
#include"postgres.h"
@@ -48,6 +48,7 @@
4848
#include"libpq/pqsignal.h"
4949
#include"mb/pg_wchar.h"
5050
#include"miscadmin.h"
51+
#include"pg_trace.h"
5152
#include"postmaster/autovacuum.h"
5253
#include"postmaster/fork_process.h"
5354
#include"postmaster/postmaster.h"
@@ -2202,6 +2203,8 @@ pgstat_report_activity(const char *cmd_str)
22022203
TimestampTzstart_timestamp;
22032204
intlen;
22042205

2206+
TRACE_POSTGRESQL_STATEMENT_STATUS(cmd_str);
2207+
22052208
if (!pgstat_track_activities|| !beentry)
22062209
return;
22072210

‎src/backend/storage/buffer/bufmgr.c

Lines changed: 43 additions & 2 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.234 2008/07/13 20:45:47 tgl Exp $
11+
* $PostgreSQL: pgsql/src/backend/storage/buffer/bufmgr.c,v 1.235 2008/08/01 13:16:08 alvherre Exp $
1212
*
1313
*-------------------------------------------------------------------------
1414
*/
@@ -34,6 +34,8 @@
3434
#include<unistd.h>
3535

3636
#include"miscadmin.h"
37+
#include"pg_trace.h"
38+
#include"pgstat.h"
3739
#include"postmaster/bgwriter.h"
3840
#include"storage/buf_internals.h"
3941
#include"storage/bufmgr.h"
@@ -42,7 +44,6 @@
4244
#include"storage/smgr.h"
4345
#include"utils/rel.h"
4446
#include"utils/resowner.h"
45-
#include"pgstat.h"
4647

4748

4849
/* Note: these two macros only work on shared buffers, not local ones! */
@@ -213,12 +214,22 @@ ReadBuffer_common(SMgrRelation smgr, bool isLocalBuf, BlockNumber blockNum,
213214
if (isExtend)
214215
blockNum=smgrnblocks(smgr);
215216

217+
TRACE_POSTGRESQL_BUFFER_READ_START(blockNum,smgr->smgr_rnode.spcNode,
218+
smgr->smgr_rnode.dbNode,smgr->smgr_rnode.relNode,isLocalBuf);
219+
216220
if (isLocalBuf)
217221
{
218222
ReadLocalBufferCount++;
219223
bufHdr=LocalBufferAlloc(smgr,blockNum,&found);
220224
if (found)
225+
{
221226
LocalBufferHitCount++;
227+
TRACE_POSTGRESQL_BUFFER_HIT(true);/* true == local buffer */
228+
}
229+
else
230+
{
231+
TRACE_POSTGRESQL_BUFFER_MISS(true);/* ditto */
232+
}
222233
}
223234
else
224235
{
@@ -230,7 +241,14 @@ ReadBuffer_common(SMgrRelation smgr, bool isLocalBuf, BlockNumber blockNum,
230241
*/
231242
bufHdr=BufferAlloc(smgr,blockNum,strategy,&found);
232243
if (found)
244+
{
233245
BufferHitCount++;
246+
TRACE_POSTGRESQL_BUFFER_HIT(false);/* false != local buffer */
247+
}
248+
else
249+
{
250+
TRACE_POSTGRESQL_BUFFER_MISS(false);/* ditto */
251+
}
234252
}
235253

236254
/* At this point we do NOT hold any locks. */
@@ -246,6 +264,11 @@ ReadBuffer_common(SMgrRelation smgr, bool isLocalBuf, BlockNumber blockNum,
246264
if (VacuumCostActive)
247265
VacuumCostBalance+=VacuumCostPageHit;
248266

267+
TRACE_POSTGRESQL_BUFFER_READ_DONE(blockNum,
268+
smgr->smgr_rnode.spcNode,
269+
smgr->smgr_rnode.dbNode,
270+
smgr->smgr_rnode.relNode,isLocalBuf,found);
271+
249272
returnBufferDescriptorGetBuffer(bufHdr);
250273
}
251274

@@ -368,6 +391,10 @@ ReadBuffer_common(SMgrRelation smgr, bool isLocalBuf, BlockNumber blockNum,
368391
if (VacuumCostActive)
369392
VacuumCostBalance+=VacuumCostPageMiss;
370393

394+
TRACE_POSTGRESQL_BUFFER_READ_DONE(blockNum,smgr->smgr_rnode.spcNode,
395+
smgr->smgr_rnode.dbNode,smgr->smgr_rnode.relNode,
396+
isLocalBuf,found);
397+
371398
returnBufferDescriptorGetBuffer(bufHdr);
372399
}
373400

@@ -1086,6 +1113,8 @@ BufferSync(int flags)
10861113
if (num_to_write==0)
10871114
return;/* nothing to do */
10881115

1116+
TRACE_POSTGRESQL_BUFFER_SYNC_START(NBuffers,num_to_write);
1117+
10891118
/*
10901119
* Loop over all buffers again, and write the ones (still) marked with
10911120
* BM_CHECKPOINT_NEEDED. In this loop, we start at the clock sweep point
@@ -1117,6 +1146,7 @@ BufferSync(int flags)
11171146
{
11181147
if (SyncOneBuffer(buf_id, false)&BUF_WRITTEN)
11191148
{
1149+
TRACE_POSTGRESQL_BUFFER_SYNC_WRITTEN(buf_id);
11201150
BgWriterStats.m_buf_written_checkpoints++;
11211151
num_written++;
11221152

@@ -1147,6 +1177,8 @@ BufferSync(int flags)
11471177
buf_id=0;
11481178
}
11491179

1180+
TRACE_POSTGRESQL_BUFFER_SYNC_DONE(NBuffers,num_written,num_to_write);
1181+
11501182
/*
11511183
* Update checkpoint statistics. As noted above, this doesn't include
11521184
* buffers written by other backends or bgwriter scan.
@@ -1653,11 +1685,13 @@ PrintBufferLeakWarning(Buffer buffer)
16531685
void
16541686
CheckPointBuffers(intflags)
16551687
{
1688+
TRACE_POSTGRESQL_BUFFER_CHECKPOINT_START(flags);
16561689
CheckpointStats.ckpt_write_t=GetCurrentTimestamp();
16571690
BufferSync(flags);
16581691
CheckpointStats.ckpt_sync_t=GetCurrentTimestamp();
16591692
smgrsync();
16601693
CheckpointStats.ckpt_sync_end_t=GetCurrentTimestamp();
1694+
TRACE_POSTGRESQL_BUFFER_CHECKPOINT_DONE();
16611695
}
16621696

16631697

@@ -1759,6 +1793,10 @@ FlushBuffer(volatile BufferDesc *buf, SMgrRelation reln)
17591793
if (reln==NULL)
17601794
reln=smgropen(buf->tag.rnode);
17611795

1796+
TRACE_POSTGRESQL_BUFFER_FLUSH_START(reln->smgr_rnode.spcNode,
1797+
reln->smgr_rnode.dbNode,
1798+
reln->smgr_rnode.relNode);
1799+
17621800
/*
17631801
* Force XLOG flush up to buffer's LSN. This implements the basic WAL
17641802
* rule that log updates must hit disk before any of the data-file changes
@@ -1785,6 +1823,9 @@ FlushBuffer(volatile BufferDesc *buf, SMgrRelation reln)
17851823

17861824
BufferFlushCount++;
17871825

1826+
TRACE_POSTGRESQL_BUFFER_FLUSH_DONE(reln->smgr_rnode.spcNode,
1827+
reln->smgr_rnode.dbNode,reln->smgr_rnode.relNode);
1828+
17881829
/*
17891830
* Mark the buffer as clean (unless BM_JUST_DIRTIED has become set) and
17901831
* end the io_in_progress state.

‎src/backend/storage/lmgr/deadlock.c

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212
*
1313
*
1414
* IDENTIFICATION
15-
* $PostgreSQL: pgsql/src/backend/storage/lmgr/deadlock.c,v 1.53 2008/03/24 18:22:36 tgl Exp $
15+
* $PostgreSQL: pgsql/src/backend/storage/lmgr/deadlock.c,v 1.54 2008/08/01 13:16:09 alvherre Exp $
1616
*
1717
*Interface:
1818
*
@@ -26,6 +26,7 @@
2626
#include"postgres.h"
2727

2828
#include"miscadmin.h"
29+
#include"pg_trace.h"
2930
#include"pgstat.h"
3031
#include"storage/lmgr.h"
3132
#include"storage/proc.h"
@@ -222,6 +223,8 @@ DeadLockCheck(PGPROC *proc)
222223
*/
223224
intnSoftEdges;
224225

226+
TRACE_POSTGRESQL_DEADLOCK_FOUND();
227+
225228
nWaitOrders=0;
226229
if (!FindLockCycle(proc,possibleConstraints,&nSoftEdges))
227230
elog(FATAL,"deadlock seems to have disappeared");

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp