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
·
SiteGround - Reliable hosting with speed, security, and support you can count on.
→
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
システムのアラート調査をサポートするAI Agentの紹介/Introduction to an AI Agent for System Alert Investigation
taddy_919
2
1.9k
レガシー共有バッチ基盤への挑戦 - SREドリブンなリアーキテクチャリングの取り組み
tatsukoni
0
200
SREじゃなかった僕らがenablingを通じて「SRE実践者」になるまでのリアル / SRE Kaigi 2026
aeonpeople
6
2.1k
茨城の思い出を振り返る ~CDKのセキュリティを添えて~ / 20260201 Mitsutoshi Matsuo
shift_evolve
PRO
1
190
制約が導く迷わない設計 〜 信頼性と運用性を両立するマイナンバー管理システムの実践 〜
bwkw
3
870
日本語テキストと音楽の対照学習の技術とその応用
lycorptech_jp
PRO
1
420
Context Engineeringが企業で不可欠になる理由
hirosatogamo
PRO
3
410
セキュリティについて学ぶ会 / 2026 01 25 Takamatsu WordPress Meetup
rocketmartue
1
290
~Everything as Codeを諦めない~ 後からCDK
mu7889yoon
3
270
10Xにおける品質保証活動の全体像と改善 #no_more_wait_for_test
nihonbuson
PRO
2
200
Databricks Free Edition講座 データサイエンス編
taka_aki
0
290
ZOZOにおけるAI活用の現在 ~開発組織全体での取り組みと試行錯誤~
zozotech
PRO
5
4.9k
Featured
See All Featured
Creating an realtime collaboration tool: Agile Flush - .NET Oxford
marcduiker
35
2.4k
Building the Perfect Custom Keyboard
takai
2
680
Facilitating Awesome Meetings
lara
57
6.7k
Save Time (by Creating Custom Rails Generators)
garrettdimon
PRO
32
2k
How Fast Is Fast Enough? [PerfNow 2025]
tammyeverts
3
450
Exploring the Power of Turbo Streams & Action Cable | RailsConf2023
kevinliebholz
37
6.3k
How Software Deployment tools have changed in the past 20 years
geshan
0
32k
So, you think you're a good person
axbom
PRO
2
1.9k
世界の人気アプリ100個を分析して見えたペイウォール設計の心得
akihiro_kokubo
PRO
66
36k
Distributed Sagas: A Protocol for Coordinating Microservices
caitiem20
333
22k
Digital Projects Gone Horribly Wrong (And the UX Pros Who Still Save the Day) - Dean Schuster
uxyall
0
300
Java REST API Framework Comparison - PWX 2021
mraible
34
9.1k
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