dtrace - miracle scotland database forum

39
Playing around with DTrace (… and Oracle, of course) Doug Burns [email protected] m http:// oracledoug.com

Upload: doug-burns

Post on 06-May-2015

8.820 views

Category:

Technology


3 download

TRANSCRIPT

Page 1: DTrace - Miracle Scotland Database Forum

Playing around with DTrace

(… and Oracle, of course)

Doug Burns

[email protected]://oracledoug.com

Page 2: DTrace - Miracle Scotland Database Forum

Agenda

Introduction What is DTrace? DTrace Basics A Few Oracle Examples Quirks and Issues Conclusions

Page 3: DTrace - Miracle Scotland Database Forum

Introduction Welcome to Scotland

I’m a Campbell

Search Google for “Campbell Glencoe”

The picture you are about to see is well-chosen

Page 4: DTrace - Miracle Scotland Database Forum

The Glencoe Massacre of 1692

Page 5: DTrace - Miracle Scotland Database Forum

Introduction So now you know I am definitely not to

be trusted. I’m a Campbell I enjoy traditional Highland hospitality … … and then kill my hosts

However, you may be safe … I don’t drink Whisky I don’t wear Skirts!

See how dangerous a simple Tie can be?

Page 6: DTrace - Miracle Scotland Database Forum

What is DTrace?

Introduction What is DTrace? DTrace Basics A Few Oracle Examples Quirks and Issues Conclusions

Page 7: DTrace - Miracle Scotland Database Forum

Similar story to Oracle Wait Statistics See Juan Loiza quotation in Chapter 2 of

TOTOT

A problem with a benchmark Lots of guesses - none correct Instrumentation helps - if you thought of it Sometimes you have to stop to move forward

Sometimes you need to see what’s really going on – even (or particularly) on Production systems

What is DTrace? - History

Page 8: DTrace - Miracle Scotland Database Forum

Dynamic Tracing framework. Why ‘Dynamic’?

No need to instrument your code Although you can, by implementing a DTrace

provider. When you hit a performance problem, you can

enable probes Perhaps like ASH but without the constant overhead? More like dbms_support.start_trace_in_session

What can I trace? Erm, just about everything

What is DTrace? – The Name

Page 9: DTrace - Miracle Scotland Database Forum

What is DTrace? – The Future

Open Source Thriving Community

DTrace is available on Solaris 10+ Remember that Solaris != SPARC FreeBSD and Mac OS X - soon AIX?

Search Google for ‘AIX 6 Preview’ probevue

Linux?

Page 10: DTrace - Miracle Scotland Database Forum

DTrace Basics

Introduction The Need for DTrace DTrace Basics A Few Oracle Examples Quirks and Issues Conclusions

Page 11: DTrace - Miracle Scotland Database Forum

DTrace Basics – D Language

‘D’ Scripting Language A combination of C and awk?

But don’t let that put you off ;-) Event-driven so you :-

Define the Events (Probes) to trap Write the handlers

Let’s take a look at a simple example But ‘Hello World’ is not interesting

Page 12: DTrace - Miracle Scotland Database Forum

DTrace Basics – Defining Probes

Probes can be identified by name or number

A probe name is a 4-tuple provider:module:function:name A space or asterisk is a wildcard Some providers do not provide modules

Examples pid456:libc:malloc:entry pid1910:oracle:krccdw: sched:::enqueue dtrace:::BEGIN

Page 13: DTrace - Miracle Scotland Database Forum

DTrace Basics – One-Liner

Use any probe definition as a one line program Enable probes using -n

dtrace -n pid1910:oracle:krccdw:

dtrace: description 'pid1910:oracle:krccdw:' matched 108 probes

CPU ID FUNCTION:NAME 0 66998 krccdw:entry 0 207834 krccdw:0 0 207835 krccdw:1 0 207836 krccdw:3 0 207837 krccdw:6 0 207838 krccdw:9 0 207839 krccdw:a 0 207840 krccdw:b 0 207841 krccdw:c

Page 14: DTrace - Miracle Scotland Database Forum

DTrace Basics – One-Liner

Make a small change in probe definition

dtrace -n ::oracle:krccdw:entry

dtrace: description '::oracle:krccdw:entry' matched 1 probe

CPU ID FUNCTION:NAME 2 43530 krccdw:entry 3 43530 krccdw:entry 1 43530 krccdw:entry 1 43530 krccdw:entry 1 43530 krccdw:entry 2 43530 krccdw:entry 2 43530 krccdw:entry 2 43530 krccdw:entry 2 43530 krccdw:entry

Page 15: DTrace - Miracle Scotland Database Forum

DTrace Basics - Providers

sched provider Access to O/S scheduling information Probes which can trap information when

processes are placed on to the run queue and when they are dequeued and allowed to run. sched:::enqueue sched:::dequeue

Probes that can be used to monitor time spent on the CPU. sched:::on-cpu sched:::off-cpu

Page 16: DTrace - Miracle Scotland Database Forum

DTrace Basics - Providers

dtrace io pid Proc syscall sysinfo

Page 17: DTrace - Miracle Scotland Database Forum

DTrace Basics – A Script

A more realistic Program Structure

#pragma D option quiet

proc:::exec{ self->parent = execname;}

proc:::exec-success/self->parent != NULL/{ @[self->parent, execname] = count();

self->parent = NULL;}

proc:::exec-failure/self->parent != NULL/{ self->parent = NULL;}

END{ printf("%-20s %-20s %s\n", "WHO", "WHAT", "COUNT");

printa("%-20s %-20s %@d\n", @);}

Page 18: DTrace - Miracle Scotland Database Forum

DTrace Basics – A Script

Output

# dtrace -s ./whoexec.d^CWHO WHAT COUNTmake.bin yacc 1sh sed 4sh tr 4make make.bin 4sh install.bin 5sh rm 6cc ir2hf 33cc ube 33sh date 34sh mcs 34cc acomp 34sh cc 34sh basename 34basename expr 34make.bin sh 87

Page 19: DTrace - Miracle Scotland Database Forum

DTrace Basics -

DTrace Toolkit – Brendan Gregg A Useful Place to Start

Learn the D language Initial ideas of what to try Reasonably well documented Can run into resource limits if you apply them

to oracle whole-sale (more later) Free Constant Development Examples will use DTrace Toolkit

programs

Page 20: DTrace - Miracle Scotland Database Forum

A Few Oracle Examples

Introduction The Need for DTrace DTrace Basics A Few Oracle Examples Quirks and Issues Conclusions

Page 21: DTrace - Miracle Scotland Database Forum

A Few Oracle Examples

iotop –d md0 1

iosnoop –p 1885

Page 22: DTrace - Miracle Scotland Database Forum

A Few Oracle Examples

topsyscall

Page 23: DTrace - Miracle Scotland Database Forum

A Few Oracle Examples

One for Alex … Change Block Tracking Find the CTWR process

ps -ef|grep ctwr|grep -v grep

oracle 1911 1 0 May 19 ? 2:47 ora_ctwr_TEST1020

Page 24: DTrace - Miracle Scotland Database Forum

A Few Oracle Examples

Traditional approach – truss (or strace)

Page 25: DTrace - Miracle Scotland Database Forum

A Few Oracle Examples

dtruss – significantly less overhead

Page 26: DTrace - Miracle Scotland Database Forum

A Few Oracle Examples

dapptrace –aFp PID

Page 27: DTrace - Miracle Scotland Database Forum

Quirks and Issues

Introduction The Need for DTrace DTrace Basics A Few Oracle Examples Quirks and Issues Conclusions

Page 28: DTrace - Miracle Scotland Database Forum

Quirks and Issues

./dapptrace -p 5728

First, think about what you’re doing! Edit /kernel/drv/fasttrap.conf Default is 250,000

Increase to 1,000,000? update_drv fasttrap Probably need a reboot

Page 29: DTrace - Miracle Scotland Database Forum

Quirks and Issues

./dapptrace -p 5728

Not zeroing variables when they’re no longer used

Caused by running out of finite space for variables

Look at tuning dynvarsize and cleanrate

Page 30: DTrace - Miracle Scotland Database Forum

Quirks and Issues

No Overhead? When probes are not enabled

No or very low overhead Sampling - A probe event rate of less than

1000 per second Likely to have negligible impact.

Tracing “Slow” disk events – maybe less than 0.2% CPU Process creation – closer to 0% Every Application Function – maybe 10%?

Source: DTrace wiki at solarisinternals.com

Page 31: DTrace - Miracle Scotland Database Forum

Quirks and Issues

No Overhead A simple example Start a sqlplus session and pick up

dedicated server process dapptrace –p PID SELECT sysdate FROM dual;

Normally sub-second With dapptrace, 5 – 20 seconds!

No overhead?

Page 32: DTrace - Miracle Scotland Database Forum

Quirks and Issues

Tracing vs. Sampling Hey, it’s the 10046/Statspack debate!

DTrace can do both – horses for courses

DTrace can drown you in detail Unless you already know what you’re

looking for Aggregation Functions can also make

results more manageable

Page 33: DTrace - Miracle Scotland Database Forum

Conclusions

Introduction The Need for DTrace DTrace Basics A Few Oracle Examples Quirks and Issues Conclusions

Page 34: DTrace - Miracle Scotland Database Forum

Conclusions “Just tell me the top things to try” The Good

You may get some quick performance wins A very practical way to introduce you to DTrace

The Bad Can only introduce you to a fraction of the field of

DTrace Every site is different, there is no one-size-fits-all set

of scripts Somewhat ill-conceived; DTrace wins often aren't that

quick

The Ugly A customer declaring that "DTrace found nothing"

after only trying the quick wins

Page 35: DTrace - Miracle Scotland Database Forum

Conclusions From the DTrace Toolkit FAQ (Docs/Faq)

1.4. Am I now a performance tuning expert?

The DTraceToolkit does not turn people into performance tuning experts in the same way that owning a set of golf clubs won't make you a professional golfer. Experience and understanding are necessary.

Page 36: DTrace - Miracle Scotland Database Forum

Conclusions Not the ideal cure for Compulsive

Tuning Disorder1

Like presenting an alcoholic with the distillery keys.

You could spend a lot of time with this. If you’re a geek!

1 Gaja Krishna Vaidyanatha - TOTOT

Page 37: DTrace - Miracle Scotland Database Forum

Conclusions

My final and most important conclusion

Never Trust a Campbell!

Page 38: DTrace - Miracle Scotland Database Forum

Playing around with DTrace

(… and Oracle, of course)

Doug Burns

[email protected]://oracledoug.com

Page 39: DTrace - Miracle Scotland Database Forum

References and Additional Info

Brendan Gregg (including link to DTrace Toolkit) http://www.brendangregg.com/dtrace.html

Solaris Internals - DTrace Topics wiki http://www.solarisinternals.com/wiki/index.php/DTrace_T

opics

Tips, Tricks and Gotchas from DTrace authors http://learningsolaris.com/docs/dtrace_tips_public.pdf