Tuesday, May 6, 2014

Profiling IO in java on linux

This is more of a note to myself, but others may find it useful.

When you want to see what bottlenecks are being hit by some java process that you're running you can do the following:

  1. Repeatedly obtain the backtrace using jstack PID. If you're repeatedly seeing something blocking in a read/write related call then you're IO bound
  2. Check what files are open by the process using lsof PID. Its likely that one of these will look suspect
  3. Watch reads to those open files using strace -f -p PID -e trace=none -e write=FD1,FD2,... -e read=FD1,FD2,...