Java Performance: The Definitive Guide cover

Java Performance: The Definitive Guide

Rating 4.1
Chapters
13
Series
Turing Programming Series
ISBN
9787115413765

Tags

Summary

This book is a classic, practical guide to Java performance tuning, focused on Java 7 and Java 8, systematically covering every layer that affects the performance of Java applications. It begins with methodology, setting out four basic principles of performance testing: test real applications, understand batch elapsed time versus throughput and response time, use statistical methods to cope with performance variation, and test early and often, and analyzes the biases that microbenchmarks tend to introduce. It then introduces operating-system-level CPU, disk, and network analysis tools, the monitoring tools bundled with the JDK such as jcmd, jconsole, jstat, and jmap, and the use of sampling profilers, profiling profilers, Java Mission Control, and Java Flight Recorder. The core chapters center on the JIT compiler, explaining Client/Server compilation modes, code cache, compilation thresholds, inlining, escape analysis, deoptimization, and the tuning trade-offs of tiered compilation; then, progressing from the basics to the advanced, it thoroughly covers garbage collection, including the principles and parameter tuning of the throughput collector, CMS, and G1, and the settings for heap size, generation spaces, metaspace, promotion, and survivor spaces. The memory section discusses heap memory analysis and object lifecycle management (object reuse, weak references, and soft references), as well as native memory footprint, NIO buffers, native memory tracking, huge pages, and compressed oops. The book closes with coverage of thread pools and ForkJoinPool, the cost of synchronization and false sharing, biased locking and spin locks, Web containers and EJB tuning in Java EE, XML/JSON processing, serialization, JDBC and JPA database performance, and subtle pitfalls in the Java SE API such as buffered I/O, class loading, strings, logging, and collections.

Editor's review

市面上泛泛谈论「Java 优化」的书不少,但真正能把性能问题讲到可落地操作的并不多,这本是公认扎实的一本。它的价值在于「方法论优先」:先教你怎样设计一次可信的压测、如何读懂吞吐量与响应时间,再谈具体参数,避免读者一上来就陷入盲目调参。JIT 编译器、垃圾收集、堆与原生内存、线程与同步四个部分写得尤其细致,把 HotSpot 中那些平时只存在于碎片化博客里的机制与标志位串成了一条完整链路,配合作者 Scott Oaks 在 Oracle 性能团队的一线经验,解释往往能说到「为什么」而不只是「怎么设」。第 1 版基于 Java 7/8,虽然如今主流 JDK 已更新多代,垃圾收集器与工具链也有变化,但性能分析的思路、工具使用方式和内存模型基础依然适用,仍适合作为案头参考反复查阅。译者柳飞、陆明刚、臧秀涛是 Java 技术书译介的熟手,术语处理较为统一,读起来不算费劲。需要留意的是,若你所在团队已全面转向 Java 11 及以上,建议优先选择第 2 版以覆盖更成熟的 G1 与容器化场景。

Who it's for

A good fit for

  • 有 1~3 年 Java 开发经验、想系统补齐性能知识体系的工程师
  • 负责线上服务稳定性与 JVM 参数治理的后端或运维人员
  • 需要为项目制定压测方案与性能基线的技术负责人
  • 准备 Java 相关面试、想深入理解 JVM 机制的同学

Not a good fit for

  • 零基础、尚未写过一个完整 Java 项目的新手
  • 只想找现成参数模板、不愿理解原理的读者
  • 主要使用 Java 11 以上新版本、需要覆盖 GraalVM 与容器化调优的读者

Reading tips

  1. 先用第 1~3 章搭好测试与工具框架,不要跳过后直接翻参数章节
  2. 读 JIT 与 GC 章节时,在本机用 -XX:+PrintGCDetails 等参数做小实验,对照书中的指标理解
  3. 把「性能调优标志摘要」附录当字典,遇到具体问题再回查,不必通读一遍
  4. 若团队已升级到 Java 11 以上,可与第 2 版对照阅读,重点补齐 G1 与容器场景差异

About the publisher

Posts & Telecom Press China · Founded in 1953

Posts & Telecom Press is known for its strengths in science and technology, computing, and information and communications titles, and has extended its publishing into photography, art, software learning, and inspirational growth, giving it a fairly diverse range. Its catalog includes computing and communications works such as Refactoring and Patterns (Revised Edition) and Huawei Switch Learning Guide (Second Edition), alongside bilingual collector's editions such as The Little Prince (Chinese-English-French illustrated collector's edition), The Great Gatsby, and Three Days to See. Beijing Ten Years: 1980-1990 and Ghost Blade: WLOP Personal Illustration Collection reflect its presence in photography and art. Its authors include Antoine de Saint-Exupéry, Helen Keller, Joshua Kerievsky, Wang Da, Zhang Zhaozeng, and WLOP.

Contents

  1. Chapter 1 Introduction
  2. Chapter 2 Performance Testing Methodology
  3. Chapter 3 A Java Performance Toolbox
  4. Chapter 4 The JIT Compiler
  5. Chapter 5 An Introduction to Garbage Collection
  6. Chapter 6 Garbage Collection Algorithms
  7. Chapter 7 Heap Memory Best Practices
  8. Chapter 8 Native Memory Best Practices
  9. Chapter 9 Threading and Synchronization Performance
  10. Chapter 10 Java EE Performance Tuning
  11. Chapter 11 Database Performance Best Practices
  12. Chapter 12 Java SE API Tips
  13. Appendix A Performance Tuning Flags Summary

FAQ

这本书有第 2 版吗?该选哪一版?
有。第 1 版于 2016 年由人民邮电出版社出版,基于 Java 7 和 Java 8,译者为柳飞、陆明刚、臧秀涛;第 2 版于 2022 年出版,译者为党文亮,内容聚焦更成熟的 Java 8 与 Java 11,新增 G1 垃圾回收器与飞行记录器、容器化环境性能等内容。新项目建议选第 2 版。
它和《Java性能优化权威指南》是同一本书吗?
不是。那本由 Charlie Hunt 与 Binu John 合著,同样是人民邮电出版社「图灵程序设计丛书」中的书,中文版出版于 2014 年,ISBN 为 9787115342973。本书作者是 Scott Oaks,原书名为 Java Performance: The Definitive Guide,两本内容与结构都不同。
这本书适合完全没接触过 JVM 的人读吗?
不太适合作为入门第一本。书中默认读者具备基本的 Java 开发经验,并大致了解类加载、垃圾回收等概念。若完全零基础,建议先用一本 Java 基础教程或 JVM 入门书打底,再回来读本书的测试方法与工具章节。
书里的内容用在 Java 17 或 Java 21 上还成立吗?
性能分析方法、工具链(如 jcmd、JFR)和内存管理思路仍然适用,但具体垃圾收集器格局已有变化,例如 CMS 在新版本中已被移除,G1 成为默认回收器。涉及版本相关参数时,建议结合目标 JDK 的官方文档核对后再使用。

Comments

Find this book

This site is an index: you start “Search all sources” in your browser, and the entries it lists all point to third-party sites; please judge their availability yourself.

More by the same author

Top rated in the same category