Kieran France FollowKieran France is a programmer for IDRSolutions. He enjoys tinkering with most things including gadgets, code and electronics. He spends his time working on the the JPedal library and our internal test suite..

How Java 10 will improve performance

April 17, 2018 1 min read

For Java 10 there has been work taking place under the hood to help improve performance. There are several changes that are taking place to improve performance under the hood of the JVM. One of these changes is JEP-312. When running an application the JVM needs to occasionally stop executing Java code in order to complete house keeping tasks such as garbage collection (we wrote an article explain the changes to Garbage Collection in Java 10 last week) and JIT compilation (we will be looking at this next time). In order to handle these the JVM enters a safe point.

What is a Safe Point?

In order for the JVM to perform various tasks of a thread it needs to stop the thread at a safe point. An example of when this might happen would be when we need to get a stack trace. In order to do this currently we need to enter a global safe point (a stop-the-world event). During this time all threads executing java code are stopped. Previously when controlling these threads it has been all or nothing. All threads are stopped.

What does JEP-312 do?

JEP-312 introduces Thread-Local handshakes. Instead of waiting for a global safe point to stop all the threads we use a callback to affect individual threads. The callback will trigger when a thread is in a safe point and allow it to be stopped as soon as possible. It can then be started again as soon as the JVM has finished any tasks it was performing to the thread. In short, threads are no longer all or nothing when it comes to stopping them. We can instead stop threads individually allowing others to continue, cutting down on the number of stops to all threads.

How do I use these features?

This new system is on by default in Java10. These changes have all taken place under the hood of the JVM, there is nothing you will need to do to take advantage of it. However you may find this feature may not be desirable. In that is the case there is a flag to let you control it. The following flag can be uses with true or false to turn the feature on or off.

-XX:ThreadLocalHandshakes=false

It should be noted that these features will initially be implemented solely for x64 and SPARC. Other platforms will fall back on the original safe points.

At IDRsolutions we have been eagerly awaiting the release of Java 10 to see what improvements these features bring the library. What features in Java 10 can you not wait to start using?

If you’re a first-time reader, or simply want to be notified when we post new articles and updates, you can keep up to date by social media (Twitter, Facebook and Google+) or the Blog RSS.

Kieran France FollowKieran France is a programmer for IDRSolutions. He enjoys tinkering with most things including gadgets, code and electronics. He spends his time working on the the JPedal library and our internal test suite..