mirror of
https://github.com/postgres/postgres.git
synced 2025-12-01 12:18:01 +03:00
Add a few more DTrace probes to the backend.
Robert Lor
This commit is contained in:
@@ -3,14 +3,19 @@
|
||||
#
|
||||
# Copyright (c) 2008, PostgreSQL Global Development Group
|
||||
#
|
||||
# $PostgreSQL: pgsql/src/backend/utils/Gen_dummy_probes.sed,v 1.1 2008/03/17 19:44:41 petere Exp $
|
||||
# $PostgreSQL: pgsql/src/backend/utils/Gen_dummy_probes.sed,v 1.2 2008/08/01 13:16:09 alvherre Exp $
|
||||
#-------------------------------------------------------------------------
|
||||
|
||||
/^probe /!d
|
||||
s/^probe \([^(]*\)\(.*\);/\1\2/
|
||||
/^[ ]*probe /!d
|
||||
s/^[ ]*probe \([^(]*\)\(.*\);/\1\2/
|
||||
s/__/_/g
|
||||
y/abcdefghijklmnopqrstuvwxyz/ABCDEFGHIJKLMNOPQRSTUVWXYZ/
|
||||
s/^/#define TRACE_POSTGRESQL_/
|
||||
s/(INT, INT)/(INT1, INT2)/
|
||||
s/([^,)]\{1,\})/(INT1)/
|
||||
s/([^,)]\{1,\}, [^,)]\{1,\})/(INT1, INT2)/
|
||||
s/([^,)]\{1,\}, [^,)]\{1,\}, [^,)]\{1,\})/(INT1, INT2, INT3)/
|
||||
s/([^,)]\{1,\}, [^,)]\{1,\}, [^,)]\{1,\}, [^,)]\{1,\})/(INT1, INT2, INT3, INT4)/
|
||||
s/([^,)]\{1,\}, [^,)]\{1,\}, [^,)]\{1,\}, [^,)]\{1,\}, [^,)]\{1,\})/(INT1, INT2, INT3, INT4, INT5)/
|
||||
s/([^,)]\{1,\}, [^,)]\{1,\}, [^,)]\{1,\}, [^,)]\{1,\}, [^,)]\{1,\}, [^,)]\{1,\})/(INT1, INT2, INT3, INT4, INT5, INT6)/
|
||||
P
|
||||
s/(.*$/_ENABLED() (0)/
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
#
|
||||
# Makefile for utils
|
||||
#
|
||||
# $PostgreSQL: pgsql/src/backend/utils/Makefile,v 1.27 2008/03/17 19:44:41 petere Exp $
|
||||
# $PostgreSQL: pgsql/src/backend/utils/Makefile,v 1.28 2008/08/01 13:16:09 alvherre Exp $
|
||||
#
|
||||
|
||||
subdir = src/backend/utils
|
||||
@@ -20,9 +20,13 @@ $(SUBDIRS:%=%-recursive): fmgroids.h
|
||||
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) -h -s $< -o $@.tmp
|
||||
$(DTRACE) -C -h -s $< -o $@.tmp
|
||||
sed -e 's/POSTGRESQL_/TRACE_POSTGRESQL_/g' $@.tmp >$@
|
||||
rm $@.tmp
|
||||
else
|
||||
|
||||
@@ -3,22 +3,89 @@
|
||||
*
|
||||
* Copyright (c) 2006-2008, PostgreSQL Global Development Group
|
||||
*
|
||||
* $PostgreSQL: pgsql/src/backend/utils/probes.d,v 1.2 2008/01/02 02:42:06 momjian Exp $
|
||||
* $PostgreSQL: pgsql/src/backend/utils/probes.d,v 1.3 2008/08/01 13:16:09 alvherre Exp $
|
||||
* ----------
|
||||
*/
|
||||
|
||||
|
||||
/* 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 {
|
||||
|
||||
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);
|
||||
/*
|
||||
* 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, LOCKMODE);
|
||||
* probe lock__wait__done(unsigned int, LOCKMODE);
|
||||
*/
|
||||
probe lock__wait__start(unsigned int, int);
|
||||
probe lock__wait__done(unsigned int, int);
|
||||
|
||||
probe query__parse__start(const char *);
|
||||
probe query__parse__done(const char *);
|
||||
probe query__rewrite__start(const char *);
|
||||
probe query__rewrite__done(const char *);
|
||||
probe query__plan__start();
|
||||
probe query__plan__done();
|
||||
probe query__execute__start();
|
||||
probe query__execute__done();
|
||||
probe query__start(const char *);
|
||||
probe query__done(const char *);
|
||||
probe statement__status(const char *);
|
||||
|
||||
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);
|
||||
* probe buffer__read__done(BlockNumber, Oid, Oid, Oid, bool, bool);
|
||||
*/
|
||||
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();
|
||||
};
|
||||
|
||||
@@ -91,7 +91,7 @@
|
||||
* Portions Copyright (c) 1994, Regents of the University of California
|
||||
*
|
||||
* IDENTIFICATION
|
||||
* $PostgreSQL: pgsql/src/backend/utils/sort/tuplesort.c,v 1.85 2008/06/19 00:46:05 alvherre Exp $
|
||||
* $PostgreSQL: pgsql/src/backend/utils/sort/tuplesort.c,v 1.86 2008/08/01 13:16:09 alvherre Exp $
|
||||
*
|
||||
*-------------------------------------------------------------------------
|
||||
*/
|
||||
@@ -107,6 +107,7 @@
|
||||
#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,6 +122,11 @@
|
||||
#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
|
||||
@@ -570,6 +576,8 @@ tuplesort_begin_heap(TupleDesc tupDesc,
|
||||
nkeys, workMem, randomAccess ? 't' : 'f');
|
||||
#endif
|
||||
|
||||
TRACE_POSTGRESQL_SORT_START(HEAP_SORT, false, nkeys, workMem, randomAccess);
|
||||
|
||||
state->nKeys = nkeys;
|
||||
|
||||
state->comparetup = comparetup_heap;
|
||||
@@ -636,6 +644,8 @@ tuplesort_begin_index_btree(Relation indexRel,
|
||||
|
||||
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;
|
||||
@@ -714,6 +724,8 @@ tuplesort_begin_datum(Oid datumType,
|
||||
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;
|
||||
@@ -825,6 +837,11 @@ tuplesort_end(Tuplesortstate *state)
|
||||
}
|
||||
#endif
|
||||
|
||||
TRACE_POSTGRESQL_SORT_DONE(state->tapeset,
|
||||
(state->tapeset ? LogicalTapeSetBlocks(state->tapeset) :
|
||||
(state->allowedMem - state->availMem + 1023) / 1024));
|
||||
|
||||
|
||||
MemoryContextSwitchTo(oldcontext);
|
||||
|
||||
/*
|
||||
|
||||
Reference in New Issue
Block a user