Skip to content
Ameen Abozaid
MID-008

Performance profiling

  • 8 Lessons
  • 4 h practice (estimate)
On this page 8 topics

Overview

Topics

  • JFR
  • JDK Mission Control
  • heap dumps
  • thread dumps
  • CPU profiling

Learn first

4 h of practice (estimate)

Learning outcomes

  1. Record and analyze a JFR recording in JDK Mission Control.
  2. Find CPU hot spots with flame graphs.
  3. Capture and read thread dumps to diagnose blocked or starved threads.
  4. Capture and analyze a heap dump to find large retainers.
  5. Follow a measure → hypothesize → change → re-measure loop.

Lessons

  1. 01Measure before you optimize
  2. 02Java Flight Recorder
  3. 03JDK Mission Control tour
  4. 04CPU profiling and flame graphs
  5. 05Thread dumps
  6. 06Heap dumps
  7. 07Demo: finding a slow endpoint's hot spot with JFR
  8. 08Demo: thread starvation in a live service

Lab and exercises

Lab

MID-008-LAB1 · Profile Shop

Outcomes: 1–5 · Time: ~4 h The instructor plants a CPU hot spot and a lock contention in Shop. Using recordings, thread dumps, and (if needed) a heap dump, find both without reading the source first, fix them, and show before/after evidence under the same load. Acceptance: written investigation log.

Exercises (assessment: investigation of an unseen recording)

IDOutcomeTask
MID-008-EX011Record Shop for 2 minutes with JFR; list the five most useful pages or views and one finding from each.
MID-008-EX022From a provided flame graph, name the hottest method, its caller, and a hypothesis.
MID-008-EX033From three provided thread dumps, identify the contended lock, its owner, and the blocked threads.
MID-008-EX044From a provided heap dump, name the largest retainer and explain why it stays live.
MID-008-EX055Write a four-line investigation log entry for a fix: symptom, evidence, change, before/after.
MID-008-EX065List three ways a measurement can mislead (cold start, debug mode, single run) and how to avoid each.
Show solutions
  • EX01 For example: Automated Analysis, Method Profiling, Memory/GC, Lock Instances, Threads; each gives a lead (hot method, allocation rate, pause, contended monitor, parked pool).
  • EX02 The widest top-level frame; its parent frame is the caller; hypothesis, for example, repeated regex or formatting per call.
  • EX03 Find the monitor address shown as "waiting to lock"; the owner is the thread with "locked" on the same address; list the blocked threads.
  • EX04 Dominator tree top entry, with the path to GC roots (typically a static or singleton field).
  • EX05 A complete entry has a measured symptom (p95 numbers), the evidence artifact, a single change, and re-measured numbers under the same load.
  • EX06 Cold start: warm up first. Debug mode: profile production-like settings. Single run: repeat and compare distributions.

Quiz

Outcomes: O1 JFR and JMC · O2 flame graphs · O3 thread dumps · O4 heap dumps · O5 measurement loop.

A self-check for you: nothing is graded, saved or sent anywhere. Choose an answer, then check it. You can try again as often as you like.

  1. 1The correct loop is:O5
  2. 2JFR is notable for:O1
  3. 3Command to start JFR on a live process:O1
  4. 4First place to look in JMC:O1
  5. 5In a flame graph, frame width shows:O2
  6. 6A wide frame at the top of a stack means:O2
  7. 7Many threads BLOCKED on the same monitor indicates:O3
  8. 8Why take several thread dumps?O3
  9. 9Retained size of an object is:O4
  10. 10To explain why a leaked object stays alive, use:O4

Practical part

Six exercises MID-008-EX01 to EX06 including an unseen-recording investigation, plus the lab investigation log. Pass: at least five exercises correct and a log showing evidence, one change per iteration, and before/after numbers for both planted problems.

Common mistakes

Optimizing by intuition; profiling in debug mode; one-off measurements.

Assessment

Investigation of an unseen recording.

Career relevance

Performance engineering (SRC-016) and the MID graduation gate.

Type to search levels, phases, modules and lessons.