Skip to content

Commit 227f817

Browse files
committed
Add support for additional DTrace probes.
Robert Lor
1 parent 3df4fa6 commit 227f817

File tree

15 files changed

+112
-15
lines changed

15 files changed

+112
-15
lines changed

src/backend/access/transam/slru.c

Lines changed: 31 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@
4141
* Portions Copyright (c) 1996-2009, PostgreSQL Global Development Group
4242
* Portions Copyright (c) 1994, Regents of the University of California
4343
*
44-
* $PostgreSQL: pgsql/src/backend/access/transam/slru.c,v 1.45 2009/01/01 17:23:36 momjian Exp $
44+
* $PostgreSQL: pgsql/src/backend/access/transam/slru.c,v 1.46 2009/04/02 19:14:33 momjian Exp $
4545
*
4646
*-------------------------------------------------------------------------
4747
*/
@@ -57,6 +57,7 @@
5757
#include "storage/fd.h"
5858
#include "storage/shmem.h"
5959
#include "miscadmin.h"
60+
#include "pg_trace.h"
6061

6162

6263
/*
@@ -372,6 +373,7 @@ SimpleLruReadPage(SlruCtl ctl, int pageno, bool write_ok,
372373
{
373374
SlruShared shared = ctl->shared;
374375

376+
TRACE_POSTGRESQL_SLRU_READPAGE_START((uintptr_t)ctl, pageno, write_ok, xid);
375377
/* Outer loop handles restart if we must wait for someone else's I/O */
376378
for (;;)
377379
{
@@ -399,6 +401,7 @@ SimpleLruReadPage(SlruCtl ctl, int pageno, bool write_ok,
399401
}
400402
/* Otherwise, it's ready to use */
401403
SlruRecentlyUsed(shared, slotno);
404+
TRACE_POSTGRESQL_SLRU_READPAGE_DONE(slotno);
402405
return slotno;
403406
}
404407

@@ -446,6 +449,7 @@ SimpleLruReadPage(SlruCtl ctl, int pageno, bool write_ok,
446449
SlruReportIOError(ctl, pageno, xid);
447450

448451
SlruRecentlyUsed(shared, slotno);
452+
TRACE_POSTGRESQL_SLRU_READPAGE_DONE(slotno);
449453
return slotno;
450454
}
451455
}
@@ -470,6 +474,8 @@ SimpleLruReadPage_ReadOnly(SlruCtl ctl, int pageno, TransactionId xid)
470474
SlruShared shared = ctl->shared;
471475
int slotno;
472476

477+
TRACE_POSTGRESQL_SLRU_READPAGE_READONLY((uintptr_t)ctl, pageno, xid);
478+
473479
/* Try to find the page while holding only shared lock */
474480
LWLockAcquire(shared->ControlLock, LW_SHARED);
475481

@@ -511,6 +517,8 @@ SimpleLruWritePage(SlruCtl ctl, int slotno, SlruFlush fdata)
511517
int pageno = shared->page_number[slotno];
512518
bool ok;
513519

520+
TRACE_POSTGRESQL_SLRU_WRITEPAGE_START((uintptr_t)ctl, pageno, slotno);
521+
514522
/* If a write is in progress, wait for it to finish */
515523
while (shared->page_status[slotno] == SLRU_PAGE_WRITE_IN_PROGRESS &&
516524
shared->page_number[slotno] == pageno)
@@ -525,7 +533,10 @@ SimpleLruWritePage(SlruCtl ctl, int slotno, SlruFlush fdata)
525533
if (!shared->page_dirty[slotno] ||
526534
shared->page_status[slotno] != SLRU_PAGE_VALID ||
527535
shared->page_number[slotno] != pageno)
536+
{
537+
TRACE_POSTGRESQL_SLRU_WRITEPAGE_DONE();
528538
return;
539+
}
529540

530541
/*
531542
* Mark the slot write-busy, and clear the dirtybit. After this point, a
@@ -569,6 +580,8 @@ SimpleLruWritePage(SlruCtl ctl, int slotno, SlruFlush fdata)
569580
/* Now it's okay to ereport if we failed */
570581
if (!ok)
571582
SlruReportIOError(ctl, pageno, InvalidTransactionId);
583+
584+
TRACE_POSTGRESQL_SLRU_WRITEPAGE_DONE();
572585
}
573586

574587
/*
@@ -593,6 +606,8 @@ SlruPhysicalReadPage(SlruCtl ctl, int pageno, int slotno)
593606

594607
SlruFileName(ctl, path, segno);
595608

609+
TRACE_POSTGRESQL_SLRU_READPAGE_PHYSICAL_START((uintptr_t)ctl, path, pageno, slotno);
610+
596611
/*
597612
* In a crash-and-restart situation, it's possible for us to receive
598613
* commands to set the commit status of transactions whose bits are in
@@ -607,13 +622,15 @@ SlruPhysicalReadPage(SlruCtl ctl, int pageno, int slotno)
607622
{
608623
slru_errcause = SLRU_OPEN_FAILED;
609624
slru_errno = errno;
625+
TRACE_POSTGRESQL_SLRU_READPAGE_PHYSICAL_DONE(false, slru_errcause, slru_errno);
610626
return false;
611627
}
612628

613629
ereport(LOG,
614630
(errmsg("file \"%s\" doesn't exist, reading as zeroes",
615631
path)));
616632
MemSet(shared->page_buffer[slotno], 0, BLCKSZ);
633+
TRACE_POSTGRESQL_SLRU_READPAGE_PHYSICAL_DONE(true, -1, -1);
617634
return true;
618635
}
619636

@@ -622,6 +639,7 @@ SlruPhysicalReadPage(SlruCtl ctl, int pageno, int slotno)
622639
slru_errcause = SLRU_SEEK_FAILED;
623640
slru_errno = errno;
624641
close(fd);
642+
TRACE_POSTGRESQL_SLRU_READPAGE_PHYSICAL_DONE(false, slru_errcause, slru_errno);
625643
return false;
626644
}
627645

@@ -631,16 +649,20 @@ SlruPhysicalReadPage(SlruCtl ctl, int pageno, int slotno)
631649
slru_errcause = SLRU_READ_FAILED;
632650
slru_errno = errno;
633651
close(fd);
652+
TRACE_POSTGRESQL_SLRU_READPAGE_PHYSICAL_DONE(false, slru_errcause, slru_errno);
634653
return false;
635654
}
636655

637656
if (close(fd))
638657
{
639658
slru_errcause = SLRU_CLOSE_FAILED;
640659
slru_errno = errno;
660+
TRACE_POSTGRESQL_SLRU_READPAGE_PHYSICAL_DONE(false, slru_errcause, slru_errno);
641661
return false;
642662
}
643663

664+
TRACE_POSTGRESQL_SLRU_READPAGE_PHYSICAL_DONE(true, -1, -1);
665+
644666
return true;
645667
}
646668

@@ -668,6 +690,8 @@ SlruPhysicalWritePage(SlruCtl ctl, int pageno, int slotno, SlruFlush fdata)
668690
char path[MAXPGPATH];
669691
int fd = -1;
670692

693+
TRACE_POSTGRESQL_SLRU_WRITEPAGE_PHYSICAL_START((uintptr_t)ctl, pageno, slotno);
694+
671695
/*
672696
* Honor the write-WAL-before-data rule, if appropriate, so that we do not
673697
* write out data before associated WAL records. This is the same action
@@ -753,6 +777,7 @@ SlruPhysicalWritePage(SlruCtl ctl, int pageno, int slotno, SlruFlush fdata)
753777
{
754778
slru_errcause = SLRU_OPEN_FAILED;
755779
slru_errno = errno;
780+
TRACE_POSTGRESQL_SLRU_WRITEPAGE_PHYSICAL_DONE(false, slru_errcause, slru_errno);
756781
return false;
757782
}
758783

@@ -781,6 +806,7 @@ SlruPhysicalWritePage(SlruCtl ctl, int pageno, int slotno, SlruFlush fdata)
781806
slru_errno = errno;
782807
if (!fdata)
783808
close(fd);
809+
TRACE_POSTGRESQL_SLRU_WRITEPAGE_PHYSICAL_DONE(false, slru_errcause, slru_errno);
784810
return false;
785811
}
786812

@@ -794,6 +820,7 @@ SlruPhysicalWritePage(SlruCtl ctl, int pageno, int slotno, SlruFlush fdata)
794820
slru_errno = errno;
795821
if (!fdata)
796822
close(fd);
823+
TRACE_POSTGRESQL_SLRU_WRITEPAGE_PHYSICAL_DONE(false, slru_errcause, slru_errno);
797824
return false;
798825
}
799826

@@ -808,17 +835,20 @@ SlruPhysicalWritePage(SlruCtl ctl, int pageno, int slotno, SlruFlush fdata)
808835
slru_errcause = SLRU_FSYNC_FAILED;
809836
slru_errno = errno;
810837
close(fd);
838+
TRACE_POSTGRESQL_SLRU_WRITEPAGE_PHYSICAL_DONE(false, slru_errcause, slru_errno);
811839
return false;
812840
}
813841

814842
if (close(fd))
815843
{
816844
slru_errcause = SLRU_CLOSE_FAILED;
817845
slru_errno = errno;
846+
TRACE_POSTGRESQL_SLRU_WRITEPAGE_PHYSICAL_DONE(false, slru_errcause, slru_errno);
818847
return false;
819848
}
820849
}
821850

851+
TRACE_POSTGRESQL_SLRU_WRITEPAGE_PHYSICAL_DONE(true, -1, -1);
822852
return true;
823853
}
824854

src/backend/executor/execScan.c

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,14 +12,15 @@
1212
*
1313
*
1414
* IDENTIFICATION
15-
* $PostgreSQL: pgsql/src/backend/executor/execScan.c,v 1.44 2009/01/01 17:23:41 momjian Exp $
15+
* $PostgreSQL: pgsql/src/backend/executor/execScan.c,v 1.45 2009/04/02 19:14:33 momjian Exp $
1616
*
1717
*-------------------------------------------------------------------------
1818
*/
1919
#include "postgres.h"
2020

2121
#include "executor/executor.h"
2222
#include "miscadmin.h"
23+
#include "pg_trace.h"
2324
#include "utils/memutils.h"
2425

2526

@@ -60,6 +61,8 @@ ExecScan(ScanState *node,
6061
qual = node->ps.qual;
6162
projInfo = node->ps.ps_ProjInfo;
6263

64+
TRACE_POSTGRESQL_EXECUTOR_SCAN((uintptr_t)node, ((Scan *)node->ps.plan)->scanrelid, (uintptr_t)accessMtd);
65+
6366
/*
6467
* If we have neither a qual to check nor a projection to do, just skip
6568
* all the overhead and return the raw scan tuple.

src/backend/executor/nodeAgg.c

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,7 @@
6161
* Portions Copyright (c) 1994, Regents of the University of California
6262
*
6363
* IDENTIFICATION
64-
* $PostgreSQL: pgsql/src/backend/executor/nodeAgg.c,v 1.164 2009/01/01 17:23:41 momjian Exp $
64+
* $PostgreSQL: pgsql/src/backend/executor/nodeAgg.c,v 1.165 2009/04/02 19:14:33 momjian Exp $
6565
*
6666
*-------------------------------------------------------------------------
6767
*/
@@ -79,6 +79,7 @@
7979
#include "parser/parse_agg.h"
8080
#include "parser/parse_coerce.h"
8181
#include "parser/parse_oper.h"
82+
#include "pg_trace.h"
8283
#include "utils/acl.h"
8384
#include "utils/builtins.h"
8485
#include "utils/lsyscache.h"
@@ -814,6 +815,8 @@ ExecAgg(AggState *node)
814815
if (node->agg_done)
815816
return NULL;
816817

818+
TRACE_POSTGRESQL_EXECUTOR_AGG((uintptr_t)node, ((Agg *) node->ss.ps.plan)->aggstrategy);
819+
817820
/*
818821
* Check to see if we're still projecting out tuples from a previous agg
819822
* tuple (because there is a function-returning-set in the projection

src/backend/executor/nodeGroup.c

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@
1515
* locate group boundaries.
1616
*
1717
* IDENTIFICATION
18-
* $PostgreSQL: pgsql/src/backend/executor/nodeGroup.c,v 1.73 2009/01/01 17:23:41 momjian Exp $
18+
* $PostgreSQL: pgsql/src/backend/executor/nodeGroup.c,v 1.74 2009/04/02 19:14:33 momjian Exp $
1919
*
2020
*-------------------------------------------------------------------------
2121
*/
@@ -24,6 +24,7 @@
2424

2525
#include "executor/executor.h"
2626
#include "executor/nodeGroup.h"
27+
#include "pg_trace.h"
2728

2829

2930
/*
@@ -49,6 +50,8 @@ ExecGroup(GroupState *node)
4950
numCols = ((Group *) node->ss.ps.plan)->numCols;
5051
grpColIdx = ((Group *) node->ss.ps.plan)->grpColIdx;
5152

53+
TRACE_POSTGRESQL_EXECUTOR_GROUP((uintptr_t)node, numCols);
54+
5255
/*
5356
* Check to see if we're still projecting out tuples from a previous group
5457
* tuple (because there is a function-returning-set in the projection

src/backend/executor/nodeHash.c

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
*
99
*
1010
* IDENTIFICATION
11-
* $PostgreSQL: pgsql/src/backend/executor/nodeHash.c,v 1.118 2009/03/21 00:04:38 tgl Exp $
11+
* $PostgreSQL: pgsql/src/backend/executor/nodeHash.c,v 1.119 2009/04/02 19:14:33 momjian Exp $
1212
*
1313
*-------------------------------------------------------------------------
1414
*/
@@ -33,6 +33,7 @@
3333
#include "executor/nodeHashjoin.h"
3434
#include "miscadmin.h"
3535
#include "parser/parse_expr.h"
36+
#include "pg_trace.h"
3637
#include "utils/dynahash.h"
3738
#include "utils/memutils.h"
3839
#include "utils/lsyscache.h"
@@ -79,6 +80,8 @@ MultiExecHash(HashState *node)
7980
ExprContext *econtext;
8081
uint32 hashvalue;
8182

83+
TRACE_POSTGRESQL_EXECUTOR_HASH_MULTI((uintptr_t)node);
84+
8285
/* must provide our own instrumentation support */
8386
if (node->ps.instrument)
8487
InstrStartNode(node->ps.instrument);

src/backend/executor/nodeHashjoin.c

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
*
99
*
1010
* IDENTIFICATION
11-
* $PostgreSQL: pgsql/src/backend/executor/nodeHashjoin.c,v 1.98 2009/03/21 00:04:38 tgl Exp $
11+
* $PostgreSQL: pgsql/src/backend/executor/nodeHashjoin.c,v 1.99 2009/04/02 19:14:33 momjian Exp $
1212
*
1313
*-------------------------------------------------------------------------
1414
*/
@@ -19,6 +19,7 @@
1919
#include "executor/hashjoin.h"
2020
#include "executor/nodeHash.h"
2121
#include "executor/nodeHashjoin.h"
22+
#include "pg_trace.h"
2223
#include "utils/memutils.h"
2324

2425

@@ -61,6 +62,8 @@ ExecHashJoin(HashJoinState *node)
6162
uint32 hashvalue;
6263
int batchno;
6364

65+
TRACE_POSTGRESQL_EXECUTOR_HASHJOIN((uintptr_t)node);
66+
6467
/*
6568
* get information from HashJoin node
6669
*/

src/backend/executor/nodeLimit.c

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
*
99
*
1010
* IDENTIFICATION
11-
* $PostgreSQL: pgsql/src/backend/executor/nodeLimit.c,v 1.36 2009/03/04 10:55:00 petere Exp $
11+
* $PostgreSQL: pgsql/src/backend/executor/nodeLimit.c,v 1.37 2009/04/02 19:14:33 momjian Exp $
1212
*
1313
*-------------------------------------------------------------------------
1414
*/
@@ -23,6 +23,7 @@
2323

2424
#include "executor/executor.h"
2525
#include "executor/nodeLimit.h"
26+
#include "pg_trace.h"
2627

2728
static void recompute_limits(LimitState *node);
2829

@@ -41,6 +42,8 @@ ExecLimit(LimitState *node)
4142
TupleTableSlot *slot;
4243
PlanState *outerPlan;
4344

45+
TRACE_POSTGRESQL_EXECUTOR_LIMIT((uintptr_t)node);
46+
4447
/*
4548
* get information from the node
4649
*/

src/backend/executor/nodeMaterial.c

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
*
99
*
1010
* IDENTIFICATION
11-
* $PostgreSQL: pgsql/src/backend/executor/nodeMaterial.c,v 1.66 2009/03/27 18:30:21 tgl Exp $
11+
* $PostgreSQL: pgsql/src/backend/executor/nodeMaterial.c,v 1.67 2009/04/02 19:14:33 momjian Exp $
1212
*
1313
*-------------------------------------------------------------------------
1414
*/
@@ -24,6 +24,7 @@
2424
#include "executor/executor.h"
2525
#include "executor/nodeMaterial.h"
2626
#include "miscadmin.h"
27+
#include "pg_trace.h"
2728

2829
/* ----------------------------------------------------------------
2930
* ExecMaterial
@@ -45,6 +46,8 @@ ExecMaterial(MaterialState *node)
4546
bool eof_tuplestore;
4647
TupleTableSlot *slot;
4748

49+
TRACE_POSTGRESQL_EXECUTOR_MATERIAL((uintptr_t)node);
50+
4851
/*
4952
* get state info from node
5053
*/

src/backend/executor/nodeMergejoin.c

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
*
99
*
1010
* IDENTIFICATION
11-
* $PostgreSQL: pgsql/src/backend/executor/nodeMergejoin.c,v 1.94 2009/01/01 17:23:42 momjian Exp $
11+
* $PostgreSQL: pgsql/src/backend/executor/nodeMergejoin.c,v 1.95 2009/04/02 19:14:33 momjian Exp $
1212
*
1313
*-------------------------------------------------------------------------
1414
*/
@@ -98,6 +98,7 @@
9898
#include "executor/execdefs.h"
9999
#include "executor/nodeMergejoin.h"
100100
#include "miscadmin.h"
101+
#include "pg_trace.h"
101102
#include "utils/acl.h"
102103
#include "utils/lsyscache.h"
103104
#include "utils/memutils.h"
@@ -565,6 +566,8 @@ ExecMergeJoin(MergeJoinState *node)
565566
bool doFillOuter;
566567
bool doFillInner;
567568

569+
TRACE_POSTGRESQL_EXECUTOR_MERGEJOIN((uintptr_t)node);
570+
568571
/*
569572
* get information from node
570573
*/

0 commit comments

Comments
 (0)