28 May, 2006

DTracing Scheduling Classes

I've recently been working on some new killer DTrace scripts, and the DTrace UK Workshops. I thought I'd take a break and share something interesting.

The following is from the DTraceToolkit, and is one of my favourite tool example files (Docs/Examples/priclass_example.txt). I'm a firm believer in providing examples, and plan to enhance the existing examples in the toolkit further. There also seems to be a trend to include more examples in Solaris man pages (such as zfs and zpool), which is great to see.



The following is a demonstration of the priclass.d script.

The script was run for several seconds then Ctrl-C was hit. During this time, other processes in different scheduling classes were running.
# ./priclass.d
Sampling... Hit Ctrl-C to end.
^C

IA
value ------------- Distribution ------------- count
40 | 0
50 |@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@ 30
60 | 0

SYS
value ------------- Distribution ------------- count
< 0 |@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@ 4959
0 | 0
10 | 0
20 | 0
30 | 0
40 | 0
50 | 0
60 | 30
70 | 0
80 | 0
90 | 0
100 | 0
110 | 0
120 | 0
130 | 0
140 | 0
150 | 0
160 | 50
>= 170 | 0

RT
value ------------- Distribution ------------- count
90 | 0
100 |@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@ 110
110 | 0

TS
value ------------- Distribution ------------- count
< 0 | 0
0 |@@@@@@@@@@@@@@@ 2880
10 |@@@@@@@ 1280
20 |@@@@@ 990
30 |@@@@@ 920
40 |@@@@ 670
50 |@@@@ 730
60 | 0

The output is quite interesting, and illustrates neatly the behaviour of different scheduling classes.

The IA interactive class had 30 samples of a 50 to 59 priority, a fairly high priority. This class is used for interactive processes, such as the windowing system. I had clicked on a few windows to create this activity.

The SYS system class has had 4959 samples at a < 0 priority - the lowest, which was for the idle thread. There are a few samples at higher priorities, including some in the 160 to 169 range (the highest), which are for interrupt threads. The system class is used by the kernel.

The RT real time class had 110 samples in the 100 to 109 priority range. This class is designed for real-time applications, those that must have a consistant response time regardless of other process activity. For that reason, the RT class trumps both TS and IA. I created these events by running "prstat -R" as root, which runs prstat in the real time class.

The TS time sharing class is the default scheduling class for the processes on a Solaris system. I ran an infinite shell loop to create heavy activity, "while :; do :; done", which shows a profile that leans towards lower priorities. This is deliberate behaivour from the time sharing class, which reduces the priority of CPU bound processes so that they interefere less with I/O bound processes. The result is more samples in the lower priority ranges.

No comments: