Phase 2: Java Internals & Performance¶
Master the JVM internals, performance engineering, garbage collection, and the full stack of Java optimization — from bytecode to CPU cache lines.
Duration: 2-3 Months
Learning Resources¶
| Resource Type | Name |
|---|---|
| Book | Optimizing Java — Benjamin J. Evans, James Gough, Chris Newland (O'Reilly) |
| Book | Java Performance: The Definitive Guide — Scott Oaks (O'Reilly) |
| Tool | JDK Mission Control (JMC) + Java Flight Recorder (JFR) |
| Tool | async-profiler / Honest Profiler (flame graphs) |
Topics¶
-
Topic 1: Optimizing Java — Part I: Foundations
Performance vocabulary (throughput, latency, observables), JVM anatomy (classloading, JIT tiers), hardware (CPU caches, NUMA, OS scheduler), performance testing types & antipatterns, microbenchmarking with JMH, non-normal statistics & HdrHistogram.
Book: Optimizing Java, Chapters 1–5
-
Topic 2: Garbage Collection Deep Dive
GC algorithms (Serial, Parallel, CMS, G1, ZGC, Shenandoah), heap structure, tri-color marking, SATB, Brooks pointers, colored pointers, Card Tables, safepoints, GC log analysis, allocation profiling, GC tuning parameters.
Book: Optimizing Java, Chapters 6–8
-
Topic 3: Bytecode & JIT Internals
JVM as a stack machine, bytecode opcode families, method invocation opcodes, template interpreter, tiered compilation (Tiers 0–4), Code Cache, inlining (the gateway optimization), loop unrolling, escape analysis & scalar replacement, monomorphic dispatch, intrinsics, 8000-byte compilation wall.
Book: Optimizing Java, Chapters 9–10
-
Topic 4: Language Performance & Concurrency
Collection internals (ArrayList vs LinkedList, HashMap bucket/treeify mechanics, TreeMap), domain object memory leak diagnosis, finalization lifecycle & deprecation,
try-with-resources, Method Handles, Amdahl's Law, JMM (happens-before,volatile≠ atomic), CAS & lock-free atomics,ReentrantLock/ReadWriteLock/Semaphore,ConcurrentHashMap, ForkJoinPool work-stealing, LMAX Disruptor, Actor model.Book: Optimizing Java, Chapters 11–12
-
Topic 5: Advanced JVM Optimization Techniques
Profiling prerequisites & safepoint bias,
AsyncGetCallTrace(), async-profiler, JFR/JMC, flame graphs (CPU/allocation), TLAB sampling, heap dump analysis, logging benchmarks (JUL vs Log4j 2.6 zero-GC), Agrona buffers & cache-line-padded queues, SBE copy-free codec, Aeron 8 latency principles & lock-free log appender, Compact Strings, Segmented Code Cache, VarHandles, Project Valhalla value types, Graal/Truffle/Futamura, Project Loom virtual threads.Book: Optimizing Java, Chapters 13–15
Topic Structure¶
Each topic folder contains reading notes keyed to chapters of the source book:
| Document Type | Purpose |
|---|---|
book-reading-chN.md |
Deep notes for Chapter N of Optimizing Java — concepts, code examples, diagrams, internals |
index.md |
Topic overview, chapter map, progress tracker, key internals to understand |
Optimizing Java — Book Reading Plan¶
| Reading Group | Chapters | Topics | Status |
|---|---|---|---|
| Week 1 | 1–5 | Foundations: observables, JVM, hardware, testing, statistics | Complete |
| Week 2 | 6–8 | Garbage Collection: algorithms, heap, GC logs, tuning | Complete |
| Week 3 | 9–10 | Bytecode & JIT: internals, inlining, escape analysis | Complete |
| Week 4 | 11–12 | Language Performance & Concurrency | Complete |
| Week 5 | 13–15 | Advanced JVM: Profiling, Logging & Future | Complete |
Project Ideas¶
- JVM Performance Profiling Lab — Profile a real application with JFR + async-profiler, generate flame graphs, identify GC and CPU bottlenecks
- GC Tuning Experiment — Run the same workload under G1, ZGC, and Shenandoah; compare GC pause distributions using HdrHistogram
- Cache-Friendly Data Structures — Implement and benchmark array-of-structs vs struct-of-arrays; measure false sharing impact
- JMH Benchmark Suite — Benchmark algorithm alternatives for a real business problem (string parsing, JSON deserialization, sorting)
- NUMA-Aware Application — Profile a multi-threaded application on a NUMA machine with and without
-XX:+UseNUMA
Phase Progress¶
- Topic 1: Optimizing Java — Part I: Foundations (Chapters 1–5)
- Topic 2: Garbage Collection Deep Dive (Chapters 6–8)
- Topic 3: Bytecode & JIT Internals (Chapters 9–10)
- Topic 4: Language Performance & Concurrency (Chapters 11–12)
- Topic 5: Advanced JVM Optimization Techniques (Chapters 13–15)
- Phase 2 Capstone Project
Phase Start Date: 2026-07-16 | Target Completion: