SlideShare a Scribd company logo
1 of 25
Download to read offline
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/

More Related Content

Viewers also liked

BeingBed Job
BeingBed JobBeingBed Job
BeingBed Jobwebtel
 
Have A Seat Plzzzzzzz
Have A Seat PlzzzzzzzHave A Seat Plzzzzzzz
Have A Seat Plzzzzzzzwebtel
 
Interesting Ads
Interesting AdsInteresting Ads
Interesting Adswebtel
 
amazing photo
amazing photoamazing photo
amazing photowebtel
 
Ce pleaca-se-si-intoarce
Ce pleaca-se-si-intoarceCe pleaca-se-si-intoarce
Ce pleaca-se-si-intoarceVASILE 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 Iswebtel
 
amazing
amazingamazing
amazingwebtel
 
Beautiful Picture
Beautiful PictureBeautiful Picture
Beautiful Picturewebtel
 
Bed Job
Bed JobBed Job
Bed Jobwebtel
 
Lifes Tug Of War
Lifes Tug Of WarLifes Tug Of War
Lifes Tug Of Warwebtel
 
Amazing Picture
Amazing PictureAmazing Picture
Amazing Picturewebtel
 
Beautiful Words Collection
Beautiful Words CollectionBeautiful Words Collection
Beautiful Words Collectionwebtel
 
Only For You
Only For YouOnly For You
Only For Youwebtel
 
Only In Tunisia
Only In TunisiaOnly In Tunisia
Only In Tunisiawebtel
 
Laloo Prasad Yadav
Laloo Prasad YadavLaloo Prasad Yadav
Laloo Prasad Yadavwebtel
 
The Amazing Art Of Dali
The Amazing Art Of DaliThe Amazing Art Of Dali
The Amazing Art Of Daliwebtel
 

Viewers also liked (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
 

Similar to 20082501 Leeds Pm

It802 bruning
It802 bruningIt802 bruning
It802 bruningmrbruning
 
DTrace Topics: Introduction
DTrace Topics: IntroductionDTrace Topics: Introduction
DTrace Topics: IntroductionBrendan Gregg
 
Monitoring MySQL with DTrace/SystemTap
Monitoring MySQL with DTrace/SystemTapMonitoring MySQL with DTrace/SystemTap
Monitoring MySQL with DTrace/SystemTapPadraig O'Sullivan
 
Lecture 6 Kernel Debugging + Ports Development
Lecture 6 Kernel Debugging + Ports DevelopmentLecture 6 Kernel Debugging + Ports Development
Lecture 6 Kernel Debugging + Ports DevelopmentMohammed Farrag
 
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 XNUArsenii Kostromin
 
Filippo, Plain simple reality of entropy
Filippo, Plain simple reality of  entropyFilippo, Plain simple reality of  entropy
Filippo, Plain simple reality of entropyPacSecJP
 
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 PROIDEA
 
DTrace - Miracle Scotland Database Forum
DTrace - Miracle Scotland Database ForumDTrace - Miracle Scotland Database Forum
DTrace - Miracle Scotland Database ForumDoug Burns
 
Solaris DTrace, An Introduction
Solaris DTrace, An IntroductionSolaris DTrace, An Introduction
Solaris DTrace, An Introductionsatyajit_t
 
Ceph Day Melbourne - Troubleshooting Ceph
Ceph Day Melbourne - Troubleshooting Ceph Ceph Day Melbourne - Troubleshooting Ceph
Ceph Day Melbourne - Troubleshooting Ceph Ceph Community
 
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 AnalysisPositive Hack Days
 
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.)Masami Hiramatsu
 
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 ProblemsMySQLConference
 
FreeBSD 2014 Flame Graphs
FreeBSD 2014 Flame GraphsFreeBSD 2014 Flame Graphs
FreeBSD 2014 Flame GraphsBrendan Gregg
 
Scaling IO-bound microservices
Scaling IO-bound microservicesScaling IO-bound microservices
Scaling IO-bound microservicesSalo Shp
 

Similar to 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
 

Recently uploaded

Abdul Kader Baba- Managing Cybersecurity Risks and Compliance Requirements i...
Abdul Kader Baba- Managing Cybersecurity Risks  and Compliance Requirements i...Abdul Kader Baba- Managing Cybersecurity Risks  and Compliance Requirements i...
Abdul Kader Baba- Managing Cybersecurity Risks and Compliance Requirements i...itnewsafrica
 
Bridging Between CAD & GIS: 6 Ways to Automate Your Data Integration
Bridging Between CAD & GIS:  6 Ways to Automate Your Data IntegrationBridging Between CAD & GIS:  6 Ways to Automate Your Data Integration
Bridging Between CAD & GIS: 6 Ways to Automate Your Data Integrationmarketing932765
 
QMMS Lesson 2 - Using MS Excel Formula.pdf
QMMS Lesson 2 - Using MS Excel Formula.pdfQMMS Lesson 2 - Using MS Excel Formula.pdf
QMMS Lesson 2 - Using MS Excel Formula.pdfROWELL MARQUINA
 
React JS; all concepts. Contains React Features, JSX, functional & Class comp...
React JS; all concepts. Contains React Features, JSX, functional & Class comp...React JS; all concepts. Contains React Features, JSX, functional & Class comp...
React JS; all concepts. Contains React Features, JSX, functional & Class comp...Karmanjay Verma
 
Top 10 Hubspot Development Companies in 2024
Top 10 Hubspot Development Companies in 2024Top 10 Hubspot Development Companies in 2024
Top 10 Hubspot Development Companies in 2024TopCSSGallery
 
A Glance At The Java Performance Toolbox
A Glance At The Java Performance ToolboxA Glance At The Java Performance Toolbox
A Glance At The Java Performance ToolboxAna-Maria Mihalceanu
 
Infrared simulation and processing on Nvidia platforms
Infrared simulation and processing on Nvidia platformsInfrared simulation and processing on Nvidia platforms
Infrared simulation and processing on Nvidia platformsYoss Cohen
 
UiPath Community: Communication Mining from Zero to Hero
UiPath Community: Communication Mining from Zero to HeroUiPath Community: Communication Mining from Zero to Hero
UiPath Community: Communication Mining from Zero to HeroUiPathCommunity
 
Microsoft 365 Copilot: How to boost your productivity with AI – Part one: Ado...
Microsoft 365 Copilot: How to boost your productivity with AI – Part one: Ado...Microsoft 365 Copilot: How to boost your productivity with AI – Part one: Ado...
Microsoft 365 Copilot: How to boost your productivity with AI – Part one: Ado...Nikki Chapple
 
Transcript: New from BookNet Canada for 2024: BNC SalesData and LibraryData -...
Transcript: New from BookNet Canada for 2024: BNC SalesData and LibraryData -...Transcript: New from BookNet Canada for 2024: BNC SalesData and LibraryData -...
Transcript: New from BookNet Canada for 2024: BNC SalesData and LibraryData -...BookNet Canada
 
MuleSoft Online Meetup Group - B2B Crash Course: Release SparkNotes
MuleSoft Online Meetup Group - B2B Crash Course: Release SparkNotesMuleSoft Online Meetup Group - B2B Crash Course: Release SparkNotes
MuleSoft Online Meetup Group - B2B Crash Course: Release SparkNotesManik S Magar
 
2024 April Patch Tuesday
2024 April Patch Tuesday2024 April Patch Tuesday
2024 April Patch TuesdayIvanti
 
Glenn Lazarus- Why Your Observability Strategy Needs Security Observability
Glenn Lazarus- Why Your Observability Strategy Needs Security ObservabilityGlenn Lazarus- Why Your Observability Strategy Needs Security Observability
Glenn Lazarus- Why Your Observability Strategy Needs Security Observabilityitnewsafrica
 
How to Effectively Monitor SD-WAN and SASE Environments with ThousandEyes
How to Effectively Monitor SD-WAN and SASE Environments with ThousandEyesHow to Effectively Monitor SD-WAN and SASE Environments with ThousandEyes
How to Effectively Monitor SD-WAN and SASE Environments with ThousandEyesThousandEyes
 
Connecting the Dots for Information Discovery.pdf
Connecting the Dots for Information Discovery.pdfConnecting the Dots for Information Discovery.pdf
Connecting the Dots for Information Discovery.pdfNeo4j
 
React Native vs Ionic - The Best Mobile App Framework
React Native vs Ionic - The Best Mobile App FrameworkReact Native vs Ionic - The Best Mobile App Framework
React Native vs Ionic - The Best Mobile App FrameworkPixlogix Infotech
 
Assure Ecommerce and Retail Operations Uptime with ThousandEyes
Assure Ecommerce and Retail Operations Uptime with ThousandEyesAssure Ecommerce and Retail Operations Uptime with ThousandEyes
Assure Ecommerce and Retail Operations Uptime with ThousandEyesThousandEyes
 
Accelerating Enterprise Software Engineering with Platformless
Accelerating Enterprise Software Engineering with PlatformlessAccelerating Enterprise Software Engineering with Platformless
Accelerating Enterprise Software Engineering with PlatformlessWSO2
 
Digital Tools & AI in Career Development
Digital Tools & AI in Career DevelopmentDigital Tools & AI in Career Development
Digital Tools & AI in Career DevelopmentMahmoud Rabie
 

Recently uploaded (20)

Abdul Kader Baba- Managing Cybersecurity Risks and Compliance Requirements i...
Abdul Kader Baba- Managing Cybersecurity Risks  and Compliance Requirements i...Abdul Kader Baba- Managing Cybersecurity Risks  and Compliance Requirements i...
Abdul Kader Baba- Managing Cybersecurity Risks and Compliance Requirements i...
 
Bridging Between CAD & GIS: 6 Ways to Automate Your Data Integration
Bridging Between CAD & GIS:  6 Ways to Automate Your Data IntegrationBridging Between CAD & GIS:  6 Ways to Automate Your Data Integration
Bridging Between CAD & GIS: 6 Ways to Automate Your Data Integration
 
QMMS Lesson 2 - Using MS Excel Formula.pdf
QMMS Lesson 2 - Using MS Excel Formula.pdfQMMS Lesson 2 - Using MS Excel Formula.pdf
QMMS Lesson 2 - Using MS Excel Formula.pdf
 
How Tech Giants Cut Corners to Harvest Data for A.I.
How Tech Giants Cut Corners to Harvest Data for A.I.How Tech Giants Cut Corners to Harvest Data for A.I.
How Tech Giants Cut Corners to Harvest Data for A.I.
 
React JS; all concepts. Contains React Features, JSX, functional & Class comp...
React JS; all concepts. Contains React Features, JSX, functional & Class comp...React JS; all concepts. Contains React Features, JSX, functional & Class comp...
React JS; all concepts. Contains React Features, JSX, functional & Class comp...
 
Top 10 Hubspot Development Companies in 2024
Top 10 Hubspot Development Companies in 2024Top 10 Hubspot Development Companies in 2024
Top 10 Hubspot Development Companies in 2024
 
A Glance At The Java Performance Toolbox
A Glance At The Java Performance ToolboxA Glance At The Java Performance Toolbox
A Glance At The Java Performance Toolbox
 
Infrared simulation and processing on Nvidia platforms
Infrared simulation and processing on Nvidia platformsInfrared simulation and processing on Nvidia platforms
Infrared simulation and processing on Nvidia platforms
 
UiPath Community: Communication Mining from Zero to Hero
UiPath Community: Communication Mining from Zero to HeroUiPath Community: Communication Mining from Zero to Hero
UiPath Community: Communication Mining from Zero to Hero
 
Microsoft 365 Copilot: How to boost your productivity with AI – Part one: Ado...
Microsoft 365 Copilot: How to boost your productivity with AI – Part one: Ado...Microsoft 365 Copilot: How to boost your productivity with AI – Part one: Ado...
Microsoft 365 Copilot: How to boost your productivity with AI – Part one: Ado...
 
Transcript: New from BookNet Canada for 2024: BNC SalesData and LibraryData -...
Transcript: New from BookNet Canada for 2024: BNC SalesData and LibraryData -...Transcript: New from BookNet Canada for 2024: BNC SalesData and LibraryData -...
Transcript: New from BookNet Canada for 2024: BNC SalesData and LibraryData -...
 
MuleSoft Online Meetup Group - B2B Crash Course: Release SparkNotes
MuleSoft Online Meetup Group - B2B Crash Course: Release SparkNotesMuleSoft Online Meetup Group - B2B Crash Course: Release SparkNotes
MuleSoft Online Meetup Group - B2B Crash Course: Release SparkNotes
 
2024 April Patch Tuesday
2024 April Patch Tuesday2024 April Patch Tuesday
2024 April Patch Tuesday
 
Glenn Lazarus- Why Your Observability Strategy Needs Security Observability
Glenn Lazarus- Why Your Observability Strategy Needs Security ObservabilityGlenn Lazarus- Why Your Observability Strategy Needs Security Observability
Glenn Lazarus- Why Your Observability Strategy Needs Security Observability
 
How to Effectively Monitor SD-WAN and SASE Environments with ThousandEyes
How to Effectively Monitor SD-WAN and SASE Environments with ThousandEyesHow to Effectively Monitor SD-WAN and SASE Environments with ThousandEyes
How to Effectively Monitor SD-WAN and SASE Environments with ThousandEyes
 
Connecting the Dots for Information Discovery.pdf
Connecting the Dots for Information Discovery.pdfConnecting the Dots for Information Discovery.pdf
Connecting the Dots for Information Discovery.pdf
 
React Native vs Ionic - The Best Mobile App Framework
React Native vs Ionic - The Best Mobile App FrameworkReact Native vs Ionic - The Best Mobile App Framework
React Native vs Ionic - The Best Mobile App Framework
 
Assure Ecommerce and Retail Operations Uptime with ThousandEyes
Assure Ecommerce and Retail Operations Uptime with ThousandEyesAssure Ecommerce and Retail Operations Uptime with ThousandEyes
Assure Ecommerce and Retail Operations Uptime with ThousandEyes
 
Accelerating Enterprise Software Engineering with Platformless
Accelerating Enterprise Software Engineering with PlatformlessAccelerating Enterprise Software Engineering with Platformless
Accelerating Enterprise Software Engineering with Platformless
 
Digital Tools & AI in Career Development
Digital Tools & AI in Career DevelopmentDigital Tools & AI in Career Development
Digital Tools & AI in Career Development
 

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/