Writing a Java Profiler in Pure Java
summary
A usable Java profiler runs in 240 lines of pure Java and samples stacks by calling Thread.getAllStackTraces on a background agent thread attached via the Java agent API; samples get aggregated into a compact tree to emit flame graphs and custom JFR events. Built prototypes include an IntelliJ plugin that links flame views back to source, and measured overhead stays around <2% in typical JFR setups.
AI-written summary · about
chapters (12)
- 0:00Introduction and personal story
- 6:29What is profiling and why it matters
- 12:09Building a simple Java profiler
- 17:55Flame graphs from samples
- 21:49Types of existing profilers
- 27:10JDK Flight Recorder overview
- 30:03Custom events with JFR
- 32:12JDK Mission Control demo
- 33:38IntelliJ profiler plugin
- 35:48Performance impact of profiling
- 36:51Continuous profiling options
- 37:55Conclusion and resources
