SlideShare una empresa de Scribd logo
1 de 25
Descargar para leer sin conexión
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/

Más contenido relacionado

Destacado

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
 

Destacado (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 a 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 a 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
 

Último

What's New in Teams Calling, Meetings and Devices March 2024
What's New in Teams Calling, Meetings and Devices March 2024What's New in Teams Calling, Meetings and Devices March 2024
What's New in Teams Calling, Meetings and Devices March 2024Stephanie Beckett
 
New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024BookNet Canada
 
CloudStudio User manual (basic edition):
CloudStudio User manual (basic edition):CloudStudio User manual (basic edition):
CloudStudio User manual (basic edition):comworks
 
Vector Databases 101 - An introduction to the world of Vector Databases
Vector Databases 101 - An introduction to the world of Vector DatabasesVector Databases 101 - An introduction to the world of Vector Databases
Vector Databases 101 - An introduction to the world of Vector DatabasesZilliz
 
DevoxxFR 2024 Reproducible Builds with Apache Maven
DevoxxFR 2024 Reproducible Builds with Apache MavenDevoxxFR 2024 Reproducible Builds with Apache Maven
DevoxxFR 2024 Reproducible Builds with Apache MavenHervé Boutemy
 
Artificial intelligence in cctv survelliance.pptx
Artificial intelligence in cctv survelliance.pptxArtificial intelligence in cctv survelliance.pptx
Artificial intelligence in cctv survelliance.pptxhariprasad279825
 
Unleash Your Potential - Namagunga Girls Coding Club
Unleash Your Potential - Namagunga Girls Coding ClubUnleash Your Potential - Namagunga Girls Coding Club
Unleash Your Potential - Namagunga Girls Coding ClubKalema Edgar
 
"LLMs for Python Engineers: Advanced Data Analysis and Semantic Kernel",Oleks...
"LLMs for Python Engineers: Advanced Data Analysis and Semantic Kernel",Oleks..."LLMs for Python Engineers: Advanced Data Analysis and Semantic Kernel",Oleks...
"LLMs for Python Engineers: Advanced Data Analysis and Semantic Kernel",Oleks...Fwdays
 
Ensuring Technical Readiness For Copilot in Microsoft 365
Ensuring Technical Readiness For Copilot in Microsoft 365Ensuring Technical Readiness For Copilot in Microsoft 365
Ensuring Technical Readiness For Copilot in Microsoft 3652toLead Limited
 
"ML in Production",Oleksandr Bagan
"ML in Production",Oleksandr Bagan"ML in Production",Oleksandr Bagan
"ML in Production",Oleksandr BaganFwdays
 
Beyond Boundaries: Leveraging No-Code Solutions for Industry Innovation
Beyond Boundaries: Leveraging No-Code Solutions for Industry InnovationBeyond Boundaries: Leveraging No-Code Solutions for Industry Innovation
Beyond Boundaries: Leveraging No-Code Solutions for Industry InnovationSafe Software
 
Search Engine Optimization SEO PDF for 2024.pdf
Search Engine Optimization SEO PDF for 2024.pdfSearch Engine Optimization SEO PDF for 2024.pdf
Search Engine Optimization SEO PDF for 2024.pdfRankYa
 
Story boards and shot lists for my a level piece
Story boards and shot lists for my a level pieceStory boards and shot lists for my a level piece
Story boards and shot lists for my a level piececharlottematthew16
 
Transcript: New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
Transcript: New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024Transcript: New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
Transcript: New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024BookNet Canada
 
Gen AI in Business - Global Trends Report 2024.pdf
Gen AI in Business - Global Trends Report 2024.pdfGen AI in Business - Global Trends Report 2024.pdf
Gen AI in Business - Global Trends Report 2024.pdfAddepto
 
Connect Wave/ connectwave Pitch Deck Presentation
Connect Wave/ connectwave Pitch Deck PresentationConnect Wave/ connectwave Pitch Deck Presentation
Connect Wave/ connectwave Pitch Deck PresentationSlibray Presentation
 
"Debugging python applications inside k8s environment", Andrii Soldatenko
"Debugging python applications inside k8s environment", Andrii Soldatenko"Debugging python applications inside k8s environment", Andrii Soldatenko
"Debugging python applications inside k8s environment", Andrii SoldatenkoFwdays
 
Anypoint Exchange: It’s Not Just a Repo!
Anypoint Exchange: It’s Not Just a Repo!Anypoint Exchange: It’s Not Just a Repo!
Anypoint Exchange: It’s Not Just a Repo!Manik S Magar
 

Último (20)

What's New in Teams Calling, Meetings and Devices March 2024
What's New in Teams Calling, Meetings and Devices March 2024What's New in Teams Calling, Meetings and Devices March 2024
What's New in Teams Calling, Meetings and Devices March 2024
 
New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
 
CloudStudio User manual (basic edition):
CloudStudio User manual (basic edition):CloudStudio User manual (basic edition):
CloudStudio User manual (basic edition):
 
E-Vehicle_Hacking_by_Parul Sharma_null_owasp.pptx
E-Vehicle_Hacking_by_Parul Sharma_null_owasp.pptxE-Vehicle_Hacking_by_Parul Sharma_null_owasp.pptx
E-Vehicle_Hacking_by_Parul Sharma_null_owasp.pptx
 
DMCC Future of Trade Web3 - Special Edition
DMCC Future of Trade Web3 - Special EditionDMCC Future of Trade Web3 - Special Edition
DMCC Future of Trade Web3 - Special Edition
 
Vector Databases 101 - An introduction to the world of Vector Databases
Vector Databases 101 - An introduction to the world of Vector DatabasesVector Databases 101 - An introduction to the world of Vector Databases
Vector Databases 101 - An introduction to the world of Vector Databases
 
DevoxxFR 2024 Reproducible Builds with Apache Maven
DevoxxFR 2024 Reproducible Builds with Apache MavenDevoxxFR 2024 Reproducible Builds with Apache Maven
DevoxxFR 2024 Reproducible Builds with Apache Maven
 
Artificial intelligence in cctv survelliance.pptx
Artificial intelligence in cctv survelliance.pptxArtificial intelligence in cctv survelliance.pptx
Artificial intelligence in cctv survelliance.pptx
 
Unleash Your Potential - Namagunga Girls Coding Club
Unleash Your Potential - Namagunga Girls Coding ClubUnleash Your Potential - Namagunga Girls Coding Club
Unleash Your Potential - Namagunga Girls Coding Club
 
"LLMs for Python Engineers: Advanced Data Analysis and Semantic Kernel",Oleks...
"LLMs for Python Engineers: Advanced Data Analysis and Semantic Kernel",Oleks..."LLMs for Python Engineers: Advanced Data Analysis and Semantic Kernel",Oleks...
"LLMs for Python Engineers: Advanced Data Analysis and Semantic Kernel",Oleks...
 
Ensuring Technical Readiness For Copilot in Microsoft 365
Ensuring Technical Readiness For Copilot in Microsoft 365Ensuring Technical Readiness For Copilot in Microsoft 365
Ensuring Technical Readiness For Copilot in Microsoft 365
 
"ML in Production",Oleksandr Bagan
"ML in Production",Oleksandr Bagan"ML in Production",Oleksandr Bagan
"ML in Production",Oleksandr Bagan
 
Beyond Boundaries: Leveraging No-Code Solutions for Industry Innovation
Beyond Boundaries: Leveraging No-Code Solutions for Industry InnovationBeyond Boundaries: Leveraging No-Code Solutions for Industry Innovation
Beyond Boundaries: Leveraging No-Code Solutions for Industry Innovation
 
Search Engine Optimization SEO PDF for 2024.pdf
Search Engine Optimization SEO PDF for 2024.pdfSearch Engine Optimization SEO PDF for 2024.pdf
Search Engine Optimization SEO PDF for 2024.pdf
 
Story boards and shot lists for my a level piece
Story boards and shot lists for my a level pieceStory boards and shot lists for my a level piece
Story boards and shot lists for my a level piece
 
Transcript: New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
Transcript: New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024Transcript: New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
Transcript: New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
 
Gen AI in Business - Global Trends Report 2024.pdf
Gen AI in Business - Global Trends Report 2024.pdfGen AI in Business - Global Trends Report 2024.pdf
Gen AI in Business - Global Trends Report 2024.pdf
 
Connect Wave/ connectwave Pitch Deck Presentation
Connect Wave/ connectwave Pitch Deck PresentationConnect Wave/ connectwave Pitch Deck Presentation
Connect Wave/ connectwave Pitch Deck Presentation
 
"Debugging python applications inside k8s environment", Andrii Soldatenko
"Debugging python applications inside k8s environment", Andrii Soldatenko"Debugging python applications inside k8s environment", Andrii Soldatenko
"Debugging python applications inside k8s environment", Andrii Soldatenko
 
Anypoint Exchange: It’s Not Just a Repo!
Anypoint Exchange: It’s Not Just a Repo!Anypoint Exchange: It’s Not Just a Repo!
Anypoint Exchange: It’s Not Just a Repo!
 

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/