Book description
Performance has been an important issue for Java developers ever since the first version hit the streets. Over the years, Java performance has improved dramatically, but tuning is essential to get the best results, especially for J2EE applications. You can never have code that runs too fast.Java Peformance Tuning, 2nd edition provides a comprehensive and indispensable guide to eliminating all types of performance problems. Using many real-life examples to work through the tuning process in detail, JPT shows how tricks such as minimizing object creation and replacing strings with arrays can really pay off in improving your code's performance.Tuning J2EE applications bears many similarities to tuning J2SE apps, but important and specific considerations apply. For this reason, Java Performance Tuning, Second Edition includes four new chapters: a new chapter on J2EE application tuning in general followed by chapters on tuning JDBC, servlets and JSPs, and EJBs.Java Performance Tuning offers common-sense advice about what to tune and what to leave alone, emphasizing techniques that provide big performance gains with minimal code restructuring. It gives you crucial guidance that helps you tune without destroying your program's architecture. Blindly changing things in an effort to make a program run faster is a great way to create buggy, unmaintainable code. Java Performance Tuning teaches you to work efficiently and effectively, resulting in code that is robust, maintainable, and fast.Java Performance Tuning, Second Edition shows you how to:
- Create a performance plan
- Glean information about your program's behavior from profiling tools
- Identify bottlenecks before tuning
- Minimize the number of objects your program creates, particularly critical for J2EE applications
- Optimize the use of strings
- Avoid performance penalties from inefficient code
- Improve the behavior of loops and switches
- Optimize I/O behavior
- Use appropriate algorithms for sorting and other common tasks
- Use threads effectively
- Optimize the performance of distributed systems
- Speed up servlets and JSPs
- Structure JDBC usage efficiently
- Use effective design patterns to optimize EJB performance
Publisher resources
Table of contents
- A Note Regarding Supplemental Files
- Copyright
- Preface
- 1. Introduction
- 2. Profiling Tools
-
3. Underlying JDK Improvements
- 3.1. Garbage Collection
- 3.2. Tuning the Heap
- 3.3. Gross Tuning
- 3.4. Fine-Tuning the Heap
- 3.5. Sharing Memory
- 3.6. Replacing JDK Classes
- 3.7. Faster VMs
-
3.8. Better Optimizing Compilers
- 3.8.1. What Optimizing Compilers Cannot Do
-
3.8.2. What Optimizing Compilers Can Do
- 3.8.2.1. Remove unused methods and classes
- 3.8.2.2. Increase statically bound calls
- 3.8.2.3. Cut dead code and unnecessary instructions, including checks for null
- 3.8.2.4. Use computationally cheaper alternatives (strength reduction)
- 3.8.2.5. Replace runtime computations with compiled results
- 3.8.2.6. Remove unused fields
- 3.8.2.7. Remove unnecessary parts of compiled files
- 3.8.2.8. Reduce necessary parts of compiled files
- 3.8.2.9. Alter access control to speed up invocations
- 3.8.2.10. Inline calls
- 3.8.2.11. Remove dynamic type checks
- 3.8.2.12. Unroll loops
- 3.8.2.13. Code motion
- 3.8.2.14. Eliminate common subexpressions
- 3.8.2.15. Eliminate unnecessary assignments
- 3.8.2.16. Rename classes, fields, and methods
- 3.8.2.17. Reorder or change bytecodes
- 3.8.2.18. Generate information to help a VM
- 3.8.3. Managing Compilers
- 3.9. Sun’s Compiler and Runtime Optimizations
- 3.10. Compile to Native Machine Code
- 3.11. Native Method Calls
- 3.12. Uncompressed ZIP/JAR Files
- 3.13. Performance Checklist
- 4. Object Creation
- 5. Strings
- 6. Exceptions, Assertions, Casts, and Variables
- 7. Loops, Switches, and Recursion
- 8. I/O, Logging, and Console Output
- 9. Sorting
- 10. Threading
-
11. Appropriate Data Structures and Algorithms
- 11.1. Collections
- 11.2. Java 2 Collections
- 11.3. Hashtables and HashMaps
-
11.4. Optimizing Queries
-
11.4.1. The Query Problem
- 11.4.1.1. Applying the Boolean-OR operator optimization
- 11.4.1.2. Eliminating the unnecessarily repeated method call
- 11.4.1.3. Eliminating casts and extra access calls
- 11.4.1.4. Avoiding synchronization
- 11.4.1.5. Avoiding the method accessor
- 11.4.1.6. Tighter typing of the collection elements
- 11.4.1.7. Optimizing map queries
-
11.4.1. The Query Problem
- 11.5. Comparing LinkedLists and ArrayLists
- 11.6. The RandomAccess Interface
- 11.7. Cached Access
- 11.8. Caching Examples
- 11.9. Finding the Index for Partially Matched Strings
- 11.10. Search Trees
- 11.11. Performance Checklist
-
12. Distributed Computing
- 12.1. Tools
- 12.2. Message Reduction
- 12.3. Comparing Communications Layers
- 12.4. Caching
- 12.5. Batching I
- 12.6. Application Partitioning
- 12.7. Batching II
- 12.8. Low-Level Communication Optimizations
- 12.9. Distributed Garbage Collection
- 12.10. Databases
- 12.11. Web Services
- 12.12. Performance Checklist
-
13. When to Optimize
- 13.1. When Not to Optimize
- 13.2. Tuning Class Libraries and Beans
- 13.3. Analysis
-
13.4. Design and Architecture
- 13.4.1. Shared Resources
- 13.4.2. Scaling
- 13.4.3. Distributed Applications
- 13.4.4. Object Design
-
13.4.5. Techniques for Predicting Performance
- 13.4.5.1. Factor in comparative performance of operations
- 13.4.5.2. Consider the relative costs of different types of accesses and updates
- 13.4.5.3. Use simulations and benchmarks
- 13.4.5.4. Consider the total work done and the design overhead
- 13.4.5.5. Focus on shared resources
- 13.4.5.6. Predict the effects of parallelism
- 13.4.5.7. Assess the costs of data conversions
- 13.4.5.8. Determine whether batch processing is faster
- 13.5. Tuning After Deployment
- 13.6. More Factors That Affect Performance
- 13.7. Performance Planning
- 13.8. Performance Checklist
- 14. Underlying Operating System and Network Improvements
-
15. J2EE Performance Tuning
- 15.1. Performance Planning
- 15.2. J2EE Monitoring and Profiling Tools
- 15.3. Measurements: What, Where, and How
- 15.4. Load Testing
- 15.5. User Perception
-
15.6. Clustering and Load Balancing
-
15.6.1. Load-Balancing Mechanisms
- 15.6.1.1. DNS load balancing
- 15.6.1.2. Hardware load balancer
- 15.6.1.3. Load-balancing dispatcher/Proxy load balancing
- 15.6.1.4. URL-based load balancing
- 15.6.1.5. Server-pooled objects
- 15.6.1.6. Client-based load balancing
- 15.6.1.7. Application configuration load balancing
- 15.6.1.8. Database partitioning
- 15.6.2. Load-Balancing Algorithms
-
15.6.1. Load-Balancing Mechanisms
- 15.7. Tuning JMS
- 15.8. Performance Checklist
-
16. Tuning JDBC
- 16.1. Measuring JDBC Performance
-
16.2. Tuning JDBC
- 16.2.1. JDBC Drivers
- 16.2.2. Connection Pooling
- 16.2.3. Optimizing SQL
- 16.2.4. Set-Based Processing
- 16.2.5. Database Server-Side Processing
- 16.2.6. Minimizing Transferred Data
- 16.2.7. Caching
- 16.2.8. Prepared Statements
- 16.2.9. Batching
- 16.2.10. Data Structures
- 16.2.11. Minimizing Data-Conversion Overhead
- 16.2.12. Metadata
- 16.2.13. Handling Exceptions
- 16.2.14. Stored Procedures
- 16.2.15. Transaction Optimization
- 16.2.16. Database Location
- 16.3. Performance Checklist
-
17. Tuning Servlets and JSPs
- 17.1. Don’t Use SingleThreadModel
-
17.2. Efficient Page Creation and Output
- 17.2.1. Minimize Output and Logging
- 17.2.2. Use Strings Efficiently
- 17.2.3. Use Bytes Versus Chars
- 17.2.4. Use Network Buffers Efficiently
- 17.2.5. Display Static Pages Quickly
- 17.2.6. Optimize Data Conversions
- 17.2.7. Use ServletOutputStream Directly (Servlets Only)
- 17.2.8. Optimize Partial Page Display
- 17.3. Body Tags
- 17.4. Cache Tags
- 17.5. HttpSession
- 17.6. Compression
- 17.7. More Performance Tips
- 17.8. Case Study: Ace’s Hardware SPECmine Tool
- 17.9. Performance Checklist
-
18. Tuning EJBs
- 18.1. Primary Design Guidelines
-
18.2. Performance-Optimizing Design Patterns
- 18.2.1. Reducing the Number of Network Trips: The Value Object Pattern
- 18.2.2. Optimizing Database Access: The Data Access Object Pattern and the Fast Lane Reader Pattern
- 18.2.3. Efficiently Transferring Large Datasets: The Page-by-Page Iterator Pattern and the ValueListHandler Pattern
- 18.2.4. Caching Services: The Service Locator, Verified Service Locator, and EJBHomeFactory Patterns
- 18.2.5. Combining EJBs: The Session Façade and CompositeEntity Patterns
- 18.2.6. Reusing Objects: The Factory and Builder Patterns
- 18.2.7. Reducing Locking Conflicts: The Optimistic Locking Pattern
- 18.2.8. Load Balancing: The Reactor and Front Controller Patterns
- 18.2.9. Optimized Message Handling: The Proxy and Decorator Patterns
- 18.2.10. Optimizing CPU Usage: The Message Façade Pattern
- 18.3. The Application Server
- 18.4. More Suggestions for Tuning EJBs
- 18.5. Case Study: The Pet Store
- 18.6. Case Study: Elite.com
- 18.7. Performance Checklist
- 19. Further Resources
- About the Author
- Colophon
- Copyright
Product information
- Title: Java Performance Tuning, 2nd Edition
- Author(s):
- Release date: January 2003
- Publisher(s): O'Reilly Media, Inc.
- ISBN: 9780596003777
You might also like
book
Java Performance: The Definitive Guide
Coding and testing are often considered separate areas of expertise. In this comprehensive guide, author and …
book
Optimizing Java
Performance tuning is an experimental science, but that doesn’t mean engineers should resort to guesswork and …
video
Optimizing Java
With any comprehensive, large-scale programming language, if you’re not careful during your development processes, you can …
book
Java Performance Tuning
No matter what language they're programming in, developers always wish things would run faster! Especially when …