Share E-Book
Scan to open this page

Scan with your phone to open this page

AuthorScott Oaks

Coding and testing are generally considered separate areas of expertise. In this practical book, Java expert Scott Oaks takes the approach that anyone who works with Java should be adept at understanding how code behaves in the Java Virtual Machine—including the tunings likely to help performance. This updated second edition helps you gain in-depth knowledge of Java application performance using both the JVM and the Java platform. Developers and performance engineers alike will learn a variety of features, tools, and processes for improving the way the Java 8 and 11 LTS releases perform. While the emphasis is on production-supported releases and features, this book also features previews of exciting new technologies such as ahead-of-time compilation and experimental garbage collections. • Understand how various Java platforms and compilers affect performance • Learn how Java garbage collection works • Apply four principles to obtain best results from performance testing • Use the JDK and other tools to learn how a Java application is performing • Minimize the garbage collector’s impact through tuning and programming practices • Tackle performance issues in Java APIs • Improve Java-driven database application performance

AI Reading Assistant

Whole-book reading guide from stratified index samples; jump to passages in the text

AI guide
【One-Line Pitch】 A practical, evidence-driven guide to making Java 8 and 11 applications faster by understanding what actually happens inside the JVM—written for developers and performance engineers who want to tune with data rather than folklore. 【Book Arc】 - **Opening (~0%–10%)**: Sets the philosophy—performance is mostly about writing better algorithms and less code, not hunting for a magic JVM flag; introduces the two knowledge domains (JVM behavior and Java platform behavior). - **Early (~10%–35%)**: Builds the measurement foundation: the four principles of performance testing, warm-up and JIT effects, choosing throughput vs. batch vs. response-time metrics, statistical rigor, and using JMH to avoid common benchmarking traps. - **Middle (~35%–55%)**: Equips you with a toolbox—OS-level analysis (e.g., iostat), JVM flag inspection via jinfo, and Java Flight Recorder/Mission Control for low-overhead profiling of GC, code, exceptions, and compilation. - **Late (~55%–85%)**: Moves into the JVM internals that dominate real performance: how the JIT compiles and optimizes bytecode, and how garbage collectors work and can be tuned to reduce pause and overhead. - **Ending (~85%–100%)**: Applies the knowledge to the Java platform itself—performance pitfalls in core APIs (collections, strings, logging) and in database-driven applications—closing the loop from measurement to code-level practice. 【Key Takeaways】 - **Write better algorithms first** (Opening): No JVM optimization can beat a fundamentally better data structure or algorithm; tuning flags cannot rescue poor design. - **Less code is faster code** (Opening): Fewer classes, objects, and executed instructions mean faster startup, less GC pressure, and better cache behavior—the "death by 1,000 cuts" of incremental bloat. - **Measure with the right metric** (Early): Throughput, elapsed/batch time, and response time are interrelated but serve different goals; picking the wrong one leads to optimizing the wrong thing. - **Warm-up is unavoidable in Java** (Early): JIT compilation, JPA caches, and OS file caching mean early measurements mislead; benchmark only after code reaches steady state. - **Use JMH and statistics, not ad-hoc loops** (Early): Proper warm-up iterations, forking, parameterization, and confidence intervals turn noisy guesses into defensible results. - **Don't tune flags blindly** (Middle): Hundreds of JVM flags exist, but most are for support engineers; change a flag only with a compelling, evidence-backed reason, and remember many are not dynamically manageable. - **JFR gives low-overhead visibility** (Middle): Java Flight Recorder exposes GC events, hot methods, exceptions, and compiler activity, making it a first stop for diagnosing production behavior. - **GC and JIT are the dominant JVM levers** (Late): Understanding tiered compilation and garbage collection behavior—and tuning or programming around them—delivers the largest JVM-side gains. 【Reading Tips】 - **Deep-read the testing chapters (Early)**: The four principles and JMH material are the foundation for every later claim; skimming here undermines the rest. - **Skim the tool catalog (Middle)**: Treat jinfo, iostat, and JFR sections as a reference to return to when diagnosing a specific problem, not as linear reading. - **Pair GC and JIT chapters with your own workload**: The concepts matter more than memorizing flags; test tuning ideas against a real application. - **Read the API and database chapters last, with your codebase in mind**: They are most useful as a checklist for auditing existing code rather than as abstract theory. 【Coverage Limits】 These excerpts emphasize the book's opening philosophy, performance-testing methodology, and tooling; the later JVM internals (GC, JIT) and Java API/database chapters are represented only by their stated scope, so this guide does not detail their specific techniques.
Page 9
394 Collections and Memory Efficiency 395 Lambdas and Anonymous Classes 397 Stream and Filter Performance 399 Lazy Traversal 399 Object Serialization 402 Tra...
View in text
Excerpt 2
and operate at peak performance. For that (and other) rea‐ sons, performance studies of Java are concerned about warm-up periods: perfor‐ mance is most often...
View in text
Excerpt 3
esponse: @GET @Produces(MediaType.APPLICATION_JSON) public JsonObject getStockInfo( @DefaultValue("" + StockPriceHistory.STANDARD) @QueryParam("impl") int im...
View in text
Excerpt 4
le JFR recordings have been enabled for a given process. To see the available recordings: % jcmd 21532 JFR.check [verbose] 21532: Recording 1: name=1 maxsize...
View in text
Excerpt 5
iled (rather than continuing to execute in the interpreter). Background compilation is also disabled when -Xbatch is specified. 108 | Chapter 4: Working with...
View in text
Excerpt 6
for the initial and max‐ imum sizes are given in Table 5-9. The JVM will round these values down slightly for alignment purposes; the GC logs that print the...
View in text
Excerpt 7
[GC pause (young) (to-space overflow), 0.41546900 secs] [60.238s][info][gc,start ] GC(28) Pause Young (Concurrent Start) (G1 Evacuation Pause) [60.238s][info...
View in text
Excerpt 8
of the G1 GC region will make G1 GC a little more efficient in this example; select a value so that there will be close to 2,048 regions at the expected heap...
View in text
Tags
AI categories
JavaProgrammingSoftware
ISBN: 1492056111
Publisher: O'Reilly Media
Publish Year: 2020
Language: English
Pages: 450
File Format: PDF
File Size: 9.4 MB
Text Preview (First 20 pages)
Registered users can read the full content for free

Register as a Gaohf Library member to read the complete e-book online for free and enjoy a better reading experience.

Generating text preview…