Upgrade to Pro
— share decks privately, control downloads, hide ads and more …
Speaker Deck
Features
Speaker Deck
PRO
Sign in
Sign up for free
Search
Search
DTrace & Python
Search
Conor McDermottroe
March 13, 2013
Technology
2
140
DTrace & Python
An introduction to DTrace and to using DTrace to inspect Python programs.
Conor McDermottroe
March 13, 2013
Tweet
Share
Other Decks in Technology
See All in Technology
次世代のメールプロトコルの斜め読み
hirachan
2
250
Okta Identity Governanceで実現する最小権限の原則
demaecan
0
230
GTC 2025 : 가속되고 있는 미래
inureyes
PRO
0
140
初海外がre:Inventだった人間の感じたこと
tommy0124
1
170
re:Inventに行くまでにやっておきたいこと
nagisa53
0
920
戦えるAIエージェントの作り方
iwiwi
19
9.3k
パフォーマンスチューニングのために普段からできること/Performance Tuning: Daily Practices
fujiwara3
2
180
オブザーバビリティが育むシステム理解と好奇心
maruloop
3
1.9k
激動の時代を爆速リチーミングで乗り越えろ
sansantech
PRO
1
230
個人でデジタル庁の デザインシステムをVue.jsで 作っている話
nishiharatsubasa
3
5.3k
AIとの協業で実現!レガシーコードをKotlinらしく生まれ変わらせる実践ガイド
zozotech
PRO
2
250
251029 JAWS-UG AI/ML 退屈なことはQDevにやらせよう
otakensh
0
120
Featured
See All Featured
Into the Great Unknown - MozCon
thekraken
40
2.1k
jQuery: Nuts, Bolts and Bling
dougneiner
65
7.9k
Making Projects Easy
brettharned
120
6.4k
XXLCSS - How to scale CSS and keep your sanity
sugarenia
249
1.3M
Design and Strategy: How to Deal with People Who Don’t "Get" Design
morganepeng
132
19k
Rails Girls Zürich Keynote
gr2m
95
14k
Improving Core Web Vitals using Speculation Rules API
sergeychernyshev
21
1.2k
StorybookのUI Testing Handbookを読んだ
zakiyama
31
6.3k
CoffeeScript is Beautiful & I Never Want to Write Plain JavaScript Again
sstephenson
162
15k
Building Better People: How to give real-time feedback that sticks.
wjessup
370
20k
Responsive Adventures: Dirty Tricks From The Dark Corners of Front-End
smashingmag
253
22k
Designing Dashboards & Data Visualisations in Web Apps
destraynor
231
54k
Transcript
DTrace & Python Conor McDermottroe @IRLConor
WARNING • I’ve only been using DTrace for a couple
of months • Sometimes it helps to know C • Sometimes it helps to know AWK
What is it? • It’s like having logging everywhere •
... but without being slow • ... and with good query tools
What is it not? • A debugger • A profiler
• A logging framework
How do you get it? • Solaris (>= 10) •
Mac OS X (>= 10.5) • FreeBSD (>= 7.1) • Linux - https://github.com/dtrace4linux/linux
How do you use it? # dtrace -n '<some D>'
-c /some/cmd # dtrace -s myscript.d -c /some/cmd # dtrace -s myscript.d -p 1234 # dtrace -s myscript.d
D Syntax provider:module:function:name /predicate goes here/ { /* body goes
here */ }
Trace all system calls syscall:::entry { printf("%s\n", probefunc); }
Trace opening files syscall::open:entry { printf("%s\n", copyinstr(arg0)); }
Who opened /etc/passwd? syscall::open:entry /copyinstr(arg0) == "/etc/passwd"/ { printf("%s\n", execname);
ustack(); }
What’s sending TCP traffic? tcp::tcp_output:send { printf( "%s -> %s\n",
execname, args[2]->ip_daddr ); }
Lots of functions copyin copyinstr stringof trace tracemem printf printa
count sum avg stack ustack clear trunc min max quantize stop copyout copyoutstr breakpoint panic chill
What about Python? • You need a patched copy of
Python • Already patched on Solaris • OS X: brew install python --with-dtrace • WARNING: The syntax may differ, depending on the patch
Trace Python function calls :Python::function-entry { printf( "%s:%d %s", copyinstr(arg0),
arg2, copyinstr(arg1) ); }
Timing breakdown for sub :Python::function-entry /copyinstr(arg1) == "sub"/ { self->start
= timestamp; } :Python::function-return /copyinstr(arg1) == "sub"/ { self->t = timestamp - self->start; @time[execname] = quantize(self->t); self->ts = 0; }
Timing breakdown for sub Python value ------------- Distribution ------------- count
65536 | 0 131072 |@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@ 7 262144 |@@@@@ 1 524288 | 0
Trace Python function calls :Python::function-entry /copyinstr(arg1) == "sub"/ { ustack();
}
Trace Python object creation :Python::instance-new-start { self->classname = copyinstr(arg0); printf("%s\n",
self->classname); }
Things to look out for • It’s fast but it's
not free - be selective • Probe names may differ across operating systems • For non-standard probes arg documentation can be sparse
Links • http://docs.oracle.com/cd/E18752_01/pdf/819-5488.pdf • http://www.brendangregg.com/dtrace.html#DTraceToolkit • http://bugs.python.org/issue13405 • https://blogs.oracle.com/brendan/resource/DTrace-cheatsheet.pdf
QUESTIONS