Akash's Blog

_

Monday, February 10, 2025

Devoxx Belgium 2024 : Java Performance Update



Introduction

A high level summary and commentry on the aforementioned Java 24 performance update video. Java is not just updating it's performance and usability in general but moving way faster year on year. The Java 25 is likely to be released somewhere in 2025. 

This video is of last year Devoxx but recently posted on Java Youtube channel and as a curios Java follower I found it very interesting, thus I decided to write about it on my blog. This video initially gives summary of Java projects, performance metrics, challenges faced in performance and then shared the recent and future performance improvements. If you don't want to get into initial summary and focus on recent performance improvements you can start from here.

Ongoing Java Projects

Speaker summarized the ongoing Java projects which are listed below,

  • Amber : Small Java Features.
  • Babylon: Extend reach of Java to SQL, ML Models and GPUs.
  • Leyden: Improve start up time and reduce memory foot print.
  • Lilliput: Reduce size of Java Object Header on 64 bit architecture.
  • Loom: Lightweight concurrency.
  • Panama: Integration between Java and system level programming languages.
  • Valhalla: Augmenting java object model with value objects.

Metrics / Challenges / Tools

In this section speaker briefed about the different metrics one need to consider while checking for performance. Performance needs to be looked from wholestic view which must include usage of memory, CPU, threads, cache and power. Also, start up and warm up time needs to be considered while measuring the performance.

While talking about challenges speaker emphasized that we can not get accurate performance statistics on our laptops it's better to do it on dedicated server post warm up when application is ready to serve. That too one should not consider the result after very few runs, performance results needs to be collected after thousands of executions. Also, suggested to use System::nanoTime instead of System::currentTimeMillis for better accuracy while checking the performance.

Speaker mentioned about JMH (Java Microbenchmark Harness) which can be used to get micro level benchmarking using @Benchmark annotation. He further talks about the internal tools which Java team uses to check the benchmarks in different platforms which gives them an idea of how much the performance improve or degraded in respective platform.

Performance Improvements

JDK-8318446: C2 - "MergeStores"
This is an internal fix to the Java Hotspot Compiler (C2), improvement in terms of array store operations. 

Array store operation refers to process of writing values to the array index. Earlier the compiler was merging primitive stores such a way which was causing assertion failures and even incorrect optimizations. 

Using Unsafe and BALE (Internal to JDK, jdk.internal.util.ByteArrayLittleEndian) were alternatives but both are not good considering Unsafe is something we should move away from and BALE may slow down things.

JDK-8340821: FFM API Bulk Operations
This includes performance enhancement in Foreign Function & Memory (FFM) API. The basic idea was to handle specific memory segments code directly in Java instead of using native code. By reducing the overhead of converting native code to Java.

JDK-8180450: Secondary Super Cache Scaling
This was a bug in secondary super cache. Specifically in instanceof operation when multiple threads frequently checks the type in succession the cache was becoming unstanble and overall performance was hammered in rare workloads. 

JDK-8336856: String Concatenation
Before this enhancement Java would do extra calculations especially with different data types like int, long, double etc. which was slowing down the overall concatenation. After this change Java has reduced unneccessary work to improve the overall performance.

JEP-474: ZGC
This change in ZGC (Z Garbage Collector) aims to enhance performance by focusing on generational garbage collection, which manages short-lived and long-lived objects more efficiently. Moving in a direction to make generational GC mode as default.

JEP-450: Compact Header
Reduce object header size to save ~20% memory. Considering, approx header sizes are around 12-16 bytes and object sizes are 32-64 bytes.

Summay

This video was having many things which were new to me. It helped me in getting more understanding of internal workings and progress happening around the performance aspect. I tried to simplify these updates as much as possible. I may dig down into each going forward for more in depth learning and better understanding.

Apparently, there are other improvements also mentioned which will be the focus for upcoming months on top of these. These updates may look abstract and at first, may sound not making huge impact but by taking a close look it's moving in a direction of high optimization and efficiency.




↑ Back to Top