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
Sponsored
·
Ship Features Fearlessly
Turn features on and off without deploys. Used by thousands of Ruby developers.
→
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
Sansan Engineering Unit 紹介資料
sansan33
PRO
1
3.8k
ブロックテーマでサイトをリニューアルした話 / 2026-01-31 Kansai WordPress Meetup
torounit
0
450
20260204_Midosuji_Tech
takuyay0ne
0
120
GitLab Duo Agent Platform × AGENTS.md で実現するSpec-Driven Development / GitLab Duo Agent Platform × AGENTS.md
n11sh1
0
120
15 years with Rails and DDD (AI Edition)
andrzejkrzywda
0
180
外部キー制約の知っておいて欲しいこと - RDBMSを正しく使うために必要なこと / FOREIGN KEY Night
soudai
PRO
12
4.8k
SREのプラクティスを用いた3領域同時 マネジメントへの挑戦 〜SRE・情シス・セキュリティを統合した チーム運営術〜
coconala_engineer
2
600
茨城の思い出を振り返る ~CDKのセキュリティを添えて~ / 20260201 Mitsutoshi Matsuo
shift_evolve
PRO
1
190
ブロックテーマ、WordPress でウェブサイトをつくるということ / 2026.02.07 Gifu WordPress Meetup
torounit
0
110
予期せぬコストの急増を障害のように扱う――「コスト版ポストモーテム」の導入とその後の改善
muziyoshiz
1
1.6k
こんなところでも(地味に)活躍するImage Modeさんを知ってるかい?- Image Mode for OpenShift -
tsukaman
0
100
2人で作ったAIダッシュボードが、開発組織の次の一手を照らした話― Cursor × SpecKit × 可視化の実践 ― Qiita AI Summit
noalisaai
1
370
Featured
See All Featured
Redefining SEO in the New Era of Traffic Generation
szymonslowik
1
210
Context Engineering - Making Every Token Count
addyosmani
9
650
Agile Actions for Facilitating Distributed Teams - ADO2019
mkilby
0
110
Fantastic passwords and where to find them - at NoRuKo
philnash
52
3.6k
Exploring anti-patterns in Rails
aemeredith
2
250
HU Berlin: Industrial-Strength Natural Language Processing with spaCy and Prodigy
inesmontani
PRO
0
200
Paper Plane (Part 1)
katiecoart
PRO
0
4k
Stewardship and Sustainability of Urban and Community Forests
pwiseman
0
110
Data-driven link building: lessons from a $708K investment (BrightonSEO talk)
szymonslowik
1
910
Visualizing Your Data: Incorporating Mongo into Loggly Infrastructure
mongodb
49
9.8k
YesSQL, Process and Tooling at Scale
rocio
174
15k
What’s in a name? Adding method to the madness
productmarketing
PRO
24
3.9k
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