Write your own Java Profiler in 240 lines of pure Java
summary
Claims a usable Java profiler fits in 240 lines of pure Java and the published version is 251 lines after fixes. It runs as a Java agent, samples every ~10–20 ms via Thread.getAllStackTraces(), aggregates samples into a simple tree and emits flame graphs, and ships under the MIT license. The implementation actually runs in production for some users, integrates with JFR/JDK Mission Control and an IntelliJ plugin, and trades precision for low overhead and simplicity.
AI-written summary · about
chapters (11)
- 0:00Introduction and story
- 6:25Why profiling matters
- 11:29Types of profilers
- 13:57Building a tiny profiler
- 23:17Sampling profiler details
- 27:11Obtaining real profiles
- 31:29Custom events with JFR
- 33:37Visualizing profiles
- 36:07Performance impact
- 37:32Continuous profiling
- 38:58Closing and resources
related talks
33mWriting a Java Profiler in Pure Java
41mUnleash the Power of Open-Source Java Profilers
46mCPU Profiling on the JVM and Flame Graphs
42mOff-CPU Profiling & Latency Diagnostics in Java
52mProfilers Are Lying Hobbitses
45mJDK 25's new CPU-Time Profiler
39mFive most useful profiling techniques to use with modern Java apps
50mObservability Beyond the Three Pillars — Continuous Profiling With Alibaba Dragonwell
