Java 25: Java Flight Recorder (JFR) Part 1

𝗝𝗮𝘃𝗮 𝟮𝟱: 𝗝𝗮𝘃𝗮 𝗙𝗹𝗶𝗴𝗵𝘁 𝗥𝗲𝗰𝗼𝗿𝗱𝗲𝗿 (𝗝𝗙𝗥) – 𝗣𝗮𝗿𝘁 𝟭 Java Flight Recorder (JFR) received a set of important improvements in Java 25, highly relevant for anyone working with observability, profiling and production performance. 🧭 𝗪𝗵𝗮𝘁 𝗶𝘀 𝗝𝗙𝗥 (𝗾𝘂𝗶𝗰𝗸 𝗿𝗲𝗰𝗮𝗽) Java Flight Recorder is a 𝗯𝘂𝗶𝗹𝘁-𝗶𝗻 𝗝𝗩𝗠 𝗽𝗿𝗼𝗳𝗶𝗹𝗲𝗿 — with 𝘂𝗹𝘁𝗿𝗮-𝗹𝗼𝘄 𝗼𝘃𝗲𝗿𝗵𝗲𝗮𝗱 (<𝟭%) — that collects events on: • CPU and memory usage • Thread locks and latencies • Object allocation • Garbage collection • I/O, networking, and JVM internals It is ideal for 𝗽𝗿𝗼𝗱𝘂𝗰𝘁𝗶𝗼𝗻 𝗲𝗻𝘃𝗶𝗿𝗼𝗻𝗺𝗲𝗻𝘁𝘀, unlike heavy tools such as VisualVM or YourKit. 📌 𝗝𝗘𝗣 𝟱𝟬𝟵 — 𝗖𝗼𝗼𝗽𝗲𝗿𝗮𝘁𝗶𝘃𝗲 𝗖𝗣𝗨 𝗦𝗮𝗺𝗽𝗹𝗶𝗻𝗴 “𝘊𝘰𝘰𝘱𝘦𝘳𝘢𝘵𝘪𝘷𝘦 𝘊𝘗𝘜 𝘚𝘢𝘮𝘱𝘭𝘪𝘯𝘨” 𝗣𝗿𝗲𝘃𝗶𝗼𝘂𝘀𝗹𝘆, JFR used preemptive sampling, meaning it interrupted threads arbitrarily to record stack traces. 𝗡𝗼𝘄, with 𝗰𝗼𝗼𝗽𝗲𝗿𝗮𝘁𝗶𝘃𝗲 𝘀𝗮𝗺𝗽𝗹𝗶𝗻𝗴, 𝘁𝗵𝗿𝗲𝗮𝗱𝘀 𝘃𝗼𝗹𝘂𝗻𝘁𝗮𝗿𝗶𝗹𝘆 𝗿𝗲𝗽𝗼𝗿𝘁 CPU usage at safe points. This reduces overhead and enables analysis of high-concurrency workloads, such as virtual threads. 📌 𝗝𝗘𝗣 𝟱𝟭𝟴 — 𝗖𝗣𝗨 𝗧𝗶𝗺𝗲 𝗣𝗿𝗼𝗳𝗶𝗹𝗶𝗻𝗴 𝗼𝗻 𝗟𝗶𝗻𝘂𝘅 “𝘙𝘦𝘤𝘰𝘳𝘥 𝘱𝘦𝘳-𝘵𝘩𝘳𝘦𝘢𝘥 𝘊𝘗𝘜 𝘵𝘪𝘮𝘦 𝘮𝘦𝘵𝘳𝘪𝘤𝘴” JFR now measures actual CPU time per thread (user + system) on Linux. 𝗣𝗿𝗲𝘃𝗶𝗼𝘂𝘀𝗹𝘆, JFR measuared only wall-clock metrics, i.e., total elapsed time, 𝗶𝗻𝗰𝗹𝘂𝗱𝗶𝗻𝗴 I/O waits, lock contention and threads sleeping in queues. 𝗡𝗼𝘄, JFR tracks CPU time spent per method, thread, and event (e.g., garbage collection, JIT compilation). 📌 𝗝𝗘𝗣 𝟱𝟮𝟬 — 𝗡𝗲𝘄 𝗰𝗼𝗼𝗽𝗲𝗿𝗮𝘁𝗶𝘃𝗲 𝘀𝗮𝗺𝗽𝗹𝗶𝗻𝗴 𝗺𝗼𝗱𝗲𝗹 + 𝗝𝗜𝗧 𝗶𝗻𝘁𝗲𝗴𝗿𝗮𝘁𝗶𝗼𝗻 “𝘑𝘍𝘙 𝘊𝘰𝘰𝘱𝘦𝘳𝘢𝘵𝘪𝘷𝘦 𝘚𝘢𝘮𝘱𝘭𝘪𝘯𝘨 𝘪𝘯𝘵𝘦𝘨𝘳𝘢𝘵𝘦𝘥 𝘸𝘪𝘵𝘩 𝘑𝘐𝘛 𝘤𝘰𝘮𝘱𝘪𝘭𝘢𝘵𝘪𝘰𝘯 𝘦𝘷𝘦𝘯𝘵𝘴” 𝗡𝗼𝘄, JFR 𝗰𝗼𝗿𝗿𝗲𝗹𝗮𝘁𝗲𝘀 CPU events with JIT compiler state. It knows if a method was 𝗶𝗻𝘁𝗲𝗿𝗽𝗿𝗲𝘁𝗲𝗱, 𝗝𝗜𝗧-𝗰𝗼𝗺𝗽𝗶𝗹𝗲𝗱, or 𝗿𝗲𝗰𝗼𝗺𝗽𝗶𝗹𝗲𝗱, enabling deeper understanding of JVM warm-up. And it helps determine if 𝘀𝗹𝗼𝘄𝗱𝗼𝘄𝗻𝘀 come from the initial interpreted phase or are bottlenecks in already optimized code. 📌 𝗕𝗲𝘁𝘁𝗲𝗿 𝗶𝗻𝘁𝗲𝗴𝗿𝗮𝘁𝗶𝗼𝗻 𝘄𝗶𝘁𝗵 𝘁𝗵𝗲 𝗼𝗯𝘀𝗲𝗿𝘃𝗮𝗯𝗶𝗹𝗶𝘁𝘆 𝗲𝗰𝗼𝘀𝘆𝘀𝘁𝗲𝗺 JFR 𝗲𝘅𝗽𝗼𝗿𝘁𝘀 metrics compatible with Micrometer and OpenTelemetry. Enables 𝗿𝗲𝗮𝗹-𝘁𝗶𝗺𝗲 𝘀𝘁𝗿𝗲𝗮𝗺𝗶𝗻𝗴 of events to systems like 𝗣𝗿𝗼𝗺𝗲𝘁𝗵𝗲𝘂𝘀, 𝗚𝗿𝗮𝗳𝗮𝗻𝗮, and 𝗘𝗹𝗮𝘀𝘁𝗶𝗰𝘀𝗲𝗮𝗿𝗰𝗵. New JSON-configurable filters allow selecting which events to export (by class, package, or event type). 😎 𝗣𝗮𝗿𝘁 𝟮 𝗼𝗳 𝘁𝗵𝗶𝘀 𝗽𝗼𝘀𝘁 𝗰𝗼𝗺𝗶𝗻𝗴 𝘀𝗼𝗼𝗻! #Java #Java25 #JFR #𝗝𝗮𝘃𝗮𝗙𝗹𝗶𝗴𝗵𝘁𝗥𝗲𝗰𝗼𝗿𝗱𝗲𝗿 #Profiling #Performance #Observability

To view or add a comment, sign in

Explore content categories