days
0
-9
hours
0
-1
minutes
-2
-1
seconds
-5
-2
search
No heap is too big!

Shenandoah: Ultra low-pause garbage collector in Java 12

Sarah Schlothauer
java
© Shutterstock / Chayes Chomsuwan

Java 12 added plenty of new enhancements and we are still celebrating its release. One of the newest features is JEP 189. Shenandoah is a garbage collector developed by a team at Red Hat and focuses on low-pause time for large heaps. Is it the right GC for you?

Now that Java SE 12 is here, it’s time to hone in on the latest features and changes. One new enhancement, in particular, caught our eyes right away. JEP 189: Shenandoah is an experimental, low-pause-time garbage collector which targets large heap applications.

Its algorithm was originally published in 2016 by Red Hat. What are its goals and functions?

Low pause time

From the OpenJDK wiki:

“Shenandoah is an ultra-low pause time garbage collector that reduces GC pause times by performing more garbage collection work concurrently with the running Java program. CMS and G1 both perform concurrent marking of live objects. Shenandoah adds concurrent compaction.”

SEE ALSO: A beginner’s guide to Java programming nightmares

According to Red Hat, pause times are no longer in direct proportion with the size of the heap. In theory, this means that a heap that’s 2 GB will have the same pause time as a heap that’s 200 GB. We don’t have to tell you twice that this is serious business. Garbage collection pauses are the frustration of many users and this new enhancement could change how some developers use the JDK.

Non-goals & use cases

Mind you, fixing all pauses is a non-goal: “The goal is not to fix all JVM pause issues. Pause times due to reasons other than GC like Time To Safe Point (TTSP) issues or monitor inflation are outside the scope of this JEP.”

Your heap size also factors into performance. Testing on Shenandoah was done on larger heap sizes (from 4 to 128 GB). It’s recommended that you use it for these large sizes. If you have a smaller heap size, then this likely is not the GC for you.

If GC pauses are not on your list of problems, this GC also is not the one for you and you can carry on using one more suited to your particular use cases. There is no such thing as a GC that suits the needs of everyone, it’s up to you to figure out the use cases and trade-offs.

The good news is that even if Shenandoah is not for you, Java 12’s enhancements also includes improvements to the G1 garbage collector (JEP 344 and JEP 346). These include abortable mixed collections and an enhancement which allows the G1 GC to automatically return Java heap memory to the OS when idle.

SEE ALSO: Java 12: “Switch Expressions gives developers a chance to clean up some of the massive switch statements & convoluted if-then-else blocks”

Further resources

  • Check out its wiki for more information, and also how to report potential bugs.
  • One of the authors of Shenandoah, Roman Kennke, occasionally blogs about the topic. Explore the tag.

Want to use it yourself? Take note: the OracleJDK does not include Shenandoah. Currently, we have no word on whether or not this will change in the future.

For every other build, follow the instructions on the Wiki on how to install and run. The OpenJDK says that “this is not the one GC to rule them all”. But it certainly is some great progress for the status of the JDK and a welcome JEP. Java 12’s enhancements look fantastic!

Author
Sarah Schlothauer

Sarah Schlothauer

All Posts by Sarah Schlothauer

Sarah Schlothauer is an assistant editor for JAXenter.com. She received her Bachelor's degree from Monmouth University and is currently enrolled at Goethe University in Frankfurt, Germany where she is working on her Masters. She lives in Frankfurt with her husband and cat.

Leave a Reply

Be the First to Comment!

avatar
400
  Subscribe  
Notify of