The JavaOne conference has just started: one huge celebration of 20 years of Java! For me, a day mostly filled with an interesting university session on Performance Tuning with the JVM. As Chief Architect by Oracle Brain Goetz (see fragment here) mentioned today during his keynote: performance is an increasing responsibility. So, what to do to prevent bad memory allocation, bottlenecks and wrong usage of resources? Master the JVM! (By @KoenusTweets)
The JVM has about 50 options for performance configuration, see this page. For standard situations the JVM is installed itself with an optimized configuration for your hardware and operating system. Really important for performance is to understand garbage collection. While it makes Java very popular not having to program memory usage (like in C), the garbage collector pauses the JVM (called “stop the world”, inside Oracle) for allocating memory. The session explained various approaches for the GC: really a smart architecture! So next time your IDE waits endlessly, you know it is the GC that is working hard. Then, if working with JDK7 or higher, it might be good to choose the most modern GC strategy G1 (Garbage First).
JVM performance tooling
The JDK comes with handy tools for performance investigation, findable in the “bin” directory. Discovering insights on Java processes, you can use VisualVM en JConsole. Especially VisualVM offers good means to profile, because of the many installable plugins available. During the session we installed the VisualGC plugin that focusses on the GC in depth. Commercial tooling from Oracle (free in non-production environments) are the Java Mission Controller (jmc). I really like to use its Java FIight Recorder, to profile extensively the JVM. The investments from Oracle in Java are very much focussed in JVM tooling, such as the Walhala research just to increase Java performance. Also Eclipse offers many Open Source plugins in this area such as jvmmonitor, JSnapshot and the Java Profiler.
JVM performance coding fun
The best performance tools for the JVM, might be the ones you make yourself;-). The HotSpot architecture provides the JVM many API’s that can be used by debuggers, profilers, and monitoring & management tools. This way you can really look at the inner state of your application, server or JVM. The course had many fun examples to hack with the JVM, eg with simple core classes like MonitoredVM and HotSpotVirtualMachine, We also programmed JMX (Java Managed eXtensions) the standard for inspecting the runtime through extensions via Groovy, the language I really like. More details on performance tuning can be found here. Let’s make Java perform excellent!
Closure: Conference Fun!
The conference evening was great fun: spicy food, having some swag and seeing the Oracle CEO talk on his Oracle World. In the evening, I also visited 3 short community focussed sessions. The first session was for the OpenJDK community: a large amount of new developers was introduced on how to get started in the Open Source development. In the next session 6 professors had an interesting forum discussion on effective teaching Java on schools. An illustrating quote was: the society has to find ways how to provide more developers and faster. I closed my day with a session of Java veteran Bruce Snyder together with the JCP committee: also these folks are looking for developers. It is good to be an engineer 😉
The Java Flight Recorder