SlideShare ist ein Scribd-Unternehmen logo
1 von 25
Downloaden Sie, um offline zu lesen
DTrace and Perl
What is DTrace?
 DTrace is a comprehensive dynamic tracing
   framework for Solaris™ and Mac OS X™.


DTrace provides a powerful infrastructure to
   permit administrators, developers, and
    service personnel to concisely answer
 arbitrary questions about the behaviour of
  the operating system and user programs.
Problem: Debugging a Live System
Possible Approaches
         Userspace:
•        Ad-hoc logging
•           Log4perl
•           Debugger

        Kernel space:
•            strace
•            ltrace
•            truss
Or use DTrace...
#!/usr/sbin/dtrace -Zs
# pl_subcalls.d

#pragma D option quiet

dtrace:::BEGIN
{
   printf(quot;Tracing... Hit Ctrl-C to end.nquot;);
}

perl*:::sub-entry
{
   @subs[basename(copyinstr(arg1)), copyinstr(arg0)] = count();
}

dtrace:::END
{
   printf(quot; %-32s %-32s %8snquot;, quot;FILEquot;, quot;SUBquot;, quot;CALLSquot;);
   printa(quot; %-32s %-32s %@8dnquot;, @subs);
}
#!/usr/bin/perl

use strict;
use warnings;

sub fib {
    my $n = shift;
    return 1 if $n < 2;
    return fib( $n - 1 ) + fib( $n - 2 );
}

print fib( 12 );
FILE          SUB      CALLS
strict.pm     bits         1
strict.pm     import       1
warnings.pm   import       1
fib.pl        BEGIN        2
fib.pl        fib        465
DTrace is...

•Fast
•Unobtrusive
•Safe
Current Tools
DTrace
DTrace in Perl

•         In 5.11.0 now

•   Patch available for 5.10.0

•     Can patch older Perls

•     See also Devel::DTrace
Probes Available


•    Subroutine Entry

•     Subroutine Exit
Probes Possible

•    Regex Compilation

•        eval / die

•   Anything you like...
DTrace in Perl is fast
   ===========================( subs )=
   standard   | dtrace     | ratio
   ====================================
   2.64732909 | 2.55084610 | 0.96355459
   2.59817791 | 2.54752493 | 0.98050442
   2.62265491 | 2.53197598 | 0.96542476
   2.60479188 | 2.54577494 | 0.97734293
   2.58312511 | 2.54531789 | 0.98536377
   ====================================
   dtrace     | standard   | ratio
   ====================================
   2.55562115 | 2.61360312 | 0.97781531
   2.51933718 | 2.59808207 | 0.96969115
   2.51130199 | 2.61182499 | 0.96151235
   2.55779004 | 2.62898207 | 0.97292031
   2.54250908 | 2.60577297 | 0.97572164
   ====================================
DTrace Limitations

•     Perl stack traces

•         Perl data

•     Limited Platforms

•       Probe Effect
Where is DTrace?
          DTrace runs on:
  Solaris (including OpenSolaris)
          Mac OS (10.5 on)

DTrace could, but doesn’t, run on:
               Linux
              FreeBSD
              Windows
It’s OK:

 Linux has
SystemTap!
dtrace for Linux
  or something
     similar

(LIKE SYSTEMTAP?)
       - jdub
(NO, LIKE dtrace)
       - VLAD
 (like systemtap,
   but not crap)
Seen on a whiteboard at OSCON
quot;That's the difference
between a knockoff and
 the genuine article.quot;
  Adam Leventhal, DTrace developer, Sun
Who made DTrace?
Mike      Bryan     Adam
Shapiro   Cantrill Leventhal
Andy Armstrong
  andy@hexten.net
http://hexten.net/

Weitere ähnliche Inhalte

Andere mochten auch

BeingBed Job
BeingBed JobBeingBed Job
BeingBed Job
webtel
 
Have A Seat Plzzzzzzz
Have A Seat PlzzzzzzzHave A Seat Plzzzzzzz
Have A Seat Plzzzzzzz
webtel
 
Interesting Ads
Interesting AdsInteresting Ads
Interesting Ads
webtel
 
amazing photo
amazing photoamazing photo
amazing photo
webtel
 
Ce pleaca-se-si-intoarce
Ce pleaca-se-si-intoarceCe pleaca-se-si-intoarce
Ce pleaca-se-si-intoarce
VASILE Viorel
 
Becoming Invisible, Cool Camouflage!
Becoming Invisible, Cool Camouflage!Becoming Invisible, Cool Camouflage!
Becoming Invisible, Cool Camouflage!
webtel
 
Guess What Place It Is
Guess What Place It IsGuess What Place It Is
Guess What Place It Is
webtel
 
amazing
amazingamazing
amazing
webtel
 
Beautiful Picture
Beautiful PictureBeautiful Picture
Beautiful Picture
webtel
 
Bed Job
Bed JobBed Job
Bed Job
webtel
 
Lifes Tug Of War
Lifes Tug Of WarLifes Tug Of War
Lifes Tug Of War
webtel
 
Amazing Picture
Amazing PictureAmazing Picture
Amazing Picture
webtel
 
Beautiful Words Collection
Beautiful Words CollectionBeautiful Words Collection
Beautiful Words Collection
webtel
 
Only For You
Only For YouOnly For You
Only For You
webtel
 
Only In Tunisia
Only In TunisiaOnly In Tunisia
Only In Tunisia
webtel
 
Laloo Prasad Yadav
Laloo Prasad YadavLaloo Prasad Yadav
Laloo Prasad Yadav
webtel
 
The Amazing Art Of Dali
The Amazing Art Of DaliThe Amazing Art Of Dali
The Amazing Art Of Dali
webtel
 

Andere mochten auch (20)

BeingBed Job
BeingBed JobBeingBed Job
BeingBed Job
 
Have A Seat Plzzzzzzz
Have A Seat PlzzzzzzzHave A Seat Plzzzzzzz
Have A Seat Plzzzzzzz
 
Interesting Ads
Interesting AdsInteresting Ads
Interesting Ads
 
amazing photo
amazing photoamazing photo
amazing photo
 
Ce pleaca-se-si-intoarce
Ce pleaca-se-si-intoarceCe pleaca-se-si-intoarce
Ce pleaca-se-si-intoarce
 
Becoming Invisible, Cool Camouflage!
Becoming Invisible, Cool Camouflage!Becoming Invisible, Cool Camouflage!
Becoming Invisible, Cool Camouflage!
 
Guess What Place It Is
Guess What Place It IsGuess What Place It Is
Guess What Place It Is
 
Los reinos-cristianos1
Los reinos-cristianos1Los reinos-cristianos1
Los reinos-cristianos1
 
Curiosites 11
Curiosites 11Curiosites 11
Curiosites 11
 
amazing
amazingamazing
amazing
 
Beautiful Picture
Beautiful PictureBeautiful Picture
Beautiful Picture
 
Bed Job
Bed JobBed Job
Bed Job
 
Lifes Tug Of War
Lifes Tug Of WarLifes Tug Of War
Lifes Tug Of War
 
Amazing Picture
Amazing PictureAmazing Picture
Amazing Picture
 
Beautiful Words Collection
Beautiful Words CollectionBeautiful Words Collection
Beautiful Words Collection
 
Only For You
Only For YouOnly For You
Only For You
 
Only In Tunisia
Only In TunisiaOnly In Tunisia
Only In Tunisia
 
Amante
AmanteAmante
Amante
 
Laloo Prasad Yadav
Laloo Prasad YadavLaloo Prasad Yadav
Laloo Prasad Yadav
 
The Amazing Art Of Dali
The Amazing Art Of DaliThe Amazing Art Of Dali
The Amazing Art Of Dali
 

Ähnlich wie 20082501 Leeds Pm

It802 bruning
It802 bruningIt802 bruning
It802 bruning
mrbruning
 
DTrace - Miracle Scotland Database Forum
DTrace - Miracle Scotland Database ForumDTrace - Miracle Scotland Database Forum
DTrace - Miracle Scotland Database Forum
Doug Burns
 
Application of Radare2 Illustrated by Shylock and Snakso.A Analysis
Application of Radare2 Illustrated by Shylock and Snakso.A AnalysisApplication of Radare2 Illustrated by Shylock and Snakso.A Analysis
Application of Radare2 Illustrated by Shylock and Snakso.A Analysis
Positive Hack Days
 
D Trace Support In My Sql Guide To Solving Reallife Performance Problems
D Trace Support In My Sql Guide To Solving Reallife Performance ProblemsD Trace Support In My Sql Guide To Solving Reallife Performance Problems
D Trace Support In My Sql Guide To Solving Reallife Performance Problems
MySQLConference
 

Ähnlich wie 20082501 Leeds Pm (20)

It802 bruning
It802 bruningIt802 bruning
It802 bruning
 
DTrace Topics: Introduction
DTrace Topics: IntroductionDTrace Topics: Introduction
DTrace Topics: Introduction
 
Monitoring MySQL with DTrace/SystemTap
Monitoring MySQL with DTrace/SystemTapMonitoring MySQL with DTrace/SystemTap
Monitoring MySQL with DTrace/SystemTap
 
Lecture 6 Kernel Debugging + Ports Development
Lecture 6 Kernel Debugging + Ports DevelopmentLecture 6 Kernel Debugging + Ports Development
Lecture 6 Kernel Debugging + Ports Development
 
Debug generic process
Debug generic processDebug generic process
Debug generic process
 
Hotsos Advanced Linux Tools
Hotsos Advanced Linux ToolsHotsos Advanced Linux Tools
Hotsos Advanced Linux Tools
 
CodeQL + DTrace = Memory Disclosure Vulnerabilities in XNU
CodeQL + DTrace = Memory Disclosure Vulnerabilities in XNUCodeQL + DTrace = Memory Disclosure Vulnerabilities in XNU
CodeQL + DTrace = Memory Disclosure Vulnerabilities in XNU
 
Filippo, Plain simple reality of entropy
Filippo, Plain simple reality of  entropyFilippo, Plain simple reality of  entropy
Filippo, Plain simple reality of entropy
 
CONFidence 2015: DTrace + OSX = Fun - Andrzej Dyjak
CONFidence 2015: DTrace + OSX = Fun - Andrzej Dyjak   CONFidence 2015: DTrace + OSX = Fun - Andrzej Dyjak
CONFidence 2015: DTrace + OSX = Fun - Andrzej Dyjak
 
DTrace - Miracle Scotland Database Forum
DTrace - Miracle Scotland Database ForumDTrace - Miracle Scotland Database Forum
DTrace - Miracle Scotland Database Forum
 
Osol Pgsql
Osol PgsqlOsol Pgsql
Osol Pgsql
 
Solaris DTrace, An Introduction
Solaris DTrace, An IntroductionSolaris DTrace, An Introduction
Solaris DTrace, An Introduction
 
Ceph Day Melbourne - Troubleshooting Ceph
Ceph Day Melbourne - Troubleshooting Ceph Ceph Day Melbourne - Troubleshooting Ceph
Ceph Day Melbourne - Troubleshooting Ceph
 
A22 Introduction to DTrace by Kyle Hailey
A22 Introduction to DTrace by Kyle HaileyA22 Introduction to DTrace by Kyle Hailey
A22 Introduction to DTrace by Kyle Hailey
 
Application of Radare2 Illustrated by Shylock and Snakso.A Analysis
Application of Radare2 Illustrated by Shylock and Snakso.A AnalysisApplication of Radare2 Illustrated by Shylock and Snakso.A Analysis
Application of Radare2 Illustrated by Shylock and Snakso.A Analysis
 
MINCS - containers in the shell script (Eng. ver.)
MINCS - containers in the shell script (Eng. ver.)MINCS - containers in the shell script (Eng. ver.)
MINCS - containers in the shell script (Eng. ver.)
 
D Trace Support In My Sql Guide To Solving Reallife Performance Problems
D Trace Support In My Sql Guide To Solving Reallife Performance ProblemsD Trace Support In My Sql Guide To Solving Reallife Performance Problems
D Trace Support In My Sql Guide To Solving Reallife Performance Problems
 
FreeBSD 2014 Flame Graphs
FreeBSD 2014 Flame GraphsFreeBSD 2014 Flame Graphs
FreeBSD 2014 Flame Graphs
 
Scaling IO-bound microservices
Scaling IO-bound microservicesScaling IO-bound microservices
Scaling IO-bound microservices
 
Metasploitable
MetasploitableMetasploitable
Metasploitable
 

Kürzlich hochgeladen

Histor y of HAM Radio presentation slide
Histor y of HAM Radio presentation slideHistor y of HAM Radio presentation slide
Histor y of HAM Radio presentation slide
vu2urc
 
Artificial Intelligence: Facts and Myths
Artificial Intelligence: Facts and MythsArtificial Intelligence: Facts and Myths
Artificial Intelligence: Facts and Myths
Joaquim Jorge
 

Kürzlich hochgeladen (20)

Histor y of HAM Radio presentation slide
Histor y of HAM Radio presentation slideHistor y of HAM Radio presentation slide
Histor y of HAM Radio presentation slide
 
Boost PC performance: How more available memory can improve productivity
Boost PC performance: How more available memory can improve productivityBoost PC performance: How more available memory can improve productivity
Boost PC performance: How more available memory can improve productivity
 
Factors to Consider When Choosing Accounts Payable Services Providers.pptx
Factors to Consider When Choosing Accounts Payable Services Providers.pptxFactors to Consider When Choosing Accounts Payable Services Providers.pptx
Factors to Consider When Choosing Accounts Payable Services Providers.pptx
 
How to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected WorkerHow to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected Worker
 
04-2024-HHUG-Sales-and-Marketing-Alignment.pptx
04-2024-HHUG-Sales-and-Marketing-Alignment.pptx04-2024-HHUG-Sales-and-Marketing-Alignment.pptx
04-2024-HHUG-Sales-and-Marketing-Alignment.pptx
 
A Call to Action for Generative AI in 2024
A Call to Action for Generative AI in 2024A Call to Action for Generative AI in 2024
A Call to Action for Generative AI in 2024
 
A Year of the Servo Reboot: Where Are We Now?
A Year of the Servo Reboot: Where Are We Now?A Year of the Servo Reboot: Where Are We Now?
A Year of the Servo Reboot: Where Are We Now?
 
Artificial Intelligence: Facts and Myths
Artificial Intelligence: Facts and MythsArtificial Intelligence: Facts and Myths
Artificial Intelligence: Facts and Myths
 
08448380779 Call Girls In Friends Colony Women Seeking Men
08448380779 Call Girls In Friends Colony Women Seeking Men08448380779 Call Girls In Friends Colony Women Seeking Men
08448380779 Call Girls In Friends Colony Women Seeking Men
 
What Are The Drone Anti-jamming Systems Technology?
What Are The Drone Anti-jamming Systems Technology?What Are The Drone Anti-jamming Systems Technology?
What Are The Drone Anti-jamming Systems Technology?
 
[2024]Digital Global Overview Report 2024 Meltwater.pdf
[2024]Digital Global Overview Report 2024 Meltwater.pdf[2024]Digital Global Overview Report 2024 Meltwater.pdf
[2024]Digital Global Overview Report 2024 Meltwater.pdf
 
From Event to Action: Accelerate Your Decision Making with Real-Time Automation
From Event to Action: Accelerate Your Decision Making with Real-Time AutomationFrom Event to Action: Accelerate Your Decision Making with Real-Time Automation
From Event to Action: Accelerate Your Decision Making with Real-Time Automation
 
Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...
Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...
Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...
 
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
 
Breaking the Kubernetes Kill Chain: Host Path Mount
Breaking the Kubernetes Kill Chain: Host Path MountBreaking the Kubernetes Kill Chain: Host Path Mount
Breaking the Kubernetes Kill Chain: Host Path Mount
 
The Codex of Business Writing Software for Real-World Solutions 2.pptx
The Codex of Business Writing Software for Real-World Solutions 2.pptxThe Codex of Business Writing Software for Real-World Solutions 2.pptx
The Codex of Business Writing Software for Real-World Solutions 2.pptx
 
Real Time Object Detection Using Open CV
Real Time Object Detection Using Open CVReal Time Object Detection Using Open CV
Real Time Object Detection Using Open CV
 
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
 
Scaling API-first – The story of a global engineering organization
Scaling API-first – The story of a global engineering organizationScaling API-first – The story of a global engineering organization
Scaling API-first – The story of a global engineering organization
 
Data Cloud, More than a CDP by Matt Robison
Data Cloud, More than a CDP by Matt RobisonData Cloud, More than a CDP by Matt Robison
Data Cloud, More than a CDP by Matt Robison
 

20082501 Leeds Pm

  • 2. What is DTrace? DTrace is a comprehensive dynamic tracing framework for Solaris™ and Mac OS X™. DTrace provides a powerful infrastructure to permit administrators, developers, and service personnel to concisely answer arbitrary questions about the behaviour of the operating system and user programs.
  • 3. Problem: Debugging a Live System
  • 4. Possible Approaches Userspace: • Ad-hoc logging • Log4perl • Debugger Kernel space: • strace • ltrace • truss
  • 6. #!/usr/sbin/dtrace -Zs # pl_subcalls.d #pragma D option quiet dtrace:::BEGIN { printf(quot;Tracing... Hit Ctrl-C to end.nquot;); } perl*:::sub-entry { @subs[basename(copyinstr(arg1)), copyinstr(arg0)] = count(); } dtrace:::END { printf(quot; %-32s %-32s %8snquot;, quot;FILEquot;, quot;SUBquot;, quot;CALLSquot;); printa(quot; %-32s %-32s %@8dnquot;, @subs); }
  • 7. #!/usr/bin/perl use strict; use warnings; sub fib { my $n = shift; return 1 if $n < 2; return fib( $n - 1 ) + fib( $n - 2 ); } print fib( 12 );
  • 8. FILE SUB CALLS strict.pm bits 1 strict.pm import 1 warnings.pm import 1 fib.pl BEGIN 2 fib.pl fib 465
  • 12. DTrace in Perl • In 5.11.0 now • Patch available for 5.10.0 • Can patch older Perls • See also Devel::DTrace
  • 13. Probes Available • Subroutine Entry • Subroutine Exit
  • 14. Probes Possible • Regex Compilation • eval / die • Anything you like...
  • 15. DTrace in Perl is fast ===========================( subs )= standard | dtrace | ratio ==================================== 2.64732909 | 2.55084610 | 0.96355459 2.59817791 | 2.54752493 | 0.98050442 2.62265491 | 2.53197598 | 0.96542476 2.60479188 | 2.54577494 | 0.97734293 2.58312511 | 2.54531789 | 0.98536377 ==================================== dtrace | standard | ratio ==================================== 2.55562115 | 2.61360312 | 0.97781531 2.51933718 | 2.59808207 | 0.96969115 2.51130199 | 2.61182499 | 0.96151235 2.55779004 | 2.62898207 | 0.97292031 2.54250908 | 2.60577297 | 0.97572164 ====================================
  • 16. DTrace Limitations • Perl stack traces • Perl data • Limited Platforms • Probe Effect
  • 17. Where is DTrace? DTrace runs on: Solaris (including OpenSolaris) Mac OS (10.5 on) DTrace could, but doesn’t, run on: Linux FreeBSD Windows
  • 18. It’s OK: Linux has SystemTap!
  • 19. dtrace for Linux or something similar (LIKE SYSTEMTAP?) - jdub (NO, LIKE dtrace) - VLAD (like systemtap, but not crap) Seen on a whiteboard at OSCON
  • 20. quot;That's the difference between a knockoff and the genuine article.quot; Adam Leventhal, DTrace developer, Sun
  • 22.
  • 23.
  • 24. Mike Bryan Adam Shapiro Cantrill Leventhal
  • 25. Andy Armstrong andy@hexten.net http://hexten.net/