JVM Performance Engineering: Inside the OpenJDK Hotspot VM, 1st edition

Published by Addison-Wesley Professional (April 9, 2024) © 2024

  • Monica Beckwith

eTextbook

£29.99

This comprehensive guide to Java Virtual Machine (JVM) performance engineering is an indispensable resource for every experienced Java developer. World-renowned Java performance expert Monica Beckwith focuses specifically on the OpenJDK HotSpot VM, thoroughly demystifies complex aspects of JVM performance, shares powerful diagnosis techniques, and helps you implement effective optimizations throughout your own code.

First, Beckwith reviews the evolution of Java and the JVM, illuminating garbage collection strategies, parallel and concurrent GC threads, and their performance implications. Next, she expertly discusses the Java type system's evolution, its impact on performance and efficiency, and potential Project Valhalla enhancements. Beckwith shows how to transform monolithic Java applications to the modern, modular Java paradigm, updating project structures, ensuring dependency compatibility, and managing modules to optimize performance. You'll learn how to make the most of the Unified Java Virtual Machine Logging Interface to maximize process visibility and control, and improve debugging and performance testing.

With these foundations in place, Beckwith introduces techniques for end-to-end Java performance optimization, including micro-benchmarking to assess and enhance the performance of any Java code. Beckwith provides in-depth coverage of advanced memory management in OpenJDK, showing how to leverage recent JDK optimizations and algorithms, and make the most of Thread-Local Allocation Buffers (TLABs) and Non-Uniform Memory Architecture (NUMA). A full chapter on runtime performance optimization includes a preview of the future of concurrency with Project Loom. Beckwith concludes with advanced techniques for accelerating app startup with OpenJDK, including up-to-date coverage of Elastic Metaspace, Project Leyden, and GraalVM.

Preface xv
Acknowledgments xxiii
About the Author xxvii

Chapter 1: The Performance Evolution of Java: The Language and the Virtual Machine 1
A New Ecosystem Is Born 2
A Few Pages from History 2
Understanding Java HotSpot VM and Its Compilation Strategies 3
HotSpot Garbage Collector: Memory Management Unit 13
The Evolution of the Java Programming Language and Its Ecosystem: A Closer Look 18
Embracing Evolution for Enhanced Performance 42

Chapter 2: Performance Implications of Java's Type System Evolution 43
Java's Primitive Types and Literals Prior to J2SE 5.0 44
Java's Reference Types Prior to J2SE 5.0 45
Java's Type System Evolution from J2SE 5.0 until Java SE 8 49
Java's Type System Evolution: Java 9 and Java 10 52
Java's Type System Evolution: Java 11 to Java 17 55
Beyond Java 17: Project Valhalla 58
Conclusion 68

Chapter 3: From Monolithic to Modular Java: A Retrospective and Ongoing Evolution 69
Introduction 69
Understanding the Java Platform Module System 70
From Monolithic to Modular: The Evolution of the JDK 78
Continuing the Evolution: Modular JDK in JDK 11 and Beyond 78
Implementing Modular Services with JDK 17 78
JAR Hell Versioning Problem and Jigsaw Layers 83
Open Services Gateway Initiative 91
Introduction to Jdeps, Jlink, Jdeprscan, and Jmod 93
Conclusion 96

Chapter 4: The Unified Java Virtual Machine Logging Interface 99
The Need for Unified Logging 99
Unification and Infrastructure 100
Tags in the Unified Logging System 101
Diving into Levels, Outputs, and Decorators 103
Practical Examples of Using the Unified Logging System 107
Optimizing and Managing the Unified Logging System 109
Asynchronous Logging and the Unified Logging System 110
Understanding the Enhancements in JDK 11 and JDK 17 113
Conclusion 113

Chapter 5: End-to-End Java Performance Optimization: Engineering Techniques and Micro-benchmarking with JMH 115
Introduction 115
Performance Engineering: A Central Pillar of Software Engineering 116
Metrics for Measuring Java Performance 118
The Role of Hardware in Performance 128
Performance Engineering Methodology: A Dynamic and Detailed Approach 145
The Importance of Performance Benchmarking 158
Conclusion 175

Chapter 6: Advanced Memory Management and Garbage Collection in OpenJDK 177
Introduction 177
Overview of Garbage Collection in Java 178
Thread-Local Allocation Buffers and Promotion-Local Allocation Buffers 179
Optimizing Memory Access with NUMA-Aware Garbage Collection 181
Exploring Garbage Collection Improvements 183
Future Trends in Garbage Collection 210
Practical Tips for Evaluating GC Performance 212
Evaluating GC Performance in Various Workloads 214
Live Data Set Pressure 216

Chapter 7: Runtime Performance Optimizations: A Focus on Strings, Locks, and Beyond 219
Introduction 219
String Optimizations 220
Enhanced Multithreading Performance: Java Thread Synchronization 236
Transitioning from the Thread-per-Task Model to More Scalable Models 259
Conclusion 270

Chapter 8: Accelerating Time to Steady State with OpenJDK HotSpot VM 273
Introduction 273
JVM Start-up and Warm-up Optimization Techniques 274
Decoding Time to Steady State in Java Applications 274
Managing State at Start-up and Ramp-up 278
GraalVM: Revolutionizing Java's Time to Steady State 290
Emerging Technologies: CRIU and Project CRaC for Checkpoint/Restore Functionality 292
Start-up and Ramp-up Optimization in Serverless and Other Environments 295
Boosting Warm-up Performance with OpenJDK HotSpot VM 300
Conclusion 306

Chapter 9: Harnessing Exotic Hardware: The Future of JVM Performance Engineering 307
Introduction to Exotic Hardware and the JVM 307
Exotic Hardware in the Cloud 309
The Role of Language Design and Toolchains 312
Case Studies 313
Envisioning the Future of JVM and Project Panama 333
Concluding Thoughts: The Future of JVM Performance Engineering 336

Index 337

Monica Beckwith (Austin, TX Area) is a Java Champion and JavaOne Rock Star who has made significant performance contributions to the Java HotSpot VM. Prior to joining Microsoft as Senior Performance Engineer, she served as JVM Performance Architect at Arm, and led Oracle's Garbage First Garbage Collector performance team. She is co-author of Java Performance Companion.

Need help? Get in touch

Video
Play
Privacy and cookies
By watching, you agree Pearson can share your viewership data for marketing and analytics for one year, revocable by deleting your cookies.

Pearson eTextbook: What’s on the inside just might surprise you

They say you can’t judge a book by its cover. It’s the same with your students. Meet each one right where they are with an engaging, interactive, personalized learning experience that goes beyond the textbook to fit any schedule, any budget, and any lifestyle.