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

Commite9b4969

Browse files
committed
DTrace support, with a small initial set of probes
by Robert Lor
1 parent9dc34b5 commite9b4969

File tree

12 files changed

+230
-11
lines changed

12 files changed

+230
-11
lines changed

‎configure

Lines changed: 82 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -314,7 +314,7 @@ ac_includes_default="\
314314
# include <unistd.h>
315315
#endif"
316316

317-
ac_subst_vars='SHELL PATH_SEPARATOR PACKAGE_NAME PACKAGE_TARNAME PACKAGE_VERSION PACKAGE_STRING PACKAGE_BUGREPORT exec_prefix prefix program_transform_name bindir sbindir libexecdir datadir sysconfdir sharedstatedir localstatedir libdir includedir oldincludedir infodir mandir build_alias host_alias target_alias DEFS ECHO_C ECHO_N ECHO_T LIBS configure_args build build_cpu build_vendor build_os host host_cpu host_vendor host_os PORTNAME docdir enable_nls WANTED_LANGUAGES default_port enable_shared enable_rpath enable_debug CC CFLAGS LDFLAGS CPPFLAGS ac_ct_CC EXEEXT OBJEXT CPP GCC TAS autodepend INCLUDES enable_thread_safety with_tcl with_perl with_python with_krb5 krb_srvtab with_pam with_ldap with_bonjour with_openssl with_zlib EGREP ELF_SYS LDFLAGS_SL AWK FLEX FLEXFLAGS LN_S LD with_gnu_ld ld_R_works RANLIB ac_ct_RANLIB TAR STRIP ac_ct_STRIP STRIP_STATIC_LIB STRIP_SHARED_LIB YACC YFLAGS PERL perl_archlibexp perl_privlibexp perl_useshrplib perl_embed_ldflags PYTHON python_version python_configdir python_includespec python_libdir python_libspec python_additional_libs HAVE_IPV6 LIBOBJS acx_pthread_config PTHREAD_CC PTHREAD_LIBS PTHREAD_CFLAGS HAVE_POSIX_SIGNALS MSGFMT MSGMERGE XGETTEXT localedir TCLSH TCL_CONFIG_SH TCL_INCLUDE_SPEC TCL_LIB_FILE TCL_LIBS TCL_LIB_SPEC TCL_SHARED_BUILD TCL_SHLIB_LD_LIBS NSGMLS JADE have_docbook DOCBOOKSTYLE COLLATEINDEX SGMLSPL vpath_build LTLIBOBJS'
317+
ac_subst_vars='SHELL PATH_SEPARATOR PACKAGE_NAME PACKAGE_TARNAME PACKAGE_VERSION PACKAGE_STRING PACKAGE_BUGREPORT exec_prefix prefix program_transform_name bindir sbindir libexecdir datadir sysconfdir sharedstatedir localstatedir libdir includedir oldincludedir infodir mandir build_alias host_alias target_alias DEFS ECHO_C ECHO_N ECHO_T LIBS configure_args build build_cpu build_vendor build_os host host_cpu host_vendor host_os PORTNAME docdir enable_nls WANTED_LANGUAGES default_port enable_shared enable_rpath enable_debug DTRACE DTRACEFLAGS enable_dtrace CC CFLAGS LDFLAGS CPPFLAGS ac_ct_CC EXEEXT OBJEXT CPP GCC TAS autodepend INCLUDES enable_thread_safety with_tcl with_perl with_python with_krb5 krb_srvtab with_pam with_ldap with_bonjour with_openssl with_zlib EGREP ELF_SYS LDFLAGS_SL AWK FLEX FLEXFLAGS LN_S LD with_gnu_ld ld_R_works RANLIB ac_ct_RANLIB TAR STRIP ac_ct_STRIP STRIP_STATIC_LIB STRIP_SHARED_LIB YACC YFLAGS PERL perl_archlibexp perl_privlibexp perl_useshrplib perl_embed_ldflags PYTHON python_version python_configdir python_includespec python_libdir python_libspec python_additional_libs HAVE_IPV6 LIBOBJS acx_pthread_config PTHREAD_CC PTHREAD_LIBS PTHREAD_CFLAGS HAVE_POSIX_SIGNALS MSGFMT MSGMERGE XGETTEXT localedir TCLSH TCL_CONFIG_SH TCL_INCLUDE_SPEC TCL_LIB_FILE TCL_LIBS TCL_LIB_SPEC TCL_SHARED_BUILD TCL_SHLIB_LD_LIBS NSGMLS JADE have_docbook DOCBOOKSTYLE COLLATEINDEX SGMLSPL vpath_build LTLIBOBJS'
318318
ac_subst_files=''
319319

320320
# Initialize some variables set by options.
@@ -865,6 +865,7 @@ Optional Features:
865865
--disable-rpath do not embed shared library search path in executables
866866
--disable-spinlocks do not use spinlocks
867867
--enable-debug build with debugging symbols (-g)
868+
--enable-dtrace build with DTrace support
868869
--enable-depend turn on automatic dependency tracking
869870
--enable-cassert enable assertion checks (for debugging)
870871
--enable-thread-safety make client libraries thread-safe
@@ -1946,6 +1947,82 @@ fi;
19461947

19471948

19481949

1950+
#
1951+
# DTrace
1952+
#
1953+
1954+
1955+
1956+
# Check whether --enable-dtrace or --disable-dtrace was given.
1957+
if test "${enable_dtrace+set}" = set; then
1958+
enableval="$enable_dtrace"
1959+
1960+
case $enableval in
1961+
yes)
1962+
1963+
cat >>confdefs.h <<\_ACEOF
1964+
#define ENABLE_DTRACE 1
1965+
_ACEOF
1966+
1967+
for ac_prog in dtrace
1968+
do
1969+
# Extract the first word of "$ac_prog", so it can be a program name with args.
1970+
set dummy $ac_prog; ac_word=$2
1971+
echo "$as_me:$LINENO: checking for $ac_word" >&5
1972+
echo $ECHO_N "checking for $ac_word... $ECHO_C" >&6
1973+
if test "${ac_cv_prog_DTRACE+set}" = set; then
1974+
echo $ECHO_N "(cached) $ECHO_C" >&6
1975+
else
1976+
if test -n "$DTRACE"; then
1977+
ac_cv_prog_DTRACE="$DTRACE" # Let the user override the test.
1978+
else
1979+
as_save_IFS=$IFS; IFS=$PATH_SEPARATOR
1980+
for as_dir in $PATH
1981+
do
1982+
IFS=$as_save_IFS
1983+
test -z "$as_dir" && as_dir=.
1984+
for ac_exec_ext in '' $ac_executable_extensions; do
1985+
if $as_executable_p "$as_dir/$ac_word$ac_exec_ext"; then
1986+
ac_cv_prog_DTRACE="$ac_prog"
1987+
echo "$as_me:$LINENO: found $as_dir/$ac_word$ac_exec_ext" >&5
1988+
break 2
1989+
fi
1990+
done
1991+
done
1992+
1993+
fi
1994+
fi
1995+
DTRACE=$ac_cv_prog_DTRACE
1996+
if test -n "$DTRACE"; then
1997+
echo "$as_me:$LINENO: result: $DTRACE" >&5
1998+
echo "${ECHO_T}$DTRACE" >&6
1999+
else
2000+
echo "$as_me:$LINENO: result: no" >&5
2001+
echo "${ECHO_T}no" >&6
2002+
fi
2003+
2004+
test -n "$DTRACE" && break
2005+
done
2006+
2007+
2008+
;;
2009+
no)
2010+
:
2011+
;;
2012+
*)
2013+
{ { echo "$as_me:$LINENO: error: no argument expected for --enable-dtrace option" >&5
2014+
echo "$as_me: error: no argument expected for --enable-dtrace option" >&2;}
2015+
{ (exit 1); exit 1; }; }
2016+
;;
2017+
esac
2018+
2019+
else
2020+
enable_dtrace=no
2021+
2022+
fi;
2023+
2024+
2025+
19492026
#
19502027
# C compiler
19512028
#
@@ -22759,6 +22836,7 @@ enable_shared) ;;
2275922836
enable_rpath) ;;
2276022837
enable_spinlocks) ;;
2276122838
enable_debug) ;;
22839+
enable_dtrace) ;;
2276222840
with_CC) ;;
2276322841
enable_depend) ;;
2276422842
enable_cassert) ;;
@@ -23431,6 +23509,9 @@ s,@default_port@,$default_port,;t t
2343123509
s,@enable_shared@,$enable_shared,;t t
2343223510
s,@enable_rpath@,$enable_rpath,;t t
2343323511
s,@enable_debug@,$enable_debug,;t t
23512+
s,@DTRACE@,$DTRACE,;t t
23513+
s,@DTRACEFLAGS@,$DTRACEFLAGS,;t t
23514+
s,@enable_dtrace@,$enable_dtrace,;t t
2343423515
s,@CC@,$CC,;t t
2343523516
s,@CFLAGS@,$CFLAGS,;t t
2343623517
s,@LDFLAGS@,$LDFLAGS,;t t

‎configure.in

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
dnl Process this file with autoconf to produce a configure script.
2-
dnl $PostgreSQL: pgsql/configure.in,v 1.468 2006/07/11 16:14:50 tgl Exp $
2+
dnl $PostgreSQL: pgsql/configure.in,v 1.469 2006/07/24 16:32:44 petere Exp $
33
dnl
44
dnl Developers, please strive to achieve this order:
55
dnl
@@ -205,6 +205,17 @@ PGAC_ARG_BOOL(enable, debug, no,
205205
[ --enable-debug build with debugging symbols (-g)])
206206
AC_SUBST(enable_debug)
207207

208+
#
209+
# DTrace
210+
#
211+
PGAC_ARG_BOOL(enable, dtrace, no,
212+
[ --enable-dtrace build with DTrace support],
213+
[AC_DEFINE([ENABLE_DTRACE], 1,
214+
[Define to 1 to enable DTrace support. (--enable-dtrace)])
215+
AC_CHECK_PROGS(DTRACE, dtrace)
216+
AC_SUBST(DTRACEFLAGS)])
217+
AC_SUBST(enable_dtrace)
218+
208219
#
209220
# C compiler
210221
#

‎doc/src/sgml/installation.sgml

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
<!-- $PostgreSQL: pgsql/doc/src/sgml/installation.sgml,v 1.258 2006/06/18 15:38:35 petere Exp $ -->
1+
<!-- $PostgreSQL: pgsql/doc/src/sgml/installation.sgml,v 1.259 2006/07/24 16:32:44 petere Exp $ -->
22

33
<chapter id="installation">
44
<title><![%standalone-include[<productname>PostgreSQL</>]]>
@@ -1007,6 +1007,17 @@ su - postgres
10071007
</listitem>
10081008
</varlistentry>
10091009

1010+
<varlistentry>
1011+
<term><option>--enable-dtrace</option></term>
1012+
<listitem>
1013+
<para>
1014+
Compiles with support for the dynamic tracing tool DTrace.
1015+
Operating system support for DTrace is currently only
1016+
available in Solaris.
1017+
</para>
1018+
</listitem>
1019+
</varlistentry>
1020+
10101021
</variablelist>
10111022
</para>
10121023

‎src/Makefile.global.in

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
# -*-makefile-*-
2-
# $PostgreSQL: pgsql/src/Makefile.global.in,v 1.224 2006/07/21 22:37:37 petere Exp $
2+
# $PostgreSQL: pgsql/src/Makefile.global.in,v 1.225 2006/07/24 16:32:44 petere Exp $
33

44
#------------------------------------------------------------------------------
55
# All PostgreSQL makefiles include this file and use the variables it sets,
@@ -157,6 +157,7 @@ enable_shared= @enable_shared@
157157
enable_rpath= @enable_rpath@
158158
enable_nls= @enable_nls@
159159
enable_debug= @enable_debug@
160+
enable_dtrace= @enable_dtrace@
160161
enable_thread_safety= @enable_thread_safety@
161162

162163
python_includespec= @python_includespec@
@@ -212,6 +213,8 @@ YACC = @YACC@
212213
YFLAGS = @YFLAGS@
213214
FLEX = @FLEX@
214215
FLEXFLAGS = @FLEXFLAGS@$(LFLAGS)
216+
DTRACE = @DTRACE@
217+
DTRACEFLAGS = @DTRACEFLAGS@
215218

216219
# Linking
217220

‎src/backend/Makefile

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
#
55
# Copyright (c) 1994, Regents of the University of California
66
#
7-
# $PostgreSQL: pgsql/src/backend/Makefile,v 1.116 2006/06/22 23:50:35 tgl Exp $
7+
# $PostgreSQL: pgsql/src/backend/Makefile,v 1.117 2006/07/24 16:32:44 petere Exp $
88
#
99
#-------------------------------------------------------------------------
1010

@@ -19,7 +19,11 @@ DIRS := access bootstrap catalog parser commands executor lib libpq \
1919

2020
SUBSYSOBJS :=$(DIRS:%=%/SUBSYS.o)
2121

22-
OBJS :=$(SUBSYSOBJS)$(top_builddir)/src/port/libpgport_srv.a
22+
ifeq ($(enable_dtrace), yes)
23+
LOCALOBJS += utils/probes.o
24+
endif
25+
26+
OBJS =$(SUBSYSOBJS)$(LOCALOBJS)$(top_builddir)/src/port/libpgport_srv.a
2327

2428
# We put libpgport into OBJS, so remove it from LIBS
2529
LIBS :=$(filter-out -lpgport,$(LIBS))
@@ -135,6 +139,10 @@ $(top_builddir)/src/include/utils/fmgroids.h: utils/fmgroids.h
135139
$(LN_S) ../../../$(subdir)/utils/fmgroids.h.
136140

137141

142+
utils/probes.o: utils/probes.d$(SUBSYSOBJS)
143+
$(DTRACE)$(DTRACEFLAGS) -G -s$^
144+
145+
138146
##########################################################################
139147

140148
distprep:
@@ -220,7 +228,7 @@ endif
220228
##########################################################################
221229

222230
clean:
223-
rm -f postgres$(X)$(POSTGRES_IMP)\
231+
rm -f$(LOCALOBJS)postgres$(X)$(POSTGRES_IMP)\
224232
$(top_srcdir)/src/include/parser/parse.h\
225233
$(top_builddir)/src/include/utils/fmgroids.h
226234
ifeq ($(PORTNAME), cygwin)

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

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010
*
1111
*
1212
* IDENTIFICATION
13-
* $PostgreSQL: pgsql/src/backend/access/transam/xact.c,v 1.223 2006/07/14 14:52:17 momjian Exp $
13+
* $PostgreSQL: pgsql/src/backend/access/transam/xact.c,v 1.224 2006/07/24 16:32:44 petere Exp $
1414
*
1515
*-------------------------------------------------------------------------
1616
*/
@@ -1384,6 +1384,8 @@ StartTransaction(void)
13841384

13851385
XactLockTableInsert(s->transactionId);
13861386

1387+
PG_TRACE1 (transaction__start,s->transactionId);
1388+
13871389
/*
13881390
* set transaction_timestamp() (a/k/a now()). We want this to be the
13891391
* same as the first command's statement_timestamp(), so don't do a
@@ -1535,6 +1537,8 @@ CommitTransaction(void)
15351537
LWLockRelease(ProcArrayLock);
15361538
}
15371539

1540+
PG_TRACE1 (transaction__commit,s->transactionId);
1541+
15381542
/*
15391543
* This is all post-commit cleanup. Note that if an error is raised here,
15401544
* it's too late to abort the transaction. This should be just
@@ -1931,6 +1935,8 @@ AbortTransaction(void)
19311935
LWLockRelease(ProcArrayLock);
19321936
}
19331937

1938+
PG_TRACE1 (transaction__abort,s->transactionId);
1939+
19341940
/*
19351941
* Post-abort cleanup.See notes in CommitTransaction() concerning
19361942
* ordering.

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

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
*
99
*
1010
* IDENTIFICATION
11-
* $PostgreSQL: pgsql/src/backend/storage/lmgr/lock.c,v 1.168 2006/07/23 23:08:46 tgl Exp $
11+
* $PostgreSQL: pgsql/src/backend/storage/lmgr/lock.c,v 1.169 2006/07/24 16:32:45 petere Exp $
1212
*
1313
* NOTES
1414
* A lock table is a shared memory hash table. When
@@ -796,8 +796,13 @@ LockAcquire(const LOCKTAG *locktag,
796796
/*
797797
* Sleep till someone wakes me up.
798798
*/
799+
800+
PG_TRACE2(lock__startwait,locktag->locktag_field2,lockmode);
801+
799802
WaitOnLock(locallock,owner);
800803

804+
PG_TRACE2(lock__endwait,locktag->locktag_field2,lockmode);
805+
801806
/*
802807
* NOTE: do not do any material change of state between here and
803808
* return.All required changes in locktable state must have been

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

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@
1515
* Portions Copyright (c) 1994, Regents of the University of California
1616
*
1717
* IDENTIFICATION
18-
* $PostgreSQL: pgsql/src/backend/storage/lmgr/lwlock.c,v 1.41 2006/07/23 03:07:58 tgl Exp $
18+
* $PostgreSQL: pgsql/src/backend/storage/lmgr/lwlock.c,v 1.42 2006/07/24 16:32:45 petere Exp $
1919
*
2020
*-------------------------------------------------------------------------
2121
*/
@@ -420,6 +420,8 @@ LWLockAcquire(LWLockId lockid, LWLockMode mode)
420420
block_counts[lockid]++;
421421
#endif
422422

423+
PG_TRACE2(lwlock__startwait,lockid,mode);
424+
423425
for (;;)
424426
{
425427
/* "false" means cannot accept cancel/die interrupt here. */
@@ -429,6 +431,8 @@ LWLockAcquire(LWLockId lockid, LWLockMode mode)
429431
extraWaits++;
430432
}
431433

434+
PG_TRACE2(lwlock__endwait,lockid,mode);
435+
432436
LOG_LWDEBUG("LWLockAcquire",lockid,"awakened");
433437

434438
/* Now loop back and try to acquire lock again. */
@@ -438,6 +442,8 @@ LWLockAcquire(LWLockId lockid, LWLockMode mode)
438442
/* We are done updating shared state of the lock itself. */
439443
SpinLockRelease(&lock->mutex);
440444

445+
PG_TRACE2(lwlock__acquire,lockid,mode);
446+
441447
/* Add lock to list of locks held by this backend */
442448
held_lwlocks[num_held_lwlocks++]=lockid;
443449

@@ -507,11 +513,13 @@ LWLockConditionalAcquire(LWLockId lockid, LWLockMode mode)
507513
/* Failed to get lock, so release interrupt holdoff */
508514
RESUME_INTERRUPTS();
509515
LOG_LWDEBUG("LWLockConditionalAcquire",lockid,"failed");
516+
PG_TRACE2(lwlock__condacquire__fail,lockid,mode);
510517
}
511518
else
512519
{
513520
/* Add lock to list of locks held by this backend */
514521
held_lwlocks[num_held_lwlocks++]=lockid;
522+
PG_TRACE2(lwlock__condacquire,lockid,mode);
515523
}
516524

517525
return !mustwait;
@@ -596,6 +604,8 @@ LWLockRelease(LWLockId lockid)
596604
/* We are done updating shared state of the lock itself. */
597605
SpinLockRelease(&lock->mutex);
598606

607+
PG_TRACE1(lwlock__release,lockid);
608+
599609
/*
600610
* Awaken any waiters I removed from the queue.
601611
*/

‎src/backend/utils/probes.d

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
/* ----------
2+
*DTrace probes for PostgreSQL backend
3+
*
4+
*Copyright (c) 2006, PostgreSQL Global Development Group
5+
*
6+
*$PostgreSQL: pgsql/src/backend/utils/probes.d,v 1.1 2006/07/24 16:32:45 petere Exp $
7+
* ----------
8+
*/
9+
10+
providerpostgresql {
11+
12+
probetransaction__start(int);
13+
probetransaction__commit(int);
14+
probetransaction__abort(int);
15+
probelwlock__acquire(int,int);
16+
probelwlock__release(int);
17+
probelwlock__startwait(int,int);
18+
probelwlock__endwait(int,int);
19+
probelwlock__condacquire(int,int);
20+
probelwlock__condacquire__fail(int,int);
21+
probelock__startwait(int,int);
22+
probelock__endwait(int,int);
23+
24+
};

‎src/include/c.h

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212
* Portions Copyright (c) 1996-2006, PostgreSQL Global Development Group
1313
* Portions Copyright (c) 1994, Regents of the University of California
1414
*
15-
* $PostgreSQL: pgsql/src/include/c.h,v 1.206 2006/07/06 01:55:51 momjian Exp $
15+
* $PostgreSQL: pgsql/src/include/c.h,v 1.207 2006/07/24 16:32:45 petere Exp $
1616
*
1717
*-------------------------------------------------------------------------
1818
*/
@@ -56,6 +56,7 @@
5656
#include"pg_config_os.h"/* must be before any system header files */
5757
#endif
5858
#include"postgres_ext.h"
59+
#include"pg_trace.h"
5960

6061
#if defined(_MSC_VER)|| defined(__BORLANDC__)
6162
#defineWIN32_ONLY_COMPILER

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp