#19 Using JDK FlightRecorder and Mission Control
Sealed Classes and ADTs. ZGC - Using -XX:SoftMaxHeapSize. Micronaut Framework movements. Does TDD Really Lead to Good Design?
Welcome to the nineteenth Dukesletter edition!
It’s hardware that makes a machine fast. It’s software that makes a fast machine slow.
— Craig Bruce
Using JDK FlightRecorder and JDK Mission Control
Java FlightRecorder and Mission Control are two of my favorite features from Java. I solve 90% of my performance problems with this tools.
Until JDK 11 was a commercial tool, but since JDK 11, are open source. Thanks to the collaboration of Red Hat, Alibaba, Azul and Datadog, this code has been backported to JDK 8.
Brice Dutheil has published an article explaining how to use FlightRecorder in combination with Mission Control, and find bottlenecks and problems using a real and detailed example: “Using JDK FlightRecorder and JDK Mission Control”.
At the same time Baeldung has published an article talking about it: “Monitoring Java Applications with Flight Recorder”.
If you need to create your own events in JFR Oracle has published a very complete guide: “Flight Recorder API Programmer’s Guide”.
Sealed Classes and ADTs
The next release of JDK 15 will include Sealed Classes as a preview feature. The author of the JEP 360 is Brian Goetz, and to introduce the feature he has written an article: “Java Feature Spotlight: Sealed Classes”.
Records, Sealed Classes and future switch/pattern matching will open the door of Algebraic Data Types to the Java Language, a paradigm that has gained a lot of traction in the functional programming world.
These ADTs and more concepts of other paradigms are introduced in this talk by James Ward and Joshua Suereth: “The Evolution of Object Oriented Programming”.
ZGC - Using -XX:SoftMaxHeapSize
One of the most difficult tasks managing a server in production is the resources allocation configuration. How much memory do we configure? for average case? for worst case?
Usually our application is not deployed alone in a server (as individual processes or as a containerized process), and all applications don’t need all assigned memory concurrently. But punctually some of the applications can get a spike of consumption and need more memory than assigned. The server has free resources, but the application can not use it.
Since JDK 12, with the JEP 346, G1 can return unused committed memory, and this can help us to deploy more resources in the same server, being conservative in average case scenario.
In JDK 13, ZGC implemented another feature that helps to optimize memory configuration: SoftMaxHeapSize. This new option sets a soft limit on how large the Java heap can grow, maintaining low memory consumption in low-load processes, giving margin to other processes to grow.
This feature is only available in ZGC, but G1 support is ongoing. To learn more about this feature and its implications I recommend to read “ZGC | Using -XX:SoftMaxHeapSize” from Per Liden, the project lead of ZGC.
Micronaut Framework movements
In the last few days we've had a lot of news about Micronaut Framework, all around the main news: Micronaut 2.0 has been launched. In the article you have an introduction of new features.
Three days latter OCI, the company that created and supported Micronaut until these release, has announced that has created the Micronaut Foundation. OCI has committed an initial contribution of $2M, and the board of the Foundation is formed by people from OCI, Oracle, Mesosphere, ThoughtWorks, JetBrains or individuals like Venkat Subramaniam.
But probably the most important news came out three days later: Graeme Rocher, the creator of Micronaut, joins Oracle:
A lot of news in one week!
How can we read these movements? Will Helidon project/team be integrated into Micronaut? Quarkus is getting a big boost from Red Hat, is this a movement from Oracle against it?
In any case, the competition is fair, and all the users of their technologies benefit.
Does TDD Really Lead to Good Design?
"TDD is a design tool." That’s what Sandro has said for years. But not anymore. After working with different teams and in different organisations, and also carefully inspecting how he works, Sandro changed his mind about the role of TDD in software design. In this talk Sandro will explain the pros and cons of the two main styles of TDD when it comes to software design, he'll discuss why some developers can test-drive well-crafted code while others can’t, and he'll also explain how to reason about design decisions.