Paul Krill
Editor at Large

OpenJDK considers async stack traces for Java

news
Nov 4, 20222 mins

Proposal would define an API to collect stack traces asynchronously and include information on both Java and native stack frames.

coffee cup - coffee beans - Java
Credit: Christoph

A proposal promoting asynchronous stack traces in Java is advancing through the OpenJDK’s Java enhancement process.

The plan, Asynchronous Stack Trace VM API, would define an AsyncGetStackTrace API to collect stack traces asynchronously and include data on both Java and native stack frames. Goals of the effort include provision of a well-tested API for profilers, which would obtain the Java native stack frames information, and support for asynchronous usage, such as calling from signal handlers.

As per the proposal, performance would not be affected when the API is not in use and memory requirements would not be significantly increased compared to the existing AsyncGetCallTrace API. The new API would not be recommended for production use, because it could crash the JVM. Plans call for minimizing the chances of that through extensive testing and fuzzing.

Currently, AsyncGetCallTrace is used by most available profilers, both open source and commercial, including async-profiler. But it has two major disadvantages. It is an internal API, not exported in any header, and it only returns information about Java frames, namely their method and bytecode indices. These issues make implementing profilers and related tools more difficult. Although additional information can be extracted from the HotSpot VM through complex code, other useful information remains hidden, such as whether a compiled Java frame is inlined, the compilation level of a Java frame, and information on C/C++ frames not at the top of the stack. This data can be helpful for profiling and tuning a VM for a given application and for profiling code that heavily uses JNI (Java Native Interface).

The AsyncGetStackTrace API would be modeled on the AsyncGetCallTrace API. The new API has not yet been proposed for a specific version of standard Java. The next version of Java is Java Development Kit (JDK) 20, which is expected in March 2023.

Paul Krill

Paul Krill is editor at large at InfoWorld. Paul has been covering computer technology as a news and feature reporter for more than 35 years, including 30 years at InfoWorld. He has specialized in coverage of software development tools and technologies since the 1990s, and he continues to lead InfoWorld’s news coverage of software development platforms including Java and .NET and programming languages including JavaScript, TypeScript, PHP, Python, Ruby, Rust, and Go. Long trusted as a reporter who prioritizes accuracy, integrity, and the best interests of readers, Paul is sought out by technology companies and industry organizations who want to reach InfoWorld’s audience of software developers and other information technology professionals. Paul has won a “Best Technology News Coverage” award from IDG.

More from this author