Java Performance Tuning

Java(TM) - see bottom of page

|home |services |training |newsletter |tuning tips |tool reports |articles |resources |about us |site map |contact us |
Tools: | GC log analysers| Multi-tenancy tools| Books| SizeOf| Thread analysers| Heap dump analysers|

Our valued sponsors who help make this site possible
JProfiler: Get rid of your performance problems and memory leaks! 

Training online: Concurrency, Threading, GC, Advanced Java and more ... 

News October 2016

JProfiler
Get rid of your performance problems and memory leaks!

Modern Garbage Collection Tuning
Shows tuning flow chart for GC tuning


Java Performance Training Courses
COURSES AVAILABLE NOW. We can provide training courses to handle all your Java performance needs

Java Performance Tuning, 2nd ed
The classic and most comprehensive book on tuning Java

Java Performance Tuning Newsletter
Your source of Java performance news. Subscribe now!
Enter email:


Training online
Threading Essentials course


JProfiler
Get rid of your performance problems and memory leaks!


Back to newsletter 191 contents

Last month I listed almost all the JEPs that have performance impact in Java 9. One JEP that I didn't list was 285: Spin-Wait Hints. I don't think it's one that many people need to know about, but for those of you who want to know about the cutting edge of ultra-low latency, it's interesting. First I'll need to explain where it's useful.

A note from this newsletter's sponsor

Site24x7.com : Deep dive Application Performance Monitoring
Fix performance issues with Java, .NET and Ruby platforms
Monitor app instance at $12/Month. 30-day free trial. Sign Up!

The best way to consider spin-waits is to think of an ideal scenario where you'd want to use them. So here's the scenario:

(Note: attaching a thread to a specific core is not difficult (eg using OS commands or with libraries like OpenHFT's Java-Affinity), but ensuring that nothing else runs on that core is challenging (eg see Mark Price's talk on trying to achieve that; or if you're in a hurry my extracted tips from that talk gives summary details).

The scenario is waiting for some state to change; and we want to respond to that change as fast as we possibly can, so we just repeatedly check the condition doing nothing else - looping on the condition check (the "spin" part of the spin-wait). Note this is an anti-pattern - if you had too much in the way of spin-wait, your CPU could be fully utilised without doing very much at all. But to achieve that "as soon as possible" hard requirement, it can be worth it.

Okay, that's spin-wait but about the JEP? So if the JVM knew it was doing a spin-wait loop, on some hardware it is possible to optimize the inter-thread comms a little. But it's difficult for the JVM to know that the application is spin-waiting rather than just looping doing something. The JEP provides a way for the application to tell the JVM it's spin-waiting by calling the Thread.onSpinWait() method in the body of the loop. On x86, this gives a 20 nanosecond improvement to the latency in responding to the state change in the spin-wait.

When 20 nanoseconds per request matter to you, you need to know about Thread.onSpinWait().

Now on to our usual links to tools, articles, news, talks, blogs. And if you need the tips from this month's articles and talks, as ever they are extracted into this month's tips page.

News

Java performance tuning related news.

Tools

Java performance tuning related tools.

A note from this newsletter's sponsor

New Relic - Try New Relic today and get your free Data Nerd shirt!
Free SaaS APMto monitor, troubleshoot, and tune apps
running on Websphere, Weblogic, Tomcat, Jetty, JBoss, Solr, Resin

Articles

Jack Shirazi


Back to newsletter 191 contents


Last Updated: 2025-01-27
Copyright © 2000-2025 Fasterj.com. All Rights Reserved.
All trademarks and registered trademarks appearing on JavaPerformanceTuning.com are the property of their respective owners.
Java is a trademark or registered trademark of Oracle Corporation in the United States and other countries. JavaPerformanceTuning.com is not connected to Oracle Corporation and is not sponsored by Oracle Corporation.
URL: http://www.JavaPerformanceTuning.com/news/news191.shtml
RSS Feed: http://www.JavaPerformanceTuning.com/newsletters.rss
Trouble with this page? Please contact us