You are previewing Java® Performance Companion.
O'Reilly logo
Java® Performance Companion

Book Description

Java® Performance Companion shows how to systematically and proactively improve Java performance with today’s advanced multicore hardware and complex operating system environments.

The authors, who are all leading Java performance and Java HotSpot VM experts, help you improve performance by using modern software engineering practices, avoiding common mistakes, and applying tips and tricks gleaned from years of real-world experience.

Picking up where Charlie Hunt and Binu John’s classic Java Performance left off, this book provides unprecedented detail on two powerful Java platform innovations: the Garbage First (G1) garbage collector and the HotSpot VM Serviceability Agent.

Coverage includes

  • Leveraging G1 to overcome limitations in parallel, serial, and CMS garbage collection

  • Understanding each stage of G1 GC collections, both young and old

  • Getting under the hood with G1 and efficiently fine-tuning it for your application

  • Identifying potential optimizations, interpreting experimental results, and taking action

  • Exploring the internals of the HotSpot VM

  • Using HotSpot VM Serviceability Agent to analyze, triage, and resolve diverse HotSpot VM issues

  • Troubleshooting out of memory errors, Java level deadlocks, and HotSpot VM crashes

  • Extending the Serviceability Agent, and using the Plugin for VisualVM

  • Mastering useful HotSpot VM command line options not covered in Java™ Performance

  • Java® Performance Companion can help you squeeze maximum performance and value from Java with JDK 8 or 9–for any application, in any environment.

    Register your product at for convenient access to downloads, updates, and corrections as they become available. 

    Table of Contents

    1. About This E-Book
    2. Title Page
    3. Copyright Page
    4. Contents
    5. Preface
      1. References
    6. Acknowledgments
      1. Charlie Hunt
      2. Monica Beckwith
      3. Poonam Parhar
      4. Bengt Rutisson
    7. About the Authors
    8. 1. Garbage First Overview
      1. Terminology
      2. Parallel GC
      3. Serial GC
      4. Concurrent Mark Sweep (CMS) GC
        1. Summary of the Collectors
      5. Garbage First (G1) GC
        1. G1 Design
        2. Humongous Objects
        3. Full Garbage Collections
        4. Concurrent Cycle
        5. Heap Sizing
      6. References
    9. 2. Garbage First Garbage Collector in Depth
      1. Background
      2. Garbage Collection in G1
      3. The Young Generation
      4. A Young Collection Pause
      5. Object Aging and the Old Generation
      6. Humongous Regions
      7. A Mixed Collection Pause
      8. Collection Sets and Their Importance
      9. Remembered Sets and Their Importance
        1. Concurrent Refinement Threads and Barriers
      10. Concurrent Marking in G1 GC
      11. Stages of Concurrent Marking
        1. Initial Mark
        2. Root Region Scanning
        3. Concurrent Marking
        4. Remark
        5. Cleanup
      12. Evacuation Failures and Full Collection
      13. References
    10. 3. Garbage First Garbage Collector Performance Tuning
      1. The Stages of a Young Collection
        1. Start of All Parallel Activities
        2. External Root Regions
        3. Remembered Sets and Processed Buffers
        4. Summarizing Remembered Sets
        5. Evacuation and Reclamation
        6. Termination
        7. Parallel Activity Outside of GC
        8. Summarizing All Parallel Activities
        9. Start of All Serial Activities
        10. Other Serial Activities
      2. Young Generation Tunables
      3. Concurrent Marking Phase Tunables
      4. A Refresher on the Mixed Garbage Collection Phase
      5. The Taming of a Mixed Garbage Collection Phase
      6. Avoiding Evacuation Failures
      7. Reference Processing
        1. Observing Reference Processing
        2. Reference Processing Tuning
      8. References
    11. 4. The Serviceability Agent
      1. What Is the Serviceability Agent?
      2. Why Do We Need the SA?
      3. SA Components
      4. SA Binaries in the JDK
      5. JDK Versions with Complete SA Binaries
      6. How the SA Understands HotSpot VM Data Structures
      7. SA Version Matching
      8. The Serviceability Agent Debugging Tools
        1. HSDB
        2. HSDB Tools
        3. CLHSDB
        4. Some Other Tools
      9. Core Dump or Crash Dump Files
      10. Debugging Transported Core Files
        1. Shared Library Problems with the SA
        2. Eliminate Shared Library Problems
      11. System Properties for the Serviceability Agent
      12. Environment Variables for the Serviceability Agent
      13. JDI Implementation
      14. Extending Serviceability Agent Tools
      15. Serviceability Agent Plugin for VisualVM
        1. How to Install the SA-Plugin in VisualVM
        2. How to Use the SA-Plugin
        3. SA-Plugin Utilities
      16. Troubleshooting Problems Using the SA
        1. Diagnosing OutOfMemoryError
        2. Diagnosing a Java-Level Deadlock
        3. Postmortem Analysis of a HotSpot VM Crash
    12. Appendix: Additional HotSpot VM Command-Line Options of Interest
    13. Index
    14. Code Snippets