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
Embed
Copy iframe code
Copy JS code
Copy link
Start on current slide
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
安全性・開発速度・ユーザー体験の あいだで考える 事業会社のプロダクトセキュリティ
mixi_engineers
PRO
0
110
EUDIWの枠組みを出発点に民間エコシステムの在り方を考える(OAuth/OIDC Numa (Immersion) Workshop 2026)
oidfj
PRO
0
120
Android skills に学ぶ
kokiko
0
170
1000⼈規模のClaude Enterprise運⽤を「Oktaのグループ」と「Slack」に集約する
sansantech
PRO
0
150
AI時代に、人は何を、どう学ぶのか #pbl_pub / What and How Do We Learn in the AI Era?
takaking22
1
250
Kiro Crew で始める マルチエージェント開発
miu_crescent
PRO
0
180
Data Hubグループ 紹介資料
sansan33
PRO
0
3.2k
VLMで2.3万枚のPyCon JP写真を検索!
terapyon
1
470
Introduction to Sansan, inc / Sansan Global Development Center, Inc.
sansan33
PRO
0
3.2k
巨大気象データと戦う ― サロゲートモデル学習を高速化する圧縮技術
gpuunite_official
0
260
AWS Blocks が楽しい #ゆるWeb札幌
tacck
PRO
0
140
Digitization部 紹介資料
sansan33
PRO
2
7.7k
Featured
See All Featured
Templates, Plugins, & Blocks: Oh My! Creating the theme that thinks of everything
marktimemedia
31
2.9k
Visual Storytelling: How to be a Superhuman Communicator
reverentgeek
2
620
Designing for Performance
lara
611
70k
What the history of the web can teach us about the future of AI
inesmontani
PRO
1
670
For a Future-Friendly Web
brad_frost
183
10k
Technical Leadership for Architectural Decision Making
baasie
3
530
JAMstack: Web Apps at Ludicrous Speed - All Things Open 2022
reverentgeek
1
580
Building AI with AI
inesmontani
PRO
1
1.2k
Navigating Team Friction
lara
192
16k
KATA
mclloyd
PRO
35
15k
How to Think Like a Performance Engineer
csswizardry
28
2.7k
Heart Work Chapter 1 - Part 1
lfama
PRO
8
36k
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