Skip to content

Using ioprofile with MySQL is cool !

Tracing per file IOs is a mandatory task for anyone doing performance issue analysis on a MySQL database. This could help to find candidates for innodb table compression, to decide to move data around on disks to optimize IOs, to decide what needs caching ...
There is no direct command to do it on linux. iostat gives you IOs per device or logical volumes.(I once thought of having loopback device mounted on my innodb datafile but it does not work).

ioprofile is a smart shell script developed by Baron Schwartz with the following principle :

You get the process id of the mysqld process with the pidof command
You get the list of files opened by the mysqld process using lsof command
With strace you then trace a particular set of system calls (open, read, write, ....)
you tabulate and summarize it all that for presentation.

I tested it on fedora and it worked fine. I just have had to install the strace package : yum install strace


[root@serge aspersa-read-only]# ./ioprofile -c count
total      read    pread64   pwrite64      write      fsync       open      close    _llseek filename
32         4          0          4         12          0          4          4          4 /tmp/#sql_19a9_0.MYI
24         4          0          0          4          0          4          4          8 /tmp/#sql_19a9_0.MYD
10         3          0          0          3          0          0          0          4 /disk1/opt/mysql/data/test/t3.MYD
10         0          1          7          0          2          0          0          0 /disk1/opt/mysql/data/ibdata1
8          0          0          5          0          3          0          0          0 /disk1/opt/mysql/data/test/t5.ibd
2          0          0          1          0          1          0          0          0 /disk1/opt/mysql/data/ib_logfile1
2          0          0          1          0          1          0          0          0 /disk1/opt/mysql/data/ib_logfile0
1          0          0          1          0          0          0          0          0 /disk1/opt/mysql/data/test/t3.MYI
[root@serge aspersa-read-only]# 

ioprofile has 2 useful options defining the aggregation function and what is measured (default is 'sum' and 'times'):
-a 'sum'|'avg'
-c 'times'|'count'|'sizes'

Documentation and code are there aspersa.

The other way to do it is to use the MySQL Performance Schema that comes with MySQL server 5.5 (currently RC). In that case you rely on the instrumentation that has been set-up in the server code. it gives much more possibilities but needs a learning curve.

Leave a Reply

Your email address will not be published. Required fields are marked *