Java Performance: The Definitive Guide

Similar documents
Java Performance Tuning and Optimization Student Guide

Efficient Android Threading

Kodewerk. Java Performance Services. The War on Latency. Reducing Dead Time Kirk Pepperdine Principle Kodewerk Ltd.

JVM Memory Model and GC

Enterprise JavaBeans 3.1

THE TROUBLE WITH MEMORY

New Features Overview

Java 8 Programming for OO Experienced Developers

Practicing at the Cutting Edge Learning and Unlearning about Performance. Martin Thompson

Welcome to the session...

SPECjAppServer2002 Statistics. Methodology. Agenda. Tuning Philosophy. More Hardware Tuning. Hardware Tuning.

JAVA PERFORMANCE. PR SW2 S18 Dr. Prähofer DI Leopoldseder

Diplomado Certificación

TH IRD EDITION. Python Cookbook. David Beazley and Brian K. Jones. O'REILLY. Beijing Cambridge Farnham Köln Sebastopol Tokyo

Running class Timing on Java HotSpot VM, 1

High Performance Python Micha Gorelick and Ian Ozsvald

Lesson 2 Dissecting Memory Problems

Top Ten Enterprise Java performance problems. Vincent Partington Xebia

[Course Overview] After completing this module you are ready to: Develop Desktop applications, Networking & Multi-threaded programs in java.

ORACLE ENTERPRISE MANAGER 10g ORACLE DIAGNOSTICS PACK FOR NON-ORACLE MIDDLEWARE

Courses For Event Java Advanced Summer Training 2018

Architecting Java solutions for CICS

Servlet Performance and Apache JServ

Concurrent Garbage Collection

J2EE: Best Practices for Application Development and Achieving High-Volume Throughput. Michael S Pallos, MBA Session: 3567, 4:30 pm August 11, 2003

Compiler construction 2009

High-Level Language VMs

DNWSH - Version: 2.3..NET Performance and Debugging Workshop

White Paper. Major Performance Tuning Considerations for Weblogic Server

Diagnostics in Testing and Performance Engineering

SUN Sun Certified Enterprise Architect for J2EE 5. Download Full Version :

IBM WebSphere Application Server V4.0. Performance. 10/02/01 Copyright 2001 IBM Corporation WS40ST11.prz Page 248 of of 28

New Java performance developments: compilation and garbage collection

System Administration of PTC Windchill 11.0

Efficient Java (with Stratosphere) Arvid Heise, Large Scale Duplicate Detection

Fundamentals of GC Tuning. Charlie Hunt JVM & Performance Junkie

Oracle Fusion Middleware

Programming Windows Azure

generate-jvm-report shows the threads, classes, memory, and loggers for a given target instance. Name Synopsis

Java EE 7: Back-End Server Application Development

Borland Optimizeit Enterprise Suite 6

Java Performance Tuning From A Garbage Collection Perspective. Nagendra Nagarajayya MDE

Evolution of Virtual Machine Technologies for Portability and Application Capture. Bob Vandette Java Hotspot VM Engineering Sept 2004

ORACLG. Oracle Press. Advanced Tuning for. JD Edwards EnterpriseOne. Implementations

WebLogic Server- Tips & Tricks for Troubleshooting Performance Issues. By: Abhay Kumar AST Corporation

TIBCO BusinessEvents Extreme. System Sizing Guide. Software Release Published May 27, 2012

IBM Tivoli Composite Application Manager for Microsoft Applications: Microsoft.NET Framework Agent Fix Pack 13.

"Charting the Course... Java Programming Language. Course Summary

1Z Oracle. Java Enterprise Edition 5 Enterprise Architect Certified Master

Oracle WebCenter Portal Performance Tuning

Towards High Performance Processing in Modern Java-based Control Systems. Marek Misiowiec Wojciech Buczak, Mark Buttner CERN ICalepcs 2011

1 Performance Optimization in Java/J2EE

Tuning Performance of Oracle WebLogic Server 12c (12.2.1)

JBoss Performance Tuning. Bill Meyer JBoss Sr. Solutions Architect

Oracle - Developing Applications for the Java EE 7 Platform Ed 1 (Training On Demand)

OS-caused Long JVM Pauses - Deep Dive and Solutions

Fast Track to EJB 3.0 and the JPA Using JBoss

Advanced Object-Oriented Programming Introduction to OOP and Java

Application Management Webinar. Daniela Field

Runtime Application Self-Protection (RASP) Performance Metrics

Course Content for Java J2EE

CO Java EE 7: Back-End Server Application Development

Page 1

Java On Steroids: Sun s High-Performance Java Implementation. History

Programming C# 5.0. Ian Griffiths O'REILLY' Beijing Cambridge * Farnham Kbln Sebastopol Tokyo

Java: framework overview and in-the-small features

A Trace-based Java JIT Compiler Retrofitted from a Method-based Compiler

Course: JBoss Training: JBoss AS 7 and JBoss EAP 6 Administration and Clustering Training

Garbage collection. The Old Way. Manual labor. JVM and other platforms. By: Timo Jantunen

J2EE Performance Tuning. Jayesh Patel Northern Virginia Java/BEA User Group January 11 th, 2005.

Oracle WebLogic Server 11g: Diagnostics and Troubleshooting

object/relational persistence What is persistence? 5

JAVA Training Overview (For Demo Classes Call Us )

Java Training For Six Weeks

Java SE7 Fundamentals

NG2C: Pretenuring Garbage Collection with Dynamic Generations for HotSpot Big Data Applications

TUTORIAL: WHITE PAPER. VERITAS Indepth for the J2EE Platform PERFORMANCE MANAGEMENT FOR J2EE APPLICATIONS

generate-jvm-report shows the threads, classes, memory, and loggers for a given target instance. Name Synopsis

Pro JPA 2. Mastering the Java Persistence API. Apress* Mike Keith and Merrick Schnicariol

JDK 9/10/11 and Garbage Collection

Java SE 8 Programming

Introduction... xv SECTION 1: DEVELOPING DESKTOP APPLICATIONS USING JAVA Chapter 1: Getting Started with Java... 1

It s Good to Have (JVM) Options

JBOSS AS 7 AND JBOSS EAP 6 ADMINISTRATION AND CLUSTERING (4 Days)

CORE JAVA. Saying Hello to Java: A primer on Java Programming language

Agenda. CSE P 501 Compilers. Java Implementation Overview. JVM Architecture. JVM Runtime Data Areas (1) JVM Data Types. CSE P 501 Su04 T-1

TIBCO ActiveSpaces Transactions. System Sizing Guide. Software Release Published February 15, 2017

Managed runtimes & garbage collection. CSE 6341 Some slides by Kathryn McKinley

TIBCO BusinessEvents Extreme. System Sizing Guide. Software Release Published February 17, 2015

ΠΙΝΑΚΑΣ ΠΛΑΝΟΥ ΕΚΠΑΙΔΕΥΣΗΣ

The Fundamentals of JVM Tuning

Implementing a Web Service p. 110 Implementing a Web Service Client p. 114 Summary p. 117 Introduction to Entity Beans p. 119 Persistence Concepts p.

Contents at a Glance. vii

This course is intended for Java programmers who wish to write programs using many of the advanced Java features.

Java performance - not so scary after all

Java Platform, Standard Edition Java Virtual Machine Guide. Release 9

Managed runtimes & garbage collection

ORACLE DATA SHEET KEY FEATURES AND BENEFITS ORACLE WEBLOGIC SUITE

Java SE 8 Programming

A Quest for Predictable Latency Adventures in Java Concurrency. Martin Thompson

Transcription:

Java Performance: The Definitive Guide Scott Oaks Beijing Cambridge Farnham Kbln Sebastopol Tokyo O'REILLY

Table of Contents Preface ix 1. Introduction 1 A Brief Outline 2 Platforms and Conventions 2 JVM Tuning Flags 4 The Complete Performance Story 5 Write Better Algorithms 5 Write Less Code 6 Oh Go Ahead, Prematurely Optimize 7 Look Elsewhere: The Database Is Always the Bottleneck 8 Optimize for the Common Case 9 Summary 10 2. An Approach to Performance Testing 11 Test a Real Application 11 Microbenchmarks 11 Macrobenchmarks 16 Mesobenchmarks 18 Common Code Examples 20 Understand Throughput, Batching, and Response Time 24 Elapsed Time (Batch) Measurements 24 Throughput Measurements 25 Response Time Tests 26 Understand Variability 29 Test Early, Test Often 33 Summary 36 3. A Java Performance Toolbox 37 Operating System Tools and Analysis 37 iii

CPU Usage 38 The CPU Run Queue 41 Disk Usage 43 Network Usage 44 Java Monitoring Tools 46 Basic VM Information 47 Thread Information 50 Class Information 51 Live GC Analysis 51 Heap Dump Postprocessing 51 Profiling Tools 51 Sampling Profilers 52 Instrumented Profilers 54 Blocking Methods and Thread Timelines 55 Native Profilers 57 Java Mission Control 59 Java Flight Recorder 60 Enabling JFR 66 Selecting JFR Events 70 Summary 72 Working with the JIT Compiler 73 Just-in-Time Compilers: An Overview 73 Hot Spot Compilation 75 Basic Tunings: Client or Server (or Both) 77 Optimizing Startup 78 Optimizing Batch Operations 80 Optimizing Long-Running Applications 81 Java and JIT Compiler Versions 81 Intermediate Tunings for the Compiler 85 Tuning the Code Cache 85 Compilation Thresholds 87 Inspecting the Compilation Process 90 Advanced Compiler Tunings 94 Compilation Threads 94 Inlining 96 Escape Analysis 97 Deoptimization 98 Not Entrant Code 98 Deoptimizing Zombie Code 101 Tiered Compilation Levels 101 iv Table ofcontents

Summary 103 5. An Introduction to Garbage Collection 105 Garbage Collection Overview 105 Generational Garbage Collectors 107 GC Algorithms 109 Choosing a GC Algorithm 113 Basic GC Tuning 119 Sizing the Heap 119 Sizing the Generations 122 Sizing Permgen and Metaspace 124 Controlling Parallelism 126 Adaptive Sizing 127 GC Tools 128 Summary 131 6. Garbage Collection Algorithms 133 Understanding the Throughput Collector 13 3 Adaptive and Static Heap Size Tuning 136 Understanding the CMS Collector 140 Tuning to Solve Concurrent Mode Failures 145 Tuning CMS for Permgen 148 Incremental CMS 149 Understanding the G1 Collector 150 Tuning Gl 157 Advanced Tunings 159 Tenuring and Survivor Spaces 159 Allocating Large Objects 163 AggressiveHeap 171 Full Control Over Heap Size 173 Summary 174 7. Heap Memory Best Practices 177 Heap Analysis 177 Heap Histograms 178 Heap Dumps 179 Out of Memory Errors 184 Using Less Memory 188 Reducing Object Size 188 Lazy Initialization 191 Immutable and Canonical Objects 196 String Interning 198 Tableof Contents v

Object Lifecycle Management Object Reuse Weak, Soft, and Other References 208 Summary 8. Native Memory Best Practices 223 Footprint Measuring Footprint Minimizing Footprint Native NIO Buffers 226 Native Memory Tracking 227 JVM Tunings for the Operating System 230 Large Pages Compressed oops 234 Summary 236 9. Threading and Synchronization Performance 237 Thread Pools and ThreadPoolExecutors 237 Setting the Maximum Number of Threads 238 Setting the Minimum Number of Threads 242 Thread Pool Task Sizes 243 Sizing a ThreadPoolExecutor 244 The ForkJoinPool 246 Automatic Parallelization 252 Thread Synchronization 254 Costs of Synchronization 254 Avoiding Synchronization 259 False Sharing 262 JVM Thread Tunings 267 Tuning Thread Stack Sizes 267 Biased Locking 268 Lock Spinning 268 Thread Priorities 269 Monitoring Threads and Locks 270 Thread Visibility 270 Blocked Thread Visibility 271 Summary 275 202 202 221 223 224 225 230 10. Java Enterprise Edition Performance 277 Basic Web Container Performance 277 HTTP Session State 280 Thread Pools 283 vi Table ofcontents

Enterprise Java Session Beans 283 Tuning EJB Pools 283 Tuning EJB Caches 286 Local and Remote Instances 288 XML and JSON Processing 289 Data Size 290 An Overview of Parsing and Marshalling 291 Choosing a Parser 293 XML Validation 299 Document Models 302 Java Object Models 305 Object Serialization 307 Transient Fields 307 Overriding Default Serialization 307 Compressing Serialized Data 311 Keeping Track of Duplicate Objects 313 Java EE Networking APIs 316 Sizing Data Transfers 316 Summary 319 11. Database Performance Best Practices 321 JDBC 322 JDBC Drivers 322 Prepared Statements and Statement Pooling 324 JDBC Connection Pools 326 Transactions 327 Result Set Processing 335 JPA 337 Transaction Handling 337 Optimizing JPA Writes 340 Optimizing JPA Reads 342 JPA Caching 346 JPA Read-Only Entities 352 Summary 353 12. Java SE API Tips 355 Buffered I/O 355 Classloading 358 Random Numbers 362 Java Native Interface 364 Exceptions 366 String Performance 370 Table of Contents vii

Logging 3/1 Java Collections API 373 Synchronized Versus Unsynchronized 373 Collection Sizing 375 Collections and Memory Efficiency 376 AggressiveOpts 378 Alternate Implementations 3 78 Miscellaneous Flags 379 Lambdas and Anonymous Classes 379 Lambda and Anonymous Classloading 381 Stream and Filter Performance 382 Lazy Traversal 3 83 Summary 385 A. Summary of Tuning Flags 387 Index 397 viii Tableof Contents