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

Book

  • Sorry, this book is no longer in print.
Not for Sale

About

Features

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.

Description

  • 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

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.

Sample Content

Online Sample Chapter

Performance Tools for Optimizing Linux: Process-Specific CPU

Table of Contents

Preface

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.

      Interrupts.

      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).

      gnome-system-monitor.

      mpstat (Multiprocessor Stat).

      sar (System Activity Reporter).

      oprofile.

    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).

      free.

      slabtop.

      sar (II).

      /proc/meminfo.

    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.

      time.

      strace.

      ltrace.

      ps (Process Status).

      ld.so (Dynamic Loader).

      gprof.

      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.

      ps.

      /proc/<PID>.

      memprof.

      valgrind (cachegrind).

      kcachegrind.

      oprofile (III).

      ipcs.

      Dynamic Languages (Java, Mono).

    Chapter Summary.

6. Performance Tools: Disk I/O.

    Introduction to Disk I/O.

    Disk I/O Performance Tools.

      vmstat (ii).

      iostat.

      sar.

      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).

      ethtool.

      ifconfig (Interface Configure).

      ip.

      sar.

      gkrellm.

      iptraf.

      netstat.

      etherape.

    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.

    Tools.

      bash.

      tee.

      script.

      watch.

      gnumeric.

      ldd.

      objdump.

      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.

Index.

Preface

Untitled Document

1.1. WHY IS PERFORMANCE IMPORTANT?

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.

1.2. LINUX: STRENGTHS AND WEAKNESS

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.

1.3. HOW CAN THIS BOOK HELP YOU?

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.

1.4. WHY LEARN HOW TO USE PERFORMANCE TOOLS?

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.

1.5. CAN I TUNE FOR PERFORMANCE?

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.

2.1 WHO SHOULD READ THIS BOOK?

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.

2.2 HOW IS THE BOOK ORGANIZED?

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.

Index

Untitled Document Download the Index related to this title.

Updates

Submit Errata

More Information

InformIT Promotional Mailings & Special Offers

I would like to receive exclusive offers and hear about products from InformIT and its family of brands. I can unsubscribe at any time.

Overview


Pearson Education, Inc., 221 River Street, Hoboken, New Jersey 07030, (Pearson) presents this site to provide information about products and services that can be purchased through this site.

This privacy notice provides an overview of our commitment to privacy and describes how we collect, protect, use and share personal information collected through this site. Please note that other Pearson websites and online products and services have their own separate privacy policies.

Collection and Use of Information


To conduct business and deliver products and services, Pearson collects and uses personal information in several ways in connection with this site, including:

Questions and Inquiries

For inquiries and questions, we collect the inquiry or question, together with name, contact details (email address, phone number and mailing address) and any other additional information voluntarily submitted to us through a Contact Us form or an email. We use this information to address the inquiry and respond to the question.

Online Store

For orders and purchases placed through our online store on this site, we collect order details, name, institution name and address (if applicable), email address, phone number, shipping and billing addresses, credit/debit card information, shipping options and any instructions. We use this information to complete transactions, fulfill orders, communicate with individuals placing orders or visiting the online store, and for related purposes.

Surveys

Pearson may offer opportunities to provide feedback or participate in surveys, including surveys evaluating Pearson products, services or sites. Participation is voluntary. Pearson collects information requested in the survey questions and uses the information to evaluate, support, maintain and improve products, services or sites, develop new products and services, conduct educational research and for other purposes specified in the survey.

Contests and Drawings

Occasionally, we may sponsor a contest or drawing. Participation is optional. Pearson collects name, contact information and other information specified on the entry form for the contest or drawing to conduct the contest or drawing. Pearson may collect additional personal information from the winners of a contest or drawing in order to award the prize and for tax reporting purposes, as required by law.

Newsletters

If you have elected to receive email newsletters or promotional mailings and special offers but want to unsubscribe, simply email information@informit.com.

Service Announcements

On rare occasions it is necessary to send out a strictly service related announcement. For instance, if our service is temporarily suspended for maintenance we might send users an email. Generally, users may not opt-out of these communications, though they can deactivate their account information. However, these communications are not promotional in nature.

Customer Service

We communicate with users on a regular basis to provide requested services and in regard to issues relating to their account we reply via email or phone in accordance with the users' wishes when a user submits their information through our Contact Us form.

Other Collection and Use of Information


Application and System Logs

Pearson automatically collects log data to help ensure the delivery, availability and security of this site. Log data may include technical information about how a user or visitor connected to this site, such as browser type, type of computer/device, operating system, internet service provider and IP address. We use this information for support purposes and to monitor the health of the site, identify problems, improve service, detect unauthorized access and fraudulent activity, prevent and respond to security incidents and appropriately scale computing resources.

Web Analytics

Pearson may use third party web trend analytical services, including Google Analytics, to collect visitor information, such as IP addresses, browser types, referring pages, pages visited and time spent on a particular site. While these analytical services collect and report information on an anonymous basis, they may use cookies to gather web trend information. The information gathered may enable Pearson (but not the third party web trend services) to link information with application and system log data. Pearson uses this information for system administration and to identify problems, improve service, detect unauthorized access and fraudulent activity, prevent and respond to security incidents, appropriately scale computing resources and otherwise support and deliver this site and its services.

Cookies and Related Technologies

This site uses cookies and similar technologies to personalize content, measure traffic patterns, control security, track use and access of information on this site, and provide interest-based messages and advertising. Users can manage and block the use of cookies through their browser. Disabling or blocking certain cookies may limit the functionality of this site.

Do Not Track

This site currently does not respond to Do Not Track signals.

Security


Pearson uses appropriate physical, administrative and technical security measures to protect personal information from unauthorized access, use and disclosure.

Children


This site is not directed to children under the age of 13.

Marketing


Pearson may send or direct marketing communications to users, provided that

  • Pearson will not use personal information collected or processed as a K-12 school service provider for the purpose of directed or targeted advertising.
  • Such marketing is consistent with applicable law and Pearson's legal obligations.
  • Pearson will not knowingly direct or send marketing communications to an individual who has expressed a preference not to receive marketing.
  • Where required by applicable law, express or implied consent to marketing exists and has not been withdrawn.

Pearson may provide personal information to a third party service provider on a restricted basis to provide marketing solely on behalf of Pearson or an affiliate or customer for whom Pearson is a service provider. Marketing preferences may be changed at any time.

Correcting/Updating Personal Information


If a user's personally identifiable information changes (such as your postal address or email address), we provide a way to correct or update that user's personal data provided to us. This can be done on the Account page. If a user no longer desires our service and desires to delete his or her account, please contact us at customer-service@informit.com and we will process the deletion of a user's account.

Choice/Opt-out


Users can always make an informed choice as to whether they should proceed with certain services offered by InformIT. If you choose to remove yourself from our mailing list(s) simply visit the following page and uncheck any communication you no longer want to receive: www.informit.com/u.aspx.

Sale of Personal Information


Pearson does not rent or sell personal information in exchange for any payment of money.

While Pearson does not sell personal information, as defined in Nevada law, Nevada residents may email a request for no sale of their personal information to NevadaDesignatedRequest@pearson.com.

Supplemental Privacy Statement for California Residents


California residents should read our Supplemental privacy statement for California residents in conjunction with this Privacy Notice. The Supplemental privacy statement for California residents explains Pearson's commitment to comply with California law and applies to personal information of California residents collected in connection with this site and the Services.

Sharing and Disclosure


Pearson may disclose personal information, as follows:

  • As required by law.
  • With the consent of the individual (or their parent, if the individual is a minor)
  • In response to a subpoena, court order or legal process, to the extent permitted or required by law
  • To protect the security and safety of individuals, data, assets and systems, consistent with applicable law
  • In connection the sale, joint venture or other transfer of some or all of its company or assets, subject to the provisions of this Privacy Notice
  • To investigate or address actual or suspected fraud or other illegal activities
  • To exercise its legal rights, including enforcement of the Terms of Use for this site or another contract
  • To affiliated Pearson companies and other companies and organizations who perform work for Pearson and are obligated to protect the privacy of personal information consistent with this Privacy Notice
  • To a school, organization, company or government agency, where Pearson collects or processes the personal information in a school setting or on behalf of such organization, company or government agency.

Links


This web site contains links to other sites. Please be aware that we are not responsible for the privacy practices of such other sites. We encourage our users to be aware when they leave our site and to read the privacy statements of each and every web site that collects Personal Information. This privacy statement applies solely to information collected by this web site.

Requests and Contact


Please contact us about this Privacy Notice or if you have any requests or questions relating to the privacy of your personal information.

Changes to this Privacy Notice


We may revise this Privacy Notice through an updated posting. We will identify the effective date of the revision in the posting. Often, updates are made to provide greater clarity or to comply with changes in regulatory requirements. If the updates involve material changes to the collection, protection, use or disclosure of Personal Information, Pearson will provide notice of the change through a conspicuous notice on this site or other appropriate way. Continued use of the site after the effective date of a posted revision evidences acceptance. Please contact us if you have questions or concerns about the Privacy Notice or any objection to any revisions.

Last Update: November 17, 2020