Here's what I have. Please confirm that this compiles for you.
--
Alvaro Herrera http://www.CommandPrompt.com/
PostgreSQL Replication, Consulting, Custom Development, 24x7 support
Index: src/backend/access/transam/clog.c
===================================================================
RCS file: /home/alvherre/Code/cvs/pgsql/src/backend/access/transam/clog.c,v
retrieving revision 1.46
diff -c -p -r1.46 clog.c
*** src/backend/access/transam/clog.c 1 Jan 2008 19:45:46 -0000 1.46
--- src/backend/access/transam/clog.c 31 Jul 2008 22:01:49 -0000
***************
*** 35,40 ****
--- 35,41 ----
#include "access/clog.h"
#include "access/slru.h"
#include "access/transam.h"
+ #include "pg_trace.h"
#include "postmaster/bgwriter.h"
/*
*************** void
*** 313,319 ****
--- 314,322 ----
ShutdownCLOG(void)
{
/* Flush dirty CLOG pages to disk */
+ TRACE_POSTGRESQL_CLOG_CHECKPOINT_START(false);
SimpleLruFlush(ClogCtl, false);
+ TRACE_POSTGRESQL_CLOG_CHECKPOINT_DONE(false);
}
/*
*************** void
*** 323,329 ****
--- 326,334 ----
CheckPointCLOG(void)
{
/* Flush dirty CLOG pages to disk */
+ TRACE_POSTGRESQL_CLOG_CHECKPOINT_START(true);
SimpleLruFlush(ClogCtl, true);
+ TRACE_POSTGRESQL_CLOG_CHECKPOINT_DONE(true);
}
Index: src/backend/access/transam/multixact.c
===================================================================
RCS file: /home/alvherre/Code/cvs/pgsql/src/backend/access/transam/multixact.c,v
retrieving revision 1.27
diff -c -p -r1.27 multixact.c
*** src/backend/access/transam/multixact.c 1 Jan 2008 19:45:46 -0000 1.27
--- src/backend/access/transam/multixact.c 31 Jul 2008 22:02:22 -0000
***************
*** 53,62 ****
#include "access/transam.h"
#include "access/xact.h"
#include "miscadmin.h"
#include "storage/backendid.h"
#include "storage/lmgr.h"
- #include "utils/memutils.h"
#include "storage/procarray.h"
/*
--- 53,63 ----
#include "access/transam.h"
#include "access/xact.h"
#include "miscadmin.h"
+ #include "pg_trace.h"
#include "storage/backendid.h"
#include "storage/lmgr.h"
#include "storage/procarray.h"
+ #include "utils/memutils.h"
/*
*************** void
*** 1497,1504 ****
--- 1498,1507 ----
ShutdownMultiXact(void)
{
/* Flush dirty MultiXact pages to disk */
+ TRACE_POSTGRESQL_MULTIXACT_CHECKPOINT_START(false);
SimpleLruFlush(MultiXactOffsetCtl, false);
SimpleLruFlush(MultiXactMemberCtl, false);
+ TRACE_POSTGRESQL_MULTIXACT_CHECKPOINT_DONE(false);
}
/*
*************** MultiXactGetCheckptMulti(bool is_shutdow
*** 1526,1531 ****
--- 1529,1536 ----
void
CheckPointMultiXact(void)
{
+ TRACE_POSTGRESQL_MULTIXACT_CHECKPOINT_START(true);
+
/* Flush dirty MultiXact pages to disk */
SimpleLruFlush(MultiXactOffsetCtl, true);
SimpleLruFlush(MultiXactMemberCtl, true);
*************** CheckPointMultiXact(void)
*** 1540,1545 ****
--- 1545,1552 ----
*/
if (!InRecovery)
TruncateMultiXact();
+
+ TRACE_POSTGRESQL_MULTIXACT_CHECKPOINT_DONE(true);
}
/*
Index: src/backend/access/transam/subtrans.c
===================================================================
RCS file: /home/alvherre/Code/cvs/pgsql/src/backend/access/transam/subtrans.c,v
retrieving revision 1.22
diff -c -p -r1.22 subtrans.c
*** src/backend/access/transam/subtrans.c 26 Mar 2008 18:48:59 -0000 1.22
--- src/backend/access/transam/subtrans.c 31 Jul 2008 22:02:34 -0000
***************
*** 31,36 ****
--- 31,37 ----
#include "access/slru.h"
#include "access/subtrans.h"
#include "access/transam.h"
+ #include "pg_trace.h"
#include "utils/snapmgr.h"
*************** ShutdownSUBTRANS(void)
*** 265,271 ****
--- 266,274 ----
* This is not actually necessary from a correctness point of view. We do
* it merely as a debugging aid.
*/
+ TRACE_POSTGRESQL_SUBTRANS_CHECKPOINT_START(false);
SimpleLruFlush(SubTransCtl, false);
+ TRACE_POSTGRESQL_SUBTRANS_CHECKPOINT_DONE(false);
}
/*
*************** CheckPointSUBTRANS(void)
*** 281,287 ****
--- 284,292 ----
* it merely to improve the odds that writing of dirty pages is done by
* the checkpoint process and not by backends.
*/
+ TRACE_POSTGRESQL_SUBTRANS_CHECKPOINT_START(true);
SimpleLruFlush(SubTransCtl, true);
+ TRACE_POSTGRESQL_SUBTRANS_CHECKPOINT_DONE(true);
}
Index: src/backend/access/transam/twophase.c
===================================================================
RCS file: /home/alvherre/Code/cvs/pgsql/src/backend/access/transam/twophase.c,v
retrieving revision 1.43
diff -c -p -r1.43 twophase.c
*** src/backend/access/transam/twophase.c 19 May 2008 18:16:26 -0000 1.43
--- src/backend/access/transam/twophase.c 31 Jul 2008 22:02:50 -0000
***************
*** 51,56 ****
--- 51,57 ----
#include "catalog/pg_type.h"
#include "funcapi.h"
#include "miscadmin.h"
+ #include "pg_trace.h"
#include "pgstat.h"
#include "storage/fd.h"
#include "storage/procarray.h"
*************** CheckPointTwoPhase(XLogRecPtr redo_horiz
*** 1387,1392 ****
--- 1388,1396 ----
*/
if (max_prepared_xacts <= 0)
return; /* nothing to do */
+
+ TRACE_POSTGRESQL_TWOPHASE_CHECKPOINT_START();
+
xids = (TransactionId *) palloc(max_prepared_xacts * sizeof(TransactionId));
nxids = 0;
*************** CheckPointTwoPhase(XLogRecPtr redo_horiz
*** 1444,1449 ****
--- 1448,1455 ----
}
pfree(xids);
+
+ TRACE_POSTGRESQL_TWOPHASE_CHECKPOINT_DONE();
}
/*
Index: src/backend/postmaster/pgstat.c
===================================================================
RCS file: /home/alvherre/Code/cvs/pgsql/src/backend/postmaster/pgstat.c,v
retrieving revision 1.176
diff -c -p -r1.176 pgstat.c
*** src/backend/postmaster/pgstat.c 30 Jun 2008 10:58:47 -0000 1.176
--- src/backend/postmaster/pgstat.c 31 Jul 2008 22:03:10 -0000
***************
*** 48,53 ****
--- 48,54 ----
#include "libpq/pqsignal.h"
#include "mb/pg_wchar.h"
#include "miscadmin.h"
+ #include "pg_trace.h"
#include "postmaster/autovacuum.h"
#include "postmaster/fork_process.h"
#include "postmaster/postmaster.h"
*************** pgstat_report_activity(const char *cmd_s
*** 2202,2207 ****
--- 2203,2210 ----
TimestampTz start_timestamp;
int len;
+ TRACE_POSTGRESQL_STATEMENT_STATUS(cmd_str);
+
if (!pgstat_track_activities || !beentry)
return;
Index: src/backend/storage/buffer/bufmgr.c
===================================================================
RCS file: /home/alvherre/Code/cvs/pgsql/src/backend/storage/buffer/bufmgr.c,v
retrieving revision 1.234
diff -c -p -r1.234 bufmgr.c
*** src/backend/storage/buffer/bufmgr.c 13 Jul 2008 20:45:47 -0000 1.234
--- src/backend/storage/buffer/bufmgr.c 31 Jul 2008 22:03:52 -0000
***************
*** 34,39 ****
--- 34,41 ----
#include <unistd.h>
#include "miscadmin.h"
+ #include "pg_trace.h"
+ #include "pgstat.h"
#include "postmaster/bgwriter.h"
#include "storage/buf_internals.h"
#include "storage/bufmgr.h"
***************
*** 42,48 ****
#include "storage/smgr.h"
#include "utils/rel.h"
#include "utils/resowner.h"
- #include "pgstat.h"
/* Note: these two macros only work on shared buffers, not local ones! */
--- 44,49 ----
*************** ReadBuffer_common(SMgrRelation smgr, boo
*** 213,224 ****
--- 214,235 ----
if (isExtend)
blockNum = smgrnblocks(smgr);
+ TRACE_POSTGRESQL_BUFFER_READ_START(blockNum, smgr->smgr_rnode.spcNode,
+ smgr->smgr_rnode.dbNode, smgr->smgr_rnode.relNode, isLocalBuf);
+
if (isLocalBuf)
{
ReadLocalBufferCount++;
bufHdr = LocalBufferAlloc(smgr, blockNum, &found);
if (found)
+ {
LocalBufferHitCount++;
+ TRACE_POSTGRESQL_BUFFER_HIT(true); /* true == local buffer */
+ }
+ else
+ {
+ TRACE_POSTGRESQL_BUFFER_MISS(true); /* ditto */
+ }
}
else
{
*************** ReadBuffer_common(SMgrRelation smgr, boo
*** 230,236 ****
--- 241,254 ----
*/
bufHdr = BufferAlloc(smgr, blockNum, strategy, &found);
if (found)
+ {
BufferHitCount++;
+ TRACE_POSTGRESQL_BUFFER_HIT(false); /* false != local buffer */
+ }
+ else
+ {
+ TRACE_POSTGRESQL_BUFFER_MISS(false); /* ditto */
+ }
}
/* At this point we do NOT hold any locks. */
*************** ReadBuffer_common(SMgrRelation smgr, boo
*** 246,251 ****
--- 264,274 ----
if (VacuumCostActive)
VacuumCostBalance += VacuumCostPageHit;
+ TRACE_POSTGRESQL_BUFFER_READ_DONE(blockNum,
+ smgr->smgr_rnode.spcNode,
+ smgr->smgr_rnode.dbNode,
+ smgr->smgr_rnode.relNode, isLocalBuf, found);
+
return BufferDescriptorGetBuffer(bufHdr);
}
*************** ReadBuffer_common(SMgrRelation smgr, boo
*** 368,373 ****
--- 391,400 ----
if (VacuumCostActive)
VacuumCostBalance += VacuumCostPageMiss;
+ TRACE_POSTGRESQL_BUFFER_READ_DONE(blockNum, smgr->smgr_rnode.spcNode,
+ smgr->smgr_rnode.dbNode, smgr->smgr_rnode.relNode,
+ isLocalBuf, found);
+
return BufferDescriptorGetBuffer(bufHdr);
}
*************** BufferSync(int flags)
*** 1086,1091 ****
--- 1113,1120 ----
if (num_to_write == 0)
return; /* nothing to do */
+ TRACE_POSTGRESQL_BUFFER_SYNC_START(NBuffers, num_to_write);
+
/*
* Loop over all buffers again, and write the ones (still) marked with
* BM_CHECKPOINT_NEEDED. In this loop, we start at the clock sweep point
*************** BufferSync(int flags)
*** 1117,1122 ****
--- 1146,1152 ----
{
if (SyncOneBuffer(buf_id, false) & BUF_WRITTEN)
{
+ TRACE_POSTGRESQL_BUFFER_SYNC_WRITTEN(buf_id);
BgWriterStats.m_buf_written_checkpoints++;
num_written++;
*************** BufferSync(int flags)
*** 1147,1152 ****
--- 1177,1184 ----
buf_id = 0;
}
+ TRACE_POSTGRESQL_BUFFER_SYNC_DONE(NBuffers, num_written, num_to_write);
+
/*
* Update checkpoint statistics. As noted above, this doesn't include
* buffers written by other backends or bgwriter scan.
*************** PrintBufferLeakWarning(Buffer buffer)
*** 1653,1663 ****
--- 1685,1697 ----
void
CheckPointBuffers(int flags)
{
+ TRACE_POSTGRESQL_BUFFER_CHECKPOINT_START(flags);
CheckpointStats.ckpt_write_t = GetCurrentTimestamp();
BufferSync(flags);
CheckpointStats.ckpt_sync_t = GetCurrentTimestamp();
smgrsync();
CheckpointStats.ckpt_sync_end_t = GetCurrentTimestamp();
+ TRACE_POSTGRESQL_BUFFER_CHECKPOINT_DONE();
}
*************** FlushBuffer(volatile BufferDesc *buf, SM
*** 1759,1764 ****
--- 1793,1802 ----
if (reln == NULL)
reln = smgropen(buf->tag.rnode);
+ TRACE_POSTGRESQL_BUFFER_FLUSH_START(reln->smgr_rnode.spcNode,
+ reln->smgr_rnode.dbNode,
+ reln->smgr_rnode.relNode);
+
/*
* Force XLOG flush up to buffer's LSN. This implements the basic WAL
* rule that log updates must hit disk before any of the data-file changes
*************** FlushBuffer(volatile BufferDesc *buf, SM
*** 1785,1790 ****
--- 1823,1831 ----
BufferFlushCount++;
+ TRACE_POSTGRESQL_BUFFER_FLUSH_DONE(reln->smgr_rnode.spcNode,
+ reln->smgr_rnode.dbNode, reln->smgr_rnode.relNode);
+
/*
* Mark the buffer as clean (unless BM_JUST_DIRTIED has become set) and
* end the io_in_progress state.
Index: src/backend/storage/lmgr/deadlock.c
===================================================================
RCS file: /home/alvherre/Code/cvs/pgsql/src/backend/storage/lmgr/deadlock.c,v
retrieving revision 1.53
diff -c -p -r1.53 deadlock.c
*** src/backend/storage/lmgr/deadlock.c 24 Mar 2008 18:22:36 -0000 1.53
--- src/backend/storage/lmgr/deadlock.c 31 Jul 2008 22:04:03 -0000
***************
*** 26,31 ****
--- 26,32 ----
#include "postgres.h"
#include "miscadmin.h"
+ #include "pg_trace.h"
#include "pgstat.h"
#include "storage/lmgr.h"
#include "storage/proc.h"
*************** DeadLockCheck(PGPROC *proc)
*** 222,227 ****
--- 223,230 ----
*/
int nSoftEdges;
+ TRACE_POSTGRESQL_DEADLOCK_FOUND();
+
nWaitOrders = 0;
if (!FindLockCycle(proc, possibleConstraints, &nSoftEdges))
elog(FATAL, "deadlock seems to have disappeared");
Index: src/backend/storage/lmgr/lock.c
===================================================================
RCS file: /home/alvherre/Code/cvs/pgsql/src/backend/storage/lmgr/lock.c,v
retrieving revision 1.183
diff -c -p -r1.183 lock.c
*** src/backend/storage/lmgr/lock.c 17 Mar 2008 19:44:41 -0000 1.183
--- src/backend/storage/lmgr/lock.c 31 Jul 2008 22:04:13 -0000
***************
*** 36,46 ****
#include "access/twophase.h"
#include "access/twophase_rmgr.h"
#include "miscadmin.h"
#include "pgstat.h"
#include "utils/memutils.h"
#include "utils/ps_status.h"
#include "utils/resowner.h"
- #include "pg_trace.h"
/* This configuration variable is used to set the lock table size */
--- 36,46 ----
#include "access/twophase.h"
#include "access/twophase_rmgr.h"
#include "miscadmin.h"
+ #include "pg_trace.h"
#include "pgstat.h"
#include "utils/memutils.h"
#include "utils/ps_status.h"
#include "utils/resowner.h"
/* This configuration variable is used to set the lock table size */
*************** LockAcquire(const LOCKTAG *locktag,
*** 787,797 ****
* Sleep till someone wakes me up.
*/
! TRACE_POSTGRESQL_LOCK_STARTWAIT(locktag->locktag_field2, lockmode);
WaitOnLock(locallock, owner);
! TRACE_POSTGRESQL_LOCK_ENDWAIT(locktag->locktag_field2, lockmode);
/*
* NOTE: do not do any material change of state between here and
--- 787,797 ----
* Sleep till someone wakes me up.
*/
! TRACE_POSTGRESQL_LOCK_WAIT_START(locktag->locktag_field2, lockmode);
WaitOnLock(locallock, owner);
! TRACE_POSTGRESQL_LOCK_WAIT_DONE(locktag->locktag_field2, lockmode);
/*
* NOTE: do not do any material change of state between here and
Index: src/backend/storage/lmgr/lwlock.c
===================================================================
RCS file: /home/alvherre/Code/cvs/pgsql/src/backend/storage/lmgr/lwlock.c,v
retrieving revision 1.51
diff -c -p -r1.51 lwlock.c
*** src/backend/storage/lmgr/lwlock.c 17 Mar 2008 19:44:41 -0000 1.51
--- src/backend/storage/lmgr/lwlock.c 31 Jul 2008 22:04:39 -0000
***************
*** 25,34 ****
#include "access/multixact.h"
#include "access/subtrans.h"
#include "miscadmin.h"
#include "storage/ipc.h"
#include "storage/proc.h"
#include "storage/spin.h"
- #include "pg_trace.h"
/* We use the ShmemLock spinlock to protect LWLockAssign */
--- 25,34 ----
#include "access/multixact.h"
#include "access/subtrans.h"
#include "miscadmin.h"
+ #include "pg_trace.h"
#include "storage/ipc.h"
#include "storage/proc.h"
#include "storage/spin.h"
/* We use the ShmemLock spinlock to protect LWLockAssign */
*************** LWLockAcquire(LWLockId lockid, LWLockMod
*** 448,454 ****
block_counts[lockid]++;
#endif
! TRACE_POSTGRESQL_LWLOCK_STARTWAIT(lockid, mode);
for (;;)
{
--- 448,454 ----
block_counts[lockid]++;
#endif
! TRACE_POSTGRESQL_LWLOCK_WAIT_START(lockid, mode);
for (;;)
{
*************** LWLockAcquire(LWLockId lockid, LWLockMod
*** 459,465 ****
extraWaits++;
}
! TRACE_POSTGRESQL_LWLOCK_ENDWAIT(lockid, mode);
LOG_LWDEBUG("LWLockAcquire", lockid, "awakened");
--- 459,465 ----
extraWaits++;
}
! TRACE_POSTGRESQL_LWLOCK_WAIT_DONE(lockid, mode);
LOG_LWDEBUG("LWLockAcquire", lockid, "awakened");
Index: src/backend/tcop/postgres.c
===================================================================
RCS file: /home/alvherre/Code/cvs/pgsql/src/backend/tcop/postgres.c,v
retrieving revision 1.554
diff -c -p -r1.554 postgres.c
*** src/backend/tcop/postgres.c 18 Jul 2008 20:26:06 -0000 1.554
--- src/backend/tcop/postgres.c 31 Jul 2008 22:05:14 -0000
***************
*** 50,55 ****
--- 50,57 ----
#include "miscadmin.h"
#include "nodes/print.h"
#include "optimizer/planner.h"
+ #include "pgstat.h"
+ #include "pg_trace.h"
#include "parser/analyze.h"
#include "parser/parser.h"
#include "postmaster/autovacuum.h"
***************
*** 70,76 ****
#include "utils/snapmgr.h"
#include "mb/pg_wchar.h"
- #include "pgstat.h"
extern int optind;
extern char *optarg;
--- 72,77 ----
*************** pg_parse_query(const char *query_string)
*** 551,556 ****
--- 552,559 ----
{
List *raw_parsetree_list;
+ TRACE_POSTGRESQL_QUERY_PARSE_START(query_string);
+
if (log_parser_stats)
ResetUsage();
*************** pg_parse_query(const char *query_string)
*** 572,577 ****
--- 575,582 ----
}
#endif
+ TRACE_POSTGRESQL_QUERY_PARSE_DONE(query_string);
+
return raw_parsetree_list;
}
*************** pg_analyze_and_rewrite(Node *parsetree,
*** 591,596 ****
--- 596,603 ----
Query *query;
List *querytree_list;
+ TRACE_POSTGRESQL_QUERY_REWRITE_START(query_string);
+
/*
* (1) Perform parse analysis.
*/
*************** pg_analyze_and_rewrite(Node *parsetree,
*** 607,612 ****
--- 614,621 ----
*/
querytree_list = pg_rewrite_query(query);
+ TRACE_POSTGRESQL_QUERY_REWRITE_DONE(query_string);
+
return querytree_list;
}
*************** pg_plan_query(Query *querytree, int curs
*** 677,682 ****
--- 686,693 ----
if (querytree->commandType == CMD_UTILITY)
return NULL;
+ TRACE_POSTGRESQL_QUERY_PLAN_START();
+
if (log_planner_stats)
ResetUsage();
*************** pg_plan_query(Query *querytree, int curs
*** 711,716 ****
--- 722,729 ----
if (Debug_print_plan)
elog_node_display(DEBUG1, "plan", plan, Debug_pretty_print);
+ TRACE_POSTGRESQL_QUERY_PLAN_DONE();
+
return plan;
}
*************** exec_simple_query(const char *query_stri
*** 785,790 ****
--- 798,804 ----
bool isTopLevel;
char msec_str[32];
+
/*
* Report query to various monitoring facilities.
*/
*************** exec_simple_query(const char *query_stri
*** 792,797 ****
--- 806,813 ----
pgstat_report_activity(query_string);
+ TRACE_POSTGRESQL_QUERY_START(query_string);
+
/*
* We use save_log_statement_stats so ShowUsage doesn't report incorrect
* results because ResetUsage wasn't called.
*************** exec_simple_query(const char *query_stri
*** 1058,1063 ****
--- 1074,1081 ----
if (save_log_statement_stats)
ShowUsage("QUERY STATISTICS");
+ TRACE_POSTGRESQL_QUERY_DONE(query_string);
+
debug_query_string = NULL;
}
Index: src/backend/tcop/pquery.c
===================================================================
RCS file: /home/alvherre/Code/cvs/pgsql/src/backend/tcop/pquery.c,v
retrieving revision 1.123
diff -c -p -r1.123 pquery.c
*** src/backend/tcop/pquery.c 12 May 2008 20:02:02 -0000 1.123
--- src/backend/tcop/pquery.c 31 Jul 2008 22:05:25 -0000
***************
*** 19,24 ****
--- 19,25 ----
#include "commands/prepare.h"
#include "commands/trigger.h"
#include "miscadmin.h"
+ #include "pg_trace.h"
#include "tcop/pquery.h"
#include "tcop/tcopprot.h"
#include "tcop/utility.h"
*************** PortalRun(Portal portal, long count, boo
*** 711,716 ****
--- 712,719 ----
AssertArg(PortalIsValid(portal));
+ TRACE_POSTGRESQL_QUERY_EXECUTE_START();
+
/* Initialize completion tag to empty string */
if (completionTag)
completionTag[0] = '\0';
*************** PortalRun(Portal portal, long count, boo
*** 857,862 ****
--- 860,867 ----
if (log_executor_stats && portal->strategy != PORTAL_MULTI_QUERY)
ShowUsage("EXECUTOR STATISTICS");
+
+ TRACE_POSTGRESQL_QUERY_EXECUTE_DONE();
return result;
}
*************** PortalRunMulti(Portal portal, bool isTop
*** 1237,1242 ****
--- 1242,1249 ----
*/
PlannedStmt *pstmt = (PlannedStmt *) stmt;
+ TRACE_POSTGRESQL_QUERY_EXECUTE_START();
+
if (log_executor_stats)
ResetUsage();
*************** PortalRunMulti(Portal portal, bool isTop
*** 1257,1262 ****
--- 1264,1271 ----
if (log_executor_stats)
ShowUsage("EXECUTOR STATISTICS");
+
+ TRACE_POSTGRESQL_QUERY_EXECUTE_DONE();
}
else
{
Index: src/backend/utils/Gen_dummy_probes.sed
===================================================================
RCS file: /home/alvherre/Code/cvs/pgsql/src/backend/utils/Gen_dummy_probes.sed,v
retrieving revision 1.1
diff -c -p -r1.1 Gen_dummy_probes.sed
*** src/backend/utils/Gen_dummy_probes.sed 17 Mar 2008 19:44:41 -0000 1.1
--- src/backend/utils/Gen_dummy_probes.sed 31 Jul 2008 20:50:35 -0000
***************
*** 6,16 ****
# $PostgreSQL: pgsql/src/backend/utils/Gen_dummy_probes.sed,v 1.1 2008-03-17 19:44:41 petere Exp $
#-------------------------------------------------------------------------
! /^probe /!d
! s/^probe \([^(]*\)\(.*\);/\1\2/
s/__/_/g
y/abcdefghijklmnopqrstuvwxyz/ABCDEFGHIJKLMNOPQRSTUVWXYZ/
s/^/#define TRACE_POSTGRESQL_/
! s/(INT, INT)/(INT1, INT2)/
P
s/(.*$/_ENABLED() (0)/
--- 6,21 ----
# $PostgreSQL: pgsql/src/backend/utils/Gen_dummy_probes.sed,v 1.1 2008-03-17 19:44:41 petere Exp $
#-------------------------------------------------------------------------
! /^[ ]*probe /!d
! s/^[ ]*probe \([^(]*\)\(.*\);/\1\2/
s/__/_/g
y/abcdefghijklmnopqrstuvwxyz/ABCDEFGHIJKLMNOPQRSTUVWXYZ/
s/^/#define TRACE_POSTGRESQL_/
! s/([^,)]\+)/(INT1)/
! s/([^,)]\+, [^,)]\+)/(INT1, INT2)/
! s/([^,)]\+, [^,)]\+, [^,)]\+)/(INT1, INT2, INT3)/
! s/([^,)]\+, [^,)]\+, [^,)]\+, [^,)]\+)/(INT1, INT2, INT3, INT4)/
! s/([^,)]\+, [^,)]\+, [^,)]\+, [^,)]\+, [^,)]\+)/(INT1, INT2, INT3, INT4, INT5)/
! s/([^,)]\+, [^,)]\+, [^,)]\+, [^,)]\+, [^,)]\+, [^,)]\+)/(INT1, INT2, INT3, INT4, INT5, INT6)/
P
s/(.*$/_ENABLED() (0)/
Index: src/backend/utils/Makefile
===================================================================
RCS file: /home/alvherre/Code/cvs/pgsql/src/backend/utils/Makefile,v
retrieving revision 1.27
diff -c -p -r1.27 Makefile
*** src/backend/utils/Makefile 17 Mar 2008 19:44:41 -0000 1.27
--- src/backend/utils/Makefile 31 Jul 2008 20:50:35 -0000
*************** $(SUBDIRS:%=%-recursive): fmgroids.h
*** 20,28 ****
fmgroids.h fmgrtab.c: Gen_fmgrtab.sh $(top_srcdir)/src/include/catalog/pg_proc.h
AWK='$(AWK)' $(SHELL) $< $(top_srcdir)/src/include/catalog/pg_proc.h
probes.h: probes.d
ifeq ($(enable_dtrace), yes)
! $(DTRACE) -h -s $< -o [EMAIL PROTECTED]
sed -e 's/POSTGRESQL_/TRACE_POSTGRESQL_/g' [EMAIL PROTECTED] >$@
rm [EMAIL PROTECTED]
else
--- 20,32 ----
fmgroids.h fmgrtab.c: Gen_fmgrtab.sh $(top_srcdir)/src/include/catalog/pg_proc.h
AWK='$(AWK)' $(SHELL) $< $(top_srcdir)/src/include/catalog/pg_proc.h
+ ifneq ($(enable_dtrace), yes)
+ probes.h: Gen_dummy_probes.sed
+ endif
+
probes.h: probes.d
ifeq ($(enable_dtrace), yes)
! $(DTRACE) -C -h -s $< -o [EMAIL PROTECTED]
sed -e 's/POSTGRESQL_/TRACE_POSTGRESQL_/g' [EMAIL PROTECTED] >$@
rm [EMAIL PROTECTED]
else
Index: src/backend/utils/probes.d
===================================================================
RCS file: /home/alvherre/Code/cvs/pgsql/src/backend/utils/probes.d,v
retrieving revision 1.2
diff -c -p -r1.2 probes.d
*** src/backend/utils/probes.d 2 Jan 2008 02:42:06 -0000 1.2
--- src/backend/utils/probes.d 31 Jul 2008 22:16:26 -0000
***************
*** 7,24 ****
* ----------
*/
provider postgresql {
! probe transaction__start(int);
! probe transaction__commit(int);
! probe transaction__abort(int);
! probe lwlock__acquire(int, int);
! probe lwlock__release(int);
! probe lwlock__startwait(int, int);
! probe lwlock__endwait(int, int);
! probe lwlock__condacquire(int, int);
! probe lwlock__condacquire__fail(int, int);
! probe lock__startwait(int, int);
! probe lock__endwait(int, int);
};
--- 7,91 ----
* ----------
*/
+
+ /* typedefs used in PostgreSQL */
+ typedef unsigned int LocalTransactionId;
+ typedef int LWLockId;
+ typedef int LWLockMode;
+ typedef int LOCKMODE;
+ typedef unsigned int BlockNumber;
+ typedef unsigned int Oid;
+
+ #define bool char
+
provider postgresql {
! /*
! * Due to a bug in Mac OS X 10.5, using built-in typedefs (e.g. uintptr_t,
! * uint32_t, etc.) cause compilation errors.
! */
!
! probe transaction__start(LocalTransactionId);
! probe transaction__commit(LocalTransactionId);
! probe transaction__abort(LocalTransactionId);
!
! probe lwlock__acquire(LWLockId, LWLockMode);
! probe lwlock__release(LWLockId);
! probe lwlock__wait__start(LWLockId, LWLockMode);
! probe lwlock__wait__done(LWLockId, LWLockMode);
! probe lwlock__condacquire(LWLockId, LWLockMode);
! probe lwlock__condacquire__fail(LWLockId, LWLockMode);
!
! /* The following probe declarations cause compilation errors
! * on Mac OS X but not on Solaris. Need further investigation.
! * probe lock__wait__start(unsigned int locktag_field2, LOCKMODE);
! * probe lock__wait__done(unsigned int locktag_field2, LOCKMODE);
! */
! probe lock__wait__start(unsigned int, int);
! probe lock__wait__done(unsigned int, int);
!
! probe query__parse__start(string);
! probe query__parse__done(string);
! probe query__rewrite__start(string);
! probe query__rewrite__done(string);
! probe query__plan__start();
! probe query__plan__done();
! probe query__execute__start();
! probe query__execute__done();
! probe query__start(string);
! probe query__done(string);
! probe statement__status(string);
!
! probe sort__start(int, bool, int, int, bool);
! probe sort__done(unsigned long, long);
!
! /* The following probe declarations cause compilation errors
! * on Mac OS X but not on Solaris. Need further investigation.
! * probe buffer__read__start(BlockNumber, Oid, Oid, Oid, bool isLocalBuf);
! * probe buffer__read__done(BlockNumber, Oid, Oid, Oid, bool isLocalBuf, bool found);
! */
! probe buffer__read__start(unsigned int, unsigned int, unsigned int, unsigned int, bool);
! probe buffer__read__done(unsigned int, unsigned int, unsigned int, unsigned int, bool, bool);
!
! probe buffer__flush__start(Oid, Oid, Oid);
! probe buffer__flush__done(Oid, Oid, Oid);
!
! probe buffer__hit(bool);
! probe buffer__miss(bool);
! probe buffer__checkpoint__start(int);
! probe buffer__checkpoint__done();
! probe buffer__sync__start(int, int);
! probe buffer__sync__written(int);
! probe buffer__sync__done(int, int, int);
!
! probe deadlock__found();
+ probe clog__checkpoint__start(bool);
+ probe clog__checkpoint__done(bool);
+ probe subtrans__checkpoint__start(bool);
+ probe subtrans__checkpoint__done(bool);
+ probe multixact__checkpoint__start(bool);
+ probe multixact__checkpoint__done(bool);
+ probe twophase__checkpoint__start();
+ probe twophase__checkpoint__done();
};
Index: src/backend/utils/sort/tuplesort.c
===================================================================
RCS file: /home/alvherre/Code/cvs/pgsql/src/backend/utils/sort/tuplesort.c,v
retrieving revision 1.85
diff -c -p -r1.85 tuplesort.c
*** src/backend/utils/sort/tuplesort.c 19 Jun 2008 00:46:05 -0000 1.85
--- src/backend/utils/sort/tuplesort.c 31 Jul 2008 22:09:52 -0000
***************
*** 107,112 ****
--- 107,113 ----
#include "catalog/pg_operator.h"
#include "commands/tablespace.h"
#include "miscadmin.h"
+ #include "pg_trace.h"
#include "utils/datum.h"
#include "utils/logtape.h"
#include "utils/lsyscache.h"
***************
*** 121,126 ****
--- 122,132 ----
#ifdef TRACE_SORT
bool trace_sort = false;
#endif
+
+ #define HEAP_SORT 0
+ #define INDEX_SORT 1
+ #define DATUM_SORT 2
+
#ifdef DEBUG_BOUNDED_SORT
bool optimize_bounded_sort = true;
#endif
*************** tuplesort_begin_heap(TupleDesc tupDesc,
*** 570,575 ****
--- 576,583 ----
nkeys, workMem, randomAccess ? 't' : 'f');
#endif
+ TRACE_POSTGRESQL_SORT_START(HEAP_SORT, false, nkeys, workMem, randomAccess);
+
state->nKeys = nkeys;
state->comparetup = comparetup_heap;
*************** tuplesort_begin_index_btree(Relation ind
*** 636,641 ****
--- 644,651 ----
state->nKeys = RelationGetNumberOfAttributes(indexRel);
+ TRACE_POSTGRESQL_SORT_START(INDEX_SORT, enforceUnique, state->nKeys, workMem, randomAccess);
+
state->comparetup = comparetup_index_btree;
state->copytup = copytup_index;
state->writetup = writetup_index;
*************** tuplesort_begin_datum(Oid datumType,
*** 714,719 ****
--- 724,731 ----
workMem, randomAccess ? 't' : 'f');
#endif
+ TRACE_POSTGRESQL_SORT_START(DATUM_SORT, false, 1, workMem, randomAccess);
+
state->nKeys = 1; /* always a one-column sort */
state->comparetup = comparetup_datum;
*************** tuplesort_end(Tuplesortstate *state)
*** 825,830 ****
--- 837,847 ----
}
#endif
+ TRACE_POSTGRESQL_SORT_DONE(state->tapeset,
+ (state->tapeset ? LogicalTapeSetBlocks(state->tapeset) :
+ (state->allowedMem - state->availMem + 1023) / 1024));
+
+
MemoryContextSwitchTo(oldcontext);
/*
--
Sent via pgsql-hackers mailing list ([email protected])
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-hackers