Linux performance tuning

When attempting to find and fix performance bottlenecks on a Linux system, it’s helpful to know where to start. Here are a few resources I’ve found:

IBM’s [Linux Performance and Tuning Guidelines](http://www.redbooks.ibm.com/abstracts/redp4285.html), published July 2007

> This IBM Redpaper describes the methods you can use to tune Linux,
tools that you can use to monitor and analyze server performance, and
key tuning parameters for specific server applications. The purpose of
this redpaper is to understand, analyze, and tune the Linux operating
system to yield superior performance for any type of application you
plan to run on these systems. ( [Read more…](http://www.redbooks.ibm.com/abstracts/redp4285.html) )

This website has useful tips:
[http://www.performancewiki.com/](http://www.performancewiki.com/)

Google has some tools that people recommend:
[http://code.google.com/p/google-perftools/wiki/GooglePerformanceTools](http://code.google.com/p/google-perftools/wiki/GooglePerformanceTools)

This book seems to be recommended:
[Optimizing Linux Performance](http://www.amazon.com/Optimizing-Linux-Performance-Hands-Professional/dp/0131486829)

In my experience, strace and ltrace along with the “-c” and “-T” options, are extremely useful — even for Perl scripts. The “-T” option shows the timings of calls, and can help isolate what calls are the slowest.

* `strace -o program.trace -T -p `
* `ltrace -o program.trace -T -p `

The “-c” option gives a summary of the calls that used the most time:

* `strace -c -p `
* `ltrace -c -p `

I haven’t found a good way to isolate memory leaks in Perl programs — not that I’m an expert. What has worked for me is to [divide and conquer](http://en.wikipedia.org/wiki/Divide_and_conquer_algorithm) in order to isolate the problem.