Do you ever wish you could see what’s going on inside your computer while it’s mulling over some seemingly simple question and driving you crazy? Well, you can, sort of. You can see exactly which system calls are being executed and what the parameters to those calls are with one of the system call tracing utilities, such as truss on Solaris or strace on Linux. Other versions include ktrace and par. Shared library calls can be seen using sotruss under Solaris 2.6. See Chapter 9 for a trace of what happens when a request is made of a web server.
Tracing is especially useful for finding out that an application is doing single byte reads or writes, which is terribly inefficient. In Java, the problem is easily fixed by using buffered reader/writers rather than single-byte IO. If you run truss -t read,write -s\!all -p (process id), you should see the following: