Perl: February 2008 Archives

Fun with DTrace and ZFS mirrors (Solaris 10)

| | Comments (0) | TrackBacks (0)
blocksgraph4s.0090.gif
As a little DTrace exercise, I wanted to show how often disk blocks are read and written on a ZFS volume. More, it should be possible to watch zfs' write mechanism (more or less sequential on forthcoming unused blocks).

To begin, I started with a DTrace script like this:


#!/usr/sbin/dtrace -s

#pragma D option quiet

io:::done
{
  printf("%i,%i,%i,%i,%i\n",(timestamp/1000000),args[1]->dev_minor,args[0]->b_lblkno,args[0]->b_flags & B_WRITE,args[0]->b_bcount);
}

This resulted in a file beginning like that:

4668607882,448,2405944908,256,51200
4668607882,448,2405945042,256,7680
4668607883,512,2300900368,0,36864
4668607883,512,1865201616,0,20480
4668607884,448,2405945344,256,38912
4668607884,512,2358096048,256,38912
4668607884,512,2358096184,256,17408

[.... continued ...]

The columns mean: Timestamp (in milliseconds), minor device node of device, logical block number, read/write (read=0,write=256), number of bytes read or written starting from the given logical block.

This data file was then processed with a nifty perl script (using GD and the libgd graphics library), displaying each pixel as a block range of the device. Each read requests makes the dot greener, each write makes the underlying dot more red. For 10 seconds of data, I made a frame - at the end I had an animated gif which is funny to watch. You see growing "red" areas (write) and more or less random read i/o. And: You see the spool area, where files are written and read afterwards (the middle of the picture) - this is the heavy loaded postfix spool queue.
The left side of the graphic shows device 448, the right side device 512. Both are the two parts of a zpool mirror - hence the rather identical access patterns.

View animated gif but be warned: The file is 5 MB in size and it depends on your browser whether it can handle such large animated gifs - or not.

Enjoy!

November 2008

Sun Mon Tue Wed Thu Fri Sat
            1
2 3 4 5 6 7 8
9 10 11 12 13 14 15
16 17 18 19 20 21 22
23 24 25 26 27 28 29
30            

About

This blog is owned by:

Pascal Gienger
Kanzleistr. 14
78462 Konstanz
Phone +49 7531 584298
Fax +49 7531 584298-9

Phone USA 1-678-791-4182

YouTube Channel: pascalgienger