3

I'm looking for a way to determine whether an app is doing sequential or random I/O. Is it possible to look at a blktrace capture and say if I/O is sequential or random? If yes, any examples of what patterns should I be looking for?

1 Answers1

3

It would seem possible that blktrace + blkparse could be used to get this info. Looking at the diagram I included in this U&L Q&A: Diagram of Linux kernel vs. performance tools?, specifically this section.

ss#1

blktrace seems as though it would be positioned to show you this type of data. In looking at the man page for blkparse it shows that you can include the sector number in the output.

excerpt from blkparse man page

OUTPUT DESCRIPTION AND FORMATTING
       The output from blkparse can be tailored for specific use -- in 
       particular, to ease parsing of output, and/or limit output fields
       to  those the user wants to see. The data for fields which can be 
       output include:

       a   Action, a (small) string (1 or 2 characters) -- see table below 
           for more details
       c   CPU id
       C   Command
...
       s   Sequence numbers
       S   Sector number

Example

$ sudo blktrace /dev/sda
Ctrl + C

Then analyze it with blkparse:

$ blkparse sda -f "%-10S %D %2c %8s %5T.%9t %5p %2a %3d\n" | head -10
4064336      8,0    3        1     0.000000000  2779  A   R
5090384      8,0    3        2     0.000000404  2779  A   R
5090384      8,0    3        3     0.000001656  2779  Q   R
5090384      8,0    3        4     0.000010042  2779  G   R
5090384      8,0    3        5     0.000013714  2779  I   R
  8,0    3        0     0.000019067     0  m   N cfq2779SN / insert_request
  8,0    3        0     0.000021085     0  m   N cfq2779SN / add_to_rr
  8,0    3        0     0.000026848     0  m   N cfq2779SN / set_active wl_class:2 wl_type:1
  8,0    3        0     0.000029175     0  m   N cfq2779SN / fifo=          (null)
  8,0    3        0     0.000030077     0  m   N cfq2779SN / dispatch_insert

When there are sectors to be reported, they'll show up as the numbers without commas, i.e. 4064336. So you could in theory confirm that the sector numbers are in series or random.

The hard part will be in identifying which application, caused which I/O event(s) at the lower level. To address this you may be able to make use of the tool, fatrace that I detailed in this U&L Q&A titled: Determining Specific File Responsible for High I/O.

References

slm
  • 369,824
  • Thanks dude, tried and looks like output fits what's expected, seq tailing sectors, rand scattered sectors,more or less – BlackBeret Sep 02 '14 at 11:01