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
140
2
Share
DTrace & Python
An introduction to DTrace and to using DTrace to inspect Python programs.
Conor McDermottroe
March 13, 2013
Other Decks in Technology
See All in Technology
10サービス以上のメール到達率改善を地道に継続的に進めている話 / Continue to improve email delivery rates across multiple services
yamaguchitk333
6
2.2k
"うちにはまだ早い"は本当? ─ 小さく始めるPlatform Engineering入門
harukasakihara
7
640
そのSLO 99.9%、本当に必要ですか? 〜優先度付きSLOによる責任共有の設計思想〜 / Is that 99.9% SLO really necessary? Design philosophy of shared responsibility through prioritized SLOs
vtryo
0
830
Cortex(Code) を ML モデルの 精度改善サイクルに組み込む.pdf
oimo23
0
210
AI全盛の今だからこそ、あえてもう一度振り返るAPIの基礎
smt7174
3
130
その英語学習、AWSで代替できませんか?
suzutatsu
1
110
20260515 ログイン機能だけではないアカウント管理を全体で考える~サービス設計者向け~
oidfj
1
810
可視化から活用へ — Mesh化・Segmentation・アライメントの研究動向
gpuunite_official
0
230
アプリブロック機能のつくりかたと、AIとHTMLの不合理な相性の良さについて
kumamotone
1
260
Databricks 月刊サービスアップデートまとめ 2026年04月号
tyosi1212
0
130
論文紹介:Pixal3D (SIGGRAPH 2026)
tenten0727
0
470
実践 TanStack Start ― 新規プロダクトを開発して確立した、サーバーとクライアント境界の設計パターン / Practical TanStack Start Server-Client Boundary Patterns
kaminashi
1
100
Featured
See All Featured
Understanding Cognitive Biases in Performance Measurement
bluesmoon
32
2.9k
職位にかかわらず全員がリーダーシップを発揮するチーム作り / Building a team where everyone can demonstrate leadership regardless of position
madoxten
62
54k
Leveraging LLMs for student feedback in introductory data science courses - posit::conf(2025)
minecr
1
250
Dealing with People You Can't Stand - Big Design 2015
cassininazir
367
27k
Everyday Curiosity
cassininazir
0
210
Why You Should Never Use an ORM
jnunemaker
PRO
61
9.8k
Refactoring Trust on Your Teams (GOTO; Chicago 2020)
rmw
35
3.5k
Claude Code のすすめ
schroneko
67
220k
Ten Tips & Tricks for a 🌱 transition
stuffmc
0
110
Exploring the relationship between traditional SERPs and Gen AI search
raygrieselhuber
PRO
2
4k
How to Grow Your eCommerce with AI & Automation
katarinadahlin
PRO
1
180
16th Malabo Montpellier Forum Presentation
akademiya2063
PRO
0
120
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