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
Learning Dtrace
Search
Outsider
November 21, 2012
Technology
2
3.2k
Learning Dtrace
Presentation at play.node() 2012
Outsider
November 21, 2012
Tweet
Share
More Decks by Outsider
See All by Outsider
GitHub Actions의 다양한 기능 활용하기 - GitHub Universe '24 Recap
outsider
0
840
당근 개발자 플랫폼은 어떤 문제를 해결하고 있는가?
outsider
1
3.3k
오픈소스에 기여할 때 알면 좋을 개발 프로세스
outsider
0
1.7k
DevOps를 가속화하는 플랫폼 엔지니어링
outsider
0
3.7k
클라우드 시대에 맞는 사이트 신뢰성 엔지니어
outsider
0
1.5k
디자인에 이어 코딩까지 AI가 프로그램 개발을 척척? : GitHub Copilot, 어디까지 알아보셨나요
outsider
0
1.5k
Citizen 개발기
outsider
0
940
오픈소스 뒤에 메인테이너 있어요
outsider
0
100
오픈소스에 기여할 때 해도 되는 일과 하면 안되는 일
outsider
0
80
Other Decks in Technology
See All in Technology
スクラムというコンフォートゾーンから抜け出そう!プロジェクト全体に目を向けるインセプションデッキ / Inception Deck for seeing the whole project
takaking22
3
150
JAWS DAYS 2025 アーキテクチャ道場 事前説明会 / JAWS DAYS 2025 briefing document
naospon
0
2.8k
DeepSeekとは?何がいいの? - Databricksと学ぶDeepSeek! 〜これからのLLMに備えよ!〜
taka_aki
1
180
【Snowflake九州ユーザー会#2】BigQueryとSnowflakeを比較してそれぞれの良し悪しを掴む / BigQuery vs Snowflake: Pros & Cons
civitaspo
2
660
LayerXにおけるAI活用事例とその裏側(2025年2月) バクラクの目指す “業務の自動運転” の例 / layerx-ai-deim2025
yuya4
2
600
マーケットプレイス版Oracle WebCenter Content For OCI
oracle4engineer
PRO
3
540
完璧を捨てろ! “攻め”のQAがもたらすスピードと革新/20250306 Hiroki Hachisuka
shift_evolve
0
100
プロダクト開発者目線での Entra ID 活用
sansantech
PRO
0
130
Exadata Database Service on Cloud@Customer セキュリティ、ネットワーク、および管理について
oracle4engineer
PRO
2
1.6k
MLflowはどのようにLLMOpsの課題を解決するのか
taka_aki
0
130
OCI Success Journey OCIの何が評価されてる?疑問に答える事例セミナー(2025年2月実施)
oracle4engineer
PRO
2
220
あなたが人生で成功するための5つの普遍的法則 #jawsug #jawsdays2025 / 20250301 HEROZ
yoshidashingo
2
360
Featured
See All Featured
Building Your Own Lightsaber
phodgson
104
6.2k
Understanding Cognitive Biases in Performance Measurement
bluesmoon
27
1.6k
Building a Modern Day E-commerce SEO Strategy
aleyda
38
7.1k
The Success of Rails: Ensuring Growth for the Next 100 Years
eileencodes
44
7.1k
What’s in a name? Adding method to the madness
productmarketing
PRO
22
3.3k
Optimizing for Happiness
mojombo
377
70k
Gamification - CAS2011
davidbonilla
80
5.2k
The Myth of the Modular Monolith - Day 2 Keynote - Rails World 2024
eileencodes
21
2.5k
Documentation Writing (for coders)
carmenintech
68
4.6k
The Art of Programming - Codeland 2020
erikaheidi
53
13k
Build your cross-platform service in a week with App Engine
jlugia
229
18k
Raft: Consensus for Rubyists
vanstee
137
6.8k
Transcript
Learning Dtrace 2012.11.20 Outsider at
DTrace is a comprehensive dynamic tracing framework created by Sun
Microsystems for troubleshooting kernel and application problems on production systems in real time. http://dtrace.org/blogs/about/dtracepony/
DTrace is a comprehensive dynamic tracing framework created by Sun
Microsystems for troubleshooting kernel and application problems on production systems in real time. http://dtrace.org/blogs/about/dtracepony/
DTrace is a comprehensive dynamic tracing framework created by Sun
Microsystems for troubleshooting kernel and application problems on production systems in real time. http://dtrace.org/blogs/about/dtracepony/
DTrace is a comprehensive dynamic tracing framework created by Sun
Microsystems for troubleshooting kernel and application problems on production systems in real time. http://dtrace.org/blogs/about/dtracepony/
DTrace is a comprehensive dynamic tracing framework created by Sun
Microsystems for troubleshooting kernel and application problems on production systems in real time. http://dtrace.org/blogs/about/dtracepony/
http://www.flickr.com/photos/ghost_of_kuji/370072145 Bryan Cantrill Mike Shapiro Adam Leventhal
Originally developed for 2003
Open-sourced in 2005 http://www.flickr.com/photos/tinou/171803338
http://www.flickr.com/photos/epu/4299657320 Ported to Unix-like systems
MIT Technology Review 2005 “Innovators Under 35” http://www2.technologyreview.com/tr35/profile.aspx?trid=91
Technology Innovation Awards 2006 Gold Winner http://www.dowjones.com/innovation/ei_winners_2006.html
STUG award 2008 https://www.usenix.org/about/stug
Dive into Dtrace
None
٘о प೯غח زਵ۽ ࢤࢿ ۽؋࣌ীࢲ ࢎਊоמ Probe
Probe List: sudo dtrace -l
Probe ղࠗ ID
Probeܳ ઁҕೞח Ҕ (ex: syscall, profile)
Unix ݽٕա Probe যܻா࣌ ۄ࠳۞ܻ ܴ
Probeо ઓೞח ೣࣻ ܴ
Probe ܴ
sudo dtrace -l -n PROBEܴ
sudo dtrace -l -f FUNCTION
sudo dtrace -l -P PROVIDER
sudo dtrace -l -m MODULE
DScript D Programming Language
.d ഛ ஹੌ೧ࢲ ழօۨ߰ীࢲ प೯ উࢿਸ ਤೠ ਬബࢿ Ѩࢎ ۽؋࣌ীࢲ
উೞѱ प೯ Features
DScript Kernel User DProgram Output Dtrace
probe-description /optional predicate/ { action statements; } 01 02 03
04 05
probe-description /optional predicate/ { action statements; } 01 02 03
04 05 provider:module:function:name (ex: syscall:::entry)
probe-description /optional predicate/ { action statements; } 01 02 03
04 05 दझమ ࢚కܳ ࣻೞח ݺ۸ޙ
probe-description /optional predicate/ { action statements; } 01 02 03
04 05 0 ইפѢա trueݶ action ࣻ೯
begin-end.d BEGIN { trace("begin the beguine"); exit(0); } END {
trace("that's all..."); } 01 02 03 04 05 06 07 08 09
begin-end.d BEGIN { trace("begin the beguine"); exit(0); } END {
trace("that's all..."); } 01 02 03 04 05 06 07 08 09 sudo dtrace -s begin-end.d
timer.d profile:::tick-5sec { trace("5sec timer"); } profile:::tick-800msec { trace("800msec timer");
} 01 02 03 04 05 06 07 08
beer.d int bottles; BEGIN { bottles = 5; } profile:::tick-1sec
/bottles >= 0/ { printf("%d bottles on the wall\n", bottles); printf("%d bottles.\n", bottles); printf("take one down, pass it around\n"); printf("%d bottles on the wall\n\n", bottles); bottles--; } profile:::tick-1sec /bottles < 0/ { exit(0); } END { printf("that's all..."); } 01 02 03 04 05 06 07 08 09 10 11 12 13 14 15 16 17
no if-else no loop ?: operator is exist No Flow
Control
process.d proc:::exec-success { printf("%s", execname); } 01 02 03 04
@: aggregation’s prefix name: aggregation’s name key: D expression list
(comma-separated) aggfunc: aggregation function Aggregate @name[key] = aggfunc(args)
count() : ഐപࣻ sum(expr) : അध ч avg(expr) :
അध ಣӐ min(expr) : അध о ч max(expr) : അध о ч quantize(expr) : 2ઁғ ࠼ب࠙ನ lquantize(expr,lower-bound, upper- bound, step-value) : ࢶഋ ࠼ب࠙ನ Aggregate Function
aggr-count.d syscall::read:entry { @counts[execname] = count(); } profile:::tick-5s { exit(0);
} 01 02 03 04 05 06 07 08
aggr-quant.d syscall::read:entry { self->ts = timestamp; } syscall::read:return /self->ts/ {
delta = timestamp - self->ts; @quanttime[execname] = quantize(delta); } profile:::tick-5s { exit(0); } 01 02 03 04 05 06 07 08 09 10 11 12 13 14
Dtrace with Node.js
http://www.flickr.com/photos/abandonedhero/3404826467 OS Requirements -Dtrace -ustack helper
USDT User-Level Statically Defined Tracing landed in node v0.6.7
http://www.flickr.com/photos/jepoirrier/2043728206 Full features work on OpenSolaris
Mac OS Dtrace ustack helper
Linux Dtrace ustack helper
Windows Dtrace ustack helper
http://www.flickr.com/photos/vectorlyme/206472613 node.js is compiled with --with-dtrace
“SunOSীࢲ ഝࢿചغ݅ ܲ दझమীࢶ زೞ ঋח”
Dtrace with node.js on SmartOS of Joyent Demo
server.js var http = require('http'); http.createServer(function(req, res) { res.writeHead(200, {
'Content-Type': 'text/plain' }); res.end('Hello World\n'); }).listen(8124); console.log('Server running!'); 01 02 03 04 05 06 07 08 09
http-server.d BEGIN { printf("%7s %2s %5s %20s (%5s) %8s %s
(%s)\n", "WHO", "FD", "RPORT", "REMOTE", "BUFFR", "METHOD", "URL", "FWDFOR"); } node*:::http-server-request { printf("+SERVER %2d %5d %20s (%5d) %8s %s (%s)\n", args[1]->fd, args[1]->remotePort, args[1]->remoteAddress, args[1]->bufferSize, args[0]->method, args[0]->url, args[0]->forwardedFor); } node*:::http-server-response { printf("-SERVER %2d %5d %20s (%5d)\n", args[0]->fd, args[0]->remotePort, args[0]->remoteAddress, args[0]->bufferSize); } 01 02 03 04 05 06 07 08 09 10 11 12 13 14 15 16 17 18 19 20 21
request-count.d http-server-request { @[args[0]->url]=count() } 01 02 03 04
loop.js new Error().stack; function main() { func1(); } function func1()
{ func2(); } function func2() { (function () { for (;;); })(); } main(); 01 02 03 04 05 06 07 08 09 10 11
profile.d profile-97 /execname == "node" && arg1/ { @[jstack(150, 8000)]
= count(); } tick-10sec { exit(0); } 01 02 03 04 05 06 07 08 09
FlameGraph stack trace visualizer
http://dtrace.org/blogs/brendan/files/2011/12/mysql-flame.png
node-stackvis $ npm install -g stackvis
$ sudo dtrace -s DSCRIPT > INPUT $ stackvis dtrace
flamegraph-svg < INPUT > OUTPUT Make FrameGraph
Alternative on non-OpenSolarises
node-dtrace-provider https://github.com/chrisa/node-dtrace-provider $ npm install dtrace-provider
var d = require('dtrace-provider'); var dtp = d.createDTraceProvider('nodeapp'); var p1
= dtp.addProbe('probe1', 'int', 'int'); var p2 = dtp.addProbe('probe2', 'char *'); dtp.enable(); 01 02 03 04 05
dtp.fire("probe1", function(p) { return [1, 2]; }); dtp.fire("probe2", function(p) {
return ["hello, dtrace via provider", "foo"]; }); 01 02 03 04 05 06
data type : int, char maximum argument : 32 Limitations
interval.js function interval(msg) { console.log(msg); } setInterval(function() { interval('Hello Dtrace');
}, 1000); 01 02 03 04 05 06 07
interval.js interval.js var d = require('dtrace-provider'); var dtp = d.createDTraceProvider('nodeapp');
var p2 = dtp.addProbe('echo', 'char *'); function interval(msg) { dtp.fire('echo', function () { return [msg]; }); console.log(msg); } setInterval(function() { interval('Hello Dtrace'); }, 1000); dtp.enable(); 01 02 03 04 05 06 07 08 09 10 11 12 13 14 15
interval.d nodeapp*:::echo { trace(copyinstr(arg0)); } 01 02 03 04
Thank you~ http://blog.outsider.ne.kr
[email protected]
@outsideris