Skip site navigation (1) Skip section navigation (2)

Proposed changes to DTrace probe implementation

From: Robert Lor <Robert(dot)Lor(at)Sun(dot)COM>
To: pgsql-hackers list <pgsql-hackers(at)postgresql(dot)org>
Subject: Proposed changes to DTrace probe implementation
Date: 2008-02-22 17:13:23
Message-ID: (view raw, whole thread or download thread mbox)
Lists: pgsql-hackers
To enable probes to work with Mac OS X Leopard and other OSes that will 
support DTrace in the future. Bug filed on this issue

The problem:
There are two different mechanisms to implementing application level 
probes in DTrace as explained here I 
originally chose the first mechanism (using DTRACE_PROBEn macros) for 
simplicity, but Leopard's DTrace implementation only supports the second 
mechanism (using macros from dtrace generated header file). The second 
mechanism was introduced as an enhancement, and one of the benefits is 
type checking.

Proposed changes:
* Switch from using DTRACE_PROBEn macros to the dynamically generated 
macros (remove pg_trace.h)
* Use "dtrace -h" to create a header file that contains the dynamically 
generated macros to be used in the source code instead of the 
* Create a new header file called probes_null.h to map the generated 
macros to no-ops
* This is unrelated to making DTrace work on Leopard, but I'd like to 
propose that we split the probes into generic database and Postgres 
specific providers, called "database" and "postgresql" respectively. 
Other databases will be adding DTrace probes as well, and we want to use 
"database" as the provider for probes that are common to all databases. 
This way scripts that use the common provider will work on databases 
that implement the common probes.

With the proposed changes, the steps for adding new probes are slightly 
different, but the ways the probes are used will not change.

Steps for adding new probes now:
1) Add probe name to probes.d
2) Add probe to source code using one of PG_TRACEn macros
3) Recompile

Steps for adding probes with proposed changes:
1) Add probe name to probes.d (probes.h will be created at build time)
2) Add null macros to probes_null.h
3) Add probe to source code using the dynamically generated macro from 
4) Recompile

Preliminary patch is attached. There is one known issue with the patch. 
When compiling outside of the source tree, probes.d needs to be 
symlinked to the source tree. I haven't figured out how to copy the file 
to the build tree yet.  I'm sure this is trivial for you gurus out there!



Attachment: dtrace.patch
Description: text/plain (3.1 KB)
Attachment: probes_null.h
Description: text/plain (1.1 KB)


pgsql-hackers by date

Next:From: Andrew DunstanDate: 2008-02-22 17:23:41
Subject: Re: Including PL/PgSQL by default
Previous:From: Peter EisentrautDate: 2008-02-22 17:07:50
Subject: Re: Linking backend in one piece

Privacy Policy | About PostgreSQL
Copyright © 1996-2017 The PostgreSQL Global Development Group