Section 2.14. DTrace Versions of runq-sz, runocc


2.14. DTrace Versions of runq-sz, %runocc

Existing tools often provide useful statistics, but not quite in the way that we want. For example, the sar command provides measurements for the length of the run queues (runq-sz), and a percent run queue occupancy (%runocc). These are useful metrics, but since they are sampled only once per second, their accuracy may not be satisfactory. DTrace allows us to revisit these measurements, customizing them to our liking.

runq-sz: DTrace can measure run queue length for each CPU and produce a distribution plot.

# dtrace -n 'profile-1000hz { @[cpu] = lquantize(     curthread->t_cpu->cpu_disp->disp_ nrunnable, 0, 64, 1); }' dtrace: description 'profile-1000hz ' matched 1 probe ^C         0            value  ------------- Distribution ------------- count              < 0 |                                         0                0 |@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@     4665                1 |@@@@                                     489                2 |                                         41                3 |                                         25                4 |                                         4                5 |                                         0 


Rather than sampling once per second, this dtrace one-liner[8] samples at 1000 hertz. The example shows a single CPU system with some work queuing on its run queue, but not a great deal. A value of zero means no threads queued (no saturation); however, the CPU may still be processing a user or kernel thread (utilization).

[8] This exists in the DTraceToolkit as dispqlen.d.

What is actually measured by DTrace is the value of disp_nrunnable from the disp_t for the current CPU.

typedef struct _disp { ...         pri_t           disp_maxrunpri; /* maximum run priority */         pri_t           disp_max_unbound_pri;   /* max pri of unbound threads */         volatile int    disp_nrunnable; /* runnable threads in cpu dispq */         struct cpu      *disp_cpu;      /* cpu owning this queue or NULL */ } disp_t;                                                              See /usr/include/sys/disp.h 


%runocc: Measuring run queue occupancy is achieved in a similar fashion.disp_nrunnable is also used, but this time just to indicate the presence of queued threads.

#!/usr/sbin/dtrace -s #pragma D option quiet profile-1000hz /curthread->t_cpu->cpu_disp->disp_nrunnable/ {         @qocc[cpu] = count(); } profile:::tick-1sec {         normalize(@qocc, 10);         printf("\n%8s %8s\n", "CPU", "%runocc");         printa("%8d %@8d\n", @qocc);         clear(@qocc); } 


This script samples at 1000 hertz and uses a DTrace normalization of 10 to turn the 1000-count into a percentage. We ran this script on a busy 4-CPU server.

# ./runocc.d      CPU  %runocc        3       39        1       49        2       65        0       97      CPU  %runocc        1        2        3        8        2       99        0      100 ... 


Each CPU has an occupied run queue, especially CPU 0.

These examples of sampling activity at 1000 hertz are simple and possibly sufficiently accurate (certainly better than the original 1 hertz statistics). While DTrace can sample activity, it may be is better suited to trace activity, measuring nanosecond timestamps for each event. The sched provider exists to facilitate the tracing of scheduling events. With sched, runq-sz and %runocc can be measured with a much higher accuracy.




Solaris Performance and Tools(c) Dtrace and Mdb Techniques for Solaris 10 and Opensolaris
Solaris Performance and Tools: DTrace and MDB Techniques for Solaris 10 and OpenSolaris
ISBN: 0131568191
EAN: 2147483647
Year: 2007
Pages: 180

flylib.com © 2008-2017.
If you may any questions please contact us: flylib@qtcs.net