Determining if an application is using random vs. sequential I/O

The DTraceToolkit comes with two super useful scripts to observe the “randonmess” or “sequentialness” of an application. The first script is iopattern, which provides a system-wide view of random and sequential I/O, the total amount of I/O generated, and an I/O size distribution:

$ iopattern 5

%RAN %SEQ  COUNT    MIN    MAX    AVG     KR     KW
 100    0      9    512   4096   1706      0     15
 100    0     19    512   1024    592      0     11
 100    0      4    512    512    512      0      2
 100    0      8    512   4096   1856      0     14

The second script is seeksize.d. Seeksize.d provides a histogram of the number of sectors traversed between I/O operations for each process on the system:

$ seeksize.d

    1615  /usr/lib/ssh/sshd

           value  ------------- Distribution ------------- count
            2048 |                                         0
            4096 |@@@@@@@                                  2
            8192 |@@@@@@@@@@@                              3
           16384 |@@@@@@@@@@@                              3
           32768 |@@@@@@@@@@@                              3
           65536 |                                         0

    [ ..... ]

While discussing these scripts last night, I didn’t provide many details on how they actually work. Each script uses the io provider to detect when an I/O occurs, and the value of “b_blkno” to determine which block is being read into memory or written to disk. Since DTrace comes with a nifty type called an aggregation, the previous block read can be compared with the current block read (both stored as thread local variables), and the result stored in the aggregation. This is pretty interesting stuff, and I apologize for not providing further details during my talk.

Leave a Comment