Home > Store

Optimizing Linux Performance: A Hands-On Guide to Linux Performance Tools

Register your product to gain access to bonus material or receive a coupon.

Optimizing Linux Performance: A Hands-On Guide to Linux Performance Tools


  • Your Price: $43.99
  • List Price: $54.99
  • Usually ships in 24 hours.



Readers learn to use Linux's rich set of performance tools to make their applications run better.

° Readers learn how to find and remove performance bottlenecks and increase the performance of Linux applications.

° Useful format -- Reader learns tool's purpose, the tool's options, than a hands-on example of how to use the tool.

° Author is key -- enhanced the industry standard and established benchmarks for greater performance.


  • Copyright 2005
  • Dimensions: 6-7/8" x 9-1/4"
  • Pages: 384
  • Edition: 1st
  • Book
  • ISBN-10: 0-13-148682-9
  • ISBN-13: 978-0-13-148682-9

  • The first comprehensive, expert guide for end-to-end Linux application optimization

  • Learn to choose the right tools—and use them together to solve real problems in real production environments

Superior application performance is more crucial than ever—and in today's complex production environments, it's tougher to ensure, too. If you use Linux, you have extraordinary advantages: complete source code access, plus an exceptional array of optimization tools. But the tools are scattered across the Internet. Many are poorly documented. And few experts know how to use them together to solve real problems. Now, one of those experts has written the definitive Linux tuning primer for every professional: Optimizing Linux® Performance.

Renowned Linux benchmarking specialist Phillip Ezolt introduces each of today's most important Linux optimization tools, showing how they fit into a proven methodology for perfecting overall application performance. Using realistic examples, Ezolt shows developers how to pinpoint exact lines of source code that are impacting performance. He teaches sysadmins and application developers how to rapidly drill down to specific bottlenecks, so they can implement solutions more quickly. You'll discover how to:

  • Identify bottlenecks even if you're not familiar with the underlying system

  • Find and choose the right performance tools for any problem

  • Recognize the meaning of the events you're measuring

  • Optimize system CPU, user CPU, memory, network I/O, and disk I/O—and understand their interrelationships

  • Fix CPU-bound, latency-sensitive, and I/O-bound applications, through case studies you can easily adapt to your own environment

Install and use oprofile, the advanced systemwide profiler for Linux systems

If you're new to tuning, Ezolt gives you a clear and practical introduction to all the principles and strategies you'll need. If you're migrating to Linux, you'll quickly master Linux equivalents to the tools and techniques you already know. Whatever your background or environment, this book can help you improve the performance of all your Linux applications—increasingbusiness value and user satisfaction at the same time.

© Copyright Pearson Education. All rights reserved.

Sample Content

Online Sample Chapter

Performance Tools for Optimizing Linux: Process-Specific CPU

Downloadable Sample Chapter

Untitled Document Download the Sample Chapter related to this title.

Table of Contents


1. Performance Hunting Tips.

    General Tips.

      Take Copious Notes (Save Everything).

      Automate Redundant Tasks.

      Choose Low-Overhead Tools If Possible.

      Use Multiple Tools to Understand the Problem.

      Trust Your Tools.

      Use the Experience of Others (Cautiously).

    Outline of a Performance Investigation.

      Finding a Metric, Baseline, and Target.

      Track Down the Approximate Problem.

      See Whether the Problem Has Already Been Solved

      The Case Begins (Start to Investigate).

      Document, Document, Document.

    Chapter Summary

2. Performance Tools: System CPU.

    CPU Performance Statistics

      Run Queue Statistics.

      Context Switches.


      CPU Utilization.

    Linux Performance Tools: CPU.

      vmstat (Virtual Memory Statistics).

      top (v. 2.0.x).

      top (v. 3.x.x).

      procinfo (Display Info from the /proc File System).


      mpstat (Multiprocessor Stat).

      sar (System Activity Reporter).


    Chapter Summary

3. Performance Tools: System Memory.

    Memory Performance Statistics.

      Memory Subsystem and Performance.

      Memory Subsystem (Virtual Memory).

    Linux Performance Tools: CPU and Memory.

      vmstat  (Virtual Memory Statistics) II.

      top (2.x and 3.x).

      procinfo II.

      gnome-system-monitor (II).



      sar (II).


    Chapter Summary

4. Performance Tools: Process-Specific CPU.

    Process Performance Statistics.

      Kernel Time Versus User Time.

      Library Time Versus Application Time.

      Subdividing Application Time.

    The Tools.




      ps (Process Status).

      ld.so (Dynamic Loader).


      oprofile (II).

      Languages: Static (C and C++) Versus Dynamic (Java and Mono).

    Chapter Summary.

5. Performance Tools: Process-Specific Memory.

    Linux Memory Subsystem.

    Memory Performance Tools.




      valgrind (cachegrind).


      oprofile (III).


      Dynamic Languages (Java, Mono).

    Chapter Summary.

6. Performance Tools: Disk I/O.

    Introduction to Disk I/O.

    Disk I/O Performance Tools.

      vmstat (ii).



      lsof  (List Open Files).

    What’s Missing?

    Chapter Summary.

7. Performance Tools: Network.

    Introduction to Network I/O.

      Network Traffic in the Link Layer.

      Protocol-Level Network Traffic.

    Network Performance Tools.

      mii-tool (Media-Independent Interface Tool).


      ifconfig (Interface Configure).







    Chapter Summary

8. Utility Tools: Performance Tool Helpers.

    Performance Tool Helpers.

      Automating and Recording Commands.

      Graphing and Analyzing Performance Statistics.

      Investigating the Libraries That an Application Uses.

      Creating and Debugging Applications.









      GNU Debugger (gdb).

      gcc (GNU Compiler Collection).

    Chapter Summary

9. Using Performance Tools to Find Problems.

    Not Always a Silver Bullet.

    Starting the Hunt.

    Optimizing an Application.

      Is Memory Usage a Problem?

      Is Startup Time a Problem?

      Is the Loader Introducing a Delay?

      Is CPU Usage (or Length of Time to Complete) a Problem?

      Is the Application’s Disk Usage a Problem?

      Is the Application’s Network Usage a Problem?

    Optimizing a System.

      Is the System CPU-Bound?

      Is a Single Processor CPU-Bound?

      Are One or More Processes Using Most of the System CPU?

      Are One or More Processes Using Most of an Individual CPU?

      Is the Kernel Servicing Many Interrupts?

      Where Is Time Spent in the Kernel?

      Is the Amount of Swap Space Being Used Increasing?

      Is the System I/O-Bound?

      Is the System Using Disk I/O?

      Is the System Using Network I/O?

    Optimizing Process CPU Usage.

      Is the Process Spending Time in User or Kernel Space?

      Which System Calls Is the Process Making, and How Long Do They Take to Complete?

      In Which Functions Does the Process Spend Time?

      What Is the Call Tree to the Hot Functions?

      Do Cache Misses Correspond to the Hot Functions or Source Lines?

    Optimizing Memory Usage.

      Is the Kernel Memory Usage Increasing?

      What Type of Memory Is the Kernel Using?

      Is a Particular Process’s Resident Set Size Increasing?

      Is Shared Memory Usage Increasing?

      Which Processes Are Using the Shared Memory?

      What Type of Memory Is the Process Using?

      What Functions Are Using All of the Stack?

      What Functions Have the Biggest Text Size?

      How Big Are the Libraries That the Process Uses?

      What Functions Are Allocating Heap Memory?

    Optimizing Disk I/O Usage.

      Is the System Stressing a Particular Disk?

      Which Application Is Accessing the Disk?

      Which Files Are Accessed by the Application?

    Optimizing Network I/O Usage.

      Is Any Network Device Sending/Receiving Near the Theoretical Limit?

      Is Any Network Device Generating a Large Number of Errors?

      What Type of Traffic Is Running on That Device?

      Is a Particular Process Responsible for That Traffic?

      What Remote System Is Sending the Traffic?

      Which Application Socket Is Responsible for the Traffic?

    The End.

    Chapter Summary.

10. Performance Hunt 1: A CPU-Bound Application (GIMP).

    CPU-Bound Application.

    Identify a Problem.

    Find a Baseline/Set a Goal.

    Configure the Application for the Performance Hunt.

    Install and Configure Performance Tools.

    Run Application and Performance Tools.

    Analyze the Results.

    Jump to the Web.

    Increase the Image Cache.

    Hitting a (Tiled) Wall.

    Solving the Problem.

    Verify Correctness?

    Next Steps.

    Chapter Summary

11. Performance Hunt 2: A Latency-Sensitive Application (nautilus).

    A Latency-Sensitive Application.

    Identify a Problem.

    Find a Baseline/Set a Goal.

    Configure the Application for the Performance Hunt.

    Install and Configure Performance Tools.

    Run Application and Performance Tools.

    Compile and Examine the Source.

    Using gdb to Generate Call Traces.

    Finding the Time Differences.

    Trying a Possible Solution.

    Chapter Summary

12. Performance Hunt 3: The System-Wide Slowdown (prelink).

    Investigating a System-Wide Slowdown.

    Identify a Problem.

    Find a Baseline/Set a Goal.

    Configure the Application for the Performance Hunt.

    Install and Configure Performance Tools.

    Run Application and Performance Tools.

    Simulating a Solution.

    Reporting the Problem.

    Testing the Solution.

    Chapter Summary.

13. Performance Tools: What’s Next?

    The State of Linux Tools.

    What Tools Does Linux Still Need?

      Hole 1: Performance Statistics Are Scattered.

      Hole 2: No Reliable and Complete Call Tree.

      Hole 3: I/O Attribution.

    Performance Tuning on Linux.

      Available Source.

      Easy Access to Developers.

      Linux Is Still Young.

    Chapter Summary.

Appendix A. Performance Tool Locations.

Appendix B. Installing oprofile.

    Fedora Core 2 (FC2).

    Enterprise Linux 3 (EL3).

    SUSE 9.1.



Untitled Document


If you've ever sat waiting for a computer to do something, (while pounding on your desk, cursing and wondering "What is TAKING so long?") you know why it is important to have a fast and well tuned computer system. While not all performance problems can be easily solved, understanding WHY things are slow can be the difference between fixing the problem in software, upgrading the slow hardware or simply throwing the whole computer out the window. Fortunately most operating systems, Linux in particular, provide the tools to figure out why the machine runs slowly. By using a few basic tools, you can determine where the system is slowing down and fix the parts that are running inefficiently.

While a slow system can be particularly annoying to an end-user, if you are an application developer, you have an even more important reason to performance tune your applications. An efficient application runs on more systems. Not everyone has the latest hardware and by writing sluggish applications that need a zippy computer, you eliminate customers who have slower computers. A well-tuned application will be usable by more customers, and have a bigger potential user base. In addition, if a potential customer must choose between two different applications with similar functionality, they will often chose the one which runs faster or is more efficient. Finally, a long lived application will likely go through several rounds of optimization to cope with different customer demands, so it is crucial to know how to track down performance problems.

If you are a system administrator, you have a responsibility to the users of the system to make sure that it is running with an adequate level of performance. If the system is running slowly, users will complain. If you can figure out the problem and fix it quickly, they'll stop complaining. As a bonus, if you can solve their problem by tuning the application or operating system rather than buying new hardware, you'll make the company bean-counters happy. Knowing how to effectively use performance tools can mean the difference between spending days and spending hours on a performance problem.


If you use Linux, maintain it, and develop on it, you are in a strange but good situation. You have unprecedented access to source code, developers, and mailing lists which often document design decisions years after they were made. Linux is an excellent environment to find and fix performance problems. This is in contrast to a proprietary environment, where it can be difficult to get direct access to software developers, may be hard to find written discussion about most design decisions, and is nearly impossible to access source code. In addition to this productive environment, Linux also has powerful performance tools that you can use to find and fix performance problems. These tools rival their proprietary counterparts.

Even with these impressive benefits the Linux ecosystem still has challenges to overcome. Linux's performance tools are scattered everywhere. The tools are developed by different groups with different aims, and as a result aren't in the same location. Some tools are included in standard Linux distributions, such as Redhat, SUSE or Debian, while others are scattered through out the Internet. If you're trying to solve a performance problem, you first have to know that the tools you need exist, and then figure out where to find them.

No single Linux performance tool will solve every type of performance problem, so you also must figure out how to use them together to determine what is broken. This can be a bit of an art that becomes easier with experience. Most of the general strategies can be written down, but Linux doesn't have any guide that tells you how to use the performance tools together to actually solve a problem. Most of the tools or subsystems have information about tuning the particular subsystem, but not how to use them with other tools. Many performance problems span several areas of the system and unless you know how to use the tools together you won't be able the fix the problem.


This book will help you in a few different ways. It will show you:

  • What the different performance tools measure

  • How to use each tool

  • How to combine the tools to solve a performance problem

  • How to start with a poorly performing system and pinpoint the problem

  • How the methods are used to solve real-world problems by providing a few case studies

Using the methods in this book, you will be able to make a well organized and diagnosed problem description which can be passed on to the original developers. If you're lucky, they'll solve the problem for you.


Why should anyone put effort into tuning a system or application?

  • A well-tuned system can do more work with less resources

  • A well-tuned application can run on older hardware

  • A well-tuned desktop can save a user time

  • A well-tuned server provides a higher service quality for more users

If you know how to effectively diagnose performance problems, you can take a targeted approach at solving the problem, rather than simply taking a shot in the dark and hoping that it works. If you are an application developer, this means that you can quickly figure out what piece of code is causing the problem. If you are a system administrator, it means that you can figure out what part of the system needs to be tuned, or upgraded without wasting time unsuccessfully trying different solutions. If you are a end-user, you can figure out which applications are lagging, and report the problem to the developers, or update your hardware if necessary.

Linux is at cross-roads. Most of the functionality for a highly productive system is already done. The next evolutionary step is for Linux and Linux applications to be tuned to compete with and surpass the performance of other operating systems. Some of this performance optimization has already begun. Projects such as SAMBA, Apache and the TUX web server have spend a lot of time tuning and optimizing the system and code. Other performance optimizations such as the Native POSIX Thread Library (NPTL), which dramatically improve threading performance, and object prelinking, which improves application startup time, are just starting to be integrated into Linux. Linux is a fertile ground for performance improvements.


The best thing about performance optimization is that you don't need to know the details of the entire application or system to effectively fix performance problems. Performance optimization requires a complementary set of skills to those of a typical application developer.

You need to be observant and persistent. It takes more of a detective than a programmer to hunt down and eliminate the performance problems. It is exhilarating to find and fix these. When you start, performance is terrible. However, you track down the cause. Rip it out by the roots, if you're lucky, it runs twice as fast. Voila!

To get to the "viola!", you have to understand the powerful but sometimes confusing world of Linux performance tools. This takes a little bit of work, but in the end it is worth it. The tools can show you aspects of your application and system that you never expected to see.


This book is intended to help Linux software developers, system administrators and end users to use the Linux performance tools to find the performance problems in a given system. Beginning performance investigators will learn the basics of performance investigation and analysis. Medium to advanced performance investigators, especially those with performance experience on other proprietary operating systems, will learn about the Linux equivalents of commands from other systems they may already be familiar with.

Software developers will learn how to pinpoint the exact line of source code that is causing a performance problem. System administrators who are performance tuning a system will learn about the tools that show why a system is slowing down and they can then use that information to tune the system. Finally, while not the primary focus of the book, end users will be the learn basic skills necessary to figure out which applications are consuming all of the system resources.


This book is intended to teach an audience varying level of experience to find and fix performance problems. To accomplish this, the chapters are presented so that you can pick and choose to read different parts of the book without reading the entire book straight through. The book is structured as follows:

The first chapter is devoted to the basic methods of performance problem hunting. It contains a series of non-Linux specific tips and suggestions that are useful for tracking down performance issues. These guidelines are general suggestions for performance problem hunting and could be applied to tracking down performance issues on any type of computer system.

The next few chapters, and the bulk of the book, present the individual tools available to measure different performance statistics on a Linux system. These chapters explain what a tool measures, how it is invoked, and an example of the tool being used. Each different chapter demonstrates tools that measure aspects of different Linux subsystems such as system CPU, user CPU, memory, network I/O and disk I/O. If a tool measures aspects of more than one subsystem, it is presented in more than one chapter. However, only the appropriate tools options for that subsystem are presented in a given chapter. Each chapter contains descriptions for multiple tools. The descriptions are in the following format:

  1. Introduction: This explains what the tool is meant to measure and how it operates.

  2. Performance tool options: This section does not simply rehash the tool's documentation. Rather, it explains which options are relevant to the current topic and what those options mean. For example, some performance tool man pages state the events that a tool measures, but never explain what the events mean. This section explains the meaning of the events, and how it is relevant to the current subsystem.

  3. Example: This gives one or more examples of the tool being used to measure performance statistics. This sections shows the tool being invoked as well as any output that it generates.

The next chapter is Linux specific and contains a series of steps to use when confronted with a slowly performing Linux system. It explains how to use the previously described Linux performance together to pinpoint the cause of the performance problem. This chapter is the most useful if you want to start with a misbehaving Linux system and simply diagnose the problem, without necessarily understanding the details of the tools.

The next three chapters show case studies where the methodologies and tools previously described are used together to solve real world problems. The case studies show the use of Linux performance tools in finding and fixing different types of performance problems: a CPU bound application, a latency sensitive application, and an I/O bound application.

The final chapter provides an overview of the performance tools and what opportunities that Linux has for improvement. The book also has two appendices. Appendix A will contain a table of the performance tools presented in the book, a URL to the latest version of each tool, and information on which Linux distributions the tool is supported. Finally, appendix B will contain information about how to install oprofile, a very powerful, but hard to install tool, on a few major Linux distributions.

© Copyright Pearson Education. All rights reserved.


Untitled Document Download the Index related to this title.


Submit Errata

More Information

Unlimited one-month access with your purchase
Free Safari Membership