Professional Documents
Culture Documents
48 Practical Applications DTrace
48 Practical Applications DTrace
Senior IT Architect
Sun Microsystems Pte Ltd
Practical Applications of DTrace
Agenda
What is DTrace?
Uses of DTrace
Additional information
Why Dynamic Tracing?
Well-defined techniques for deu!!in! f at al,
non- reproducible failure:
> Obtain core file or crash dump
>
Debug problem post m ort em using mdb(1),
dbx(1)
Techniques for debugging t ransient
failures are much more ad hoc
> Tpical techniques push traditional tools (e!g!
truss(1), mdb(1)) beond their design centers
> "an transient problems cannot be debugged
at all using extant techniques
Transient failure
Any unacce"tale eha#ior that does not result in fatal
failure of the system
May e a clear failure$
> %&ur a""lication occasionally doesn't recei#e its timer si!nal()
May e a failure ased on customer's definition of
%unacce"tale)$
> %We *ere e+"ectin! to accommodate ,-- users "er .PU / and
*e're ale to !et no more than 0- users "er .PU()
> %1#ery mornin! from aout 2am to aout ,-$3-am4 the system is a
do!()
#erformance inhibitors or incorrect expectations$
Debugging transient failure
5istorically4 *e ha#e deu!!ed transient failure
usin! "rocess-centric tools$ truss6,74 "stack6,74
"rstat6,74 etc(
These tools *ere not desi!ned to deu!
syst em ic "rolems
8ut the tools desi!ned for systemic "rolems 6i(e(4
md6,77 are desi!ned for "ostmortem analysis(((
Postmortem techniques
&ne technique is to use "ostmortem analysis to
deu! transient "rolems y inducing fatal
failure during period of transient failure
%etter than nothing, but not b much:
> &equires inducing fatal failure, 'hich nearl
al'as results in more do'ntime than the
transient failure
> &equires a (een intuition to be able to suss out
a dnamic problem from a static snapshot of
state
Invasive techniques
If e+istin! tools cannot root-cause transient failure4
more in#asi#e techniques must e used
Ty"ically4 custom instrumentation is de#elo"ed for
the failin! "ro!ram and9or the kernel
The customer re"roduces the "rolem usin! the
instrumented inaries
Dynamic instrumentation
Want to e ale to dynam ically modify the
system to record arbit rary data
Must e ale to do this on a product ion system
Must e com"letely saf e / there should e no *ay
to induce fatal failure
Introducing DTrace
Dynamic tracin! frame*ork introduced *ithin S,-
in Se"temer :--3
A#ailale on stock systems / ty"ical system has
more than 3;4--- "roes
Dynamically inter"reted lan!ua!e allo*s for
aritrary actions and "redicates
.an instrument at oth user-le#el and kernel-le#el
Introducing DTrace, cont.
Po*erful data mana!ement "rimiti#es eliminate
need for most "ost"rocessin!
Un*anted data is "runed as close to the source as
"ossile
Mechanism to trace durin! oot
Mechanism to retrie#e all data from a kernel crash
dum"
Much more(((
ey !oncepts
Proes
Pro#iders
.onsumers
The %D) lan!ua!e
>
<ariales
>
Actions
>
A!!re!ation
>
Predicates
>
=ormattin!
Probes
A probe is a point of instrumentation
) probe is made a*ailable b a provider
+ach probe identifies the m odule and
f unct ion that it instruments
+ach probe has a nam e
These four attributes define a tuple that
uniquel identifies each probe
+ach probe is assigned an integer
identifier
Providers
A "ro#ider re"resents a methodolo!y for
instrumentin! the system
Pro#iders make "roes a#ailale to the DTrace
frame*ork
DTrace informs "ro#iders *hen a "roe is to e
enaled
Pro#iders transfer control to DTrace *hen an
enaled "roe is hit
Providers, cont.
DTrace has quite a fe* "ro#iders4 e(!($
>
The f unct ion boundary t racing (FBT)
pro*ider can dynamically instrument e#ery function
entry and return in the kernel
>
The syscall "ro#ider can dynamically instrument the
system call tale
>
The lockst at "ro#ider can dynamically instrument
the kernel synchroni>ation "rimiti#es
>
The prof ile pro*ider can add a configureable,
rate profile interrupt of to the sstem
>
...
!onsumers
A DTrace consumer is a "rocess that interacts
*ith DTrace
?o limit on concurrent consumers@ DTrace
handles the multi"le+in!
Some "ro!rams are DTrace consumers only as an
im"lementation detail
dtrace6,M7 is a DTrace consumer that acts as a
!eneric front-end to the DTrace facility
"isting probes
Proes can e listed *ith the %-l) o"tion to dtrace
6,M7
.an list "roes
>
in a s"ecific function *ith %-f f unct ion)
>
in a s"ecific module *ith %-m m odule)
>
*ith a s"ecific name *ith %-n nam e-
>
from a specific pro*ider 'ith .,# provider-
/or each probe, pro*ider, module, function
and name are displaed
#ere are the Probes,
Providers and !onsumers
Actions
Act ions are taken *hen a "roe fires
Actions are com"letely "ro!rammale
Most actions record some s"ecified state in the
system
Some actions change the state of the system
system in a *ell-defined *ay
>
These are called dest ruct ive act ions
> Disabled b default
Many actions take as "arameters e+"ressions in
the D language
Actions$ %trace&