Brice Dutheil

Avatar photo

Brice Dutheil

Brice Dutheil is a software engineer, aficionado of open source software. Previously a Mockito core contributor, now a Dad of 2.

Do you want your ad here?

Contact us to get your ad seen by thousands of users every day!

[email protected]
Likes 0
Comments 1
Shares 0
Articles 7
Views 59,5K
Latest post

Project Panama for Newbies (Part 3)

We are going to dig a little deeper in our exploration of Project Panama and how to talk to third party libraries such as SDL & OpenGL. With the skills you've learned from Part 1 and Part 2, you should be able to call most of the common function signatures in many libraries out in the wild.

Introduction to JVM Unified Logging (JEP-158 / JEP-271)

Unified logging was introduced in JDK 9, and is available for us all, in the JDK 11 LTS. Like other great serviceability feature (jcmd or JFR) this was inspired by JRockit.

In my opinion the flexibility of this logging system brought a major downside from a user’s perspective in its configuration correctness, and I think in some ways it’s more obscure compared to the previous explicit logging flags.

How & When to Use JDK Flight Recorder in Production

While it would certainly be useful to record the whole lifetime, this is unpractical, even airplane Flight Data Recorders (and Cockpit Voice Recorders) only keep recent history.

Instead, it’s possible to aim at specific time frames where a recording could be useful.

Control JFR Programmatically

While from JDK 14 events can be consumed on the fly, previous JDK versions (from JDK 11) offer a public API useful enough to control Flight Recorder programmatically or to read events from a JFR file.

Such API facilities are useful especially when combined with other technologies like Spring Actuators. Yet when there’s available integration or when using these integrations is too late, like recording startup, the most actionable way to get recording is from the command line.

Analyze JFR Recordings

Continuing from part 1, to exploit the recording by analyzing it, we have a tool named jfr that ships with the JDK. On Linux the alternative jdk management may not be aware of jfr, which means you may need to use the full path to this executable.

The first interesting thing to do is to get an overview of the recording, the summary sub-command displays an histogram of the events.

Get Started with JDK Flight Recorder

Java Flight Recorder is the profiler you can use in production, continuously.

Flight Recorder has been available before in the JDK, e.g., it shipped as part of the JDK 8, but to use it, it required that you set specific commercial VM flags to unlock Flight Recorder, this is not anymore necessary from Java 11 onwards.

Join the Community

Be a Part of Our Network

Mastodon

Subscribe to foojay updates:

https://foojay.io/today/author/brice-dutheil/feed/
Copied to the clipboard