|
|
|
Back to newsletter 280 contents
This month I have a guest, Ingo Kegel architect for JProfiler, telling us about how thread-local handshakes can give you near-zero overhead for full sampling without async! JProfiler uses this technique with Java 17+ so it's a practical useful technique. Although explained here in the context of JProfiler, it's a generally applicable technique. On to Ingo...
Global safepoints were traditionally required for sampling, but async sampling provided a more effective solution with reduced overhead and without safepoint bias. However, async sampling has many drawbacks, such as partial traces and reduced functionality because of the restrictive environment of an async handler. Thread-local handshakes allow performing actions on individual threads without stopping all threads at a global safepoint. This allows sampling which does not suffer from safepoint bias and has very low overhead.
Thread-local handshakes were first added in Java 10 with JEP 312. But it wasn't until Java 16, with JEP 376 (for improved ZGC efficiency in concurrent thread-stacks processing, together with other fixes) that a "mechanism by which other HotSpot subsystems can lazily process stacks" was added to the JVMTI. With this capability available, full sampling can now be comparable in overhead with async sampling. From Java 17 JProfiler supports both thread-local handshake sampling and async sampling. There is some remaining local safepoint bias, but it's irrelevant for the vast majority of applications given the frequency of local safepoints.
Now on to all the usual newsletter list of links, tips, tools, news and articles, and as usual I've extracted all the tips into this month's tips page
Java performance tuning related news
Java performance tuning related tools
Back to newsletter 280 contents