These tools are especially useful for finding out that an application
is doing single byte reads or writes, which is terribly inefficient.
In Java, the single-byte read/write problem is easily fixed by using
buffered readers and writers rather than single-byte I/O. If you run
% truss -t read,write -s\!all -p <process id>
You want to see fast buffered 8K reads, like this:
read(49, " B\r\n T R 0 8 0 6 5 9".., 8192) = 8192
read(49, " J".., 8192) = 8192
read(49, " 2 4 9 B D ".., 8192) = 8192
read(49, " 0 0 3 2 9 . 8 9 0 0 0 0".., 8192) = 8192
read(49, " . 0 0 R ".., 8192) = 8192
read(49, " B\r\n T R 0 8".., 8192) = 8192
read(49, " ".., 8192) = 8192
read(49, " 4 4 1 3 2 4 9 B ".., 8192) = 8192
read(49, " 0 0 0 2 4 5 6 1 5 . 0 3".., 8192) = 8192
You do not want to see one-byte unbuffered reads, like this:
read(49, " C", 1) = 1
read(49, " C", 1) = 1
read(49, " ", 1) = 1
read(49, " 0", 1) = 1
read(49, " 2", 1) = 1
read(49, " 3", 1) = 1
read(49, " 0", 1) = 1
read(49, " 0", 1) = 1
read(49, " 7", 1) = 1
read(49, " 5", 1) = 1
read(49, " 6", 1) = 1
read(49, " ", 1) = 1
read(49, " 0", 1) = 1
read(49, "\r", 1) = 1