-
Type:
CSR
-
Resolution: Approved
-
Priority:
P3
-
Component/s: core-svc
-
None
-
minimal
-
New interface, no compatibility impact.
-
Java API
-
JDK
Summary
Introduce a new JDK-specific monitoring and management interface named jdk.management.HotSpotAOTCacheMXBean.java to manage the creation of the AOT cache.
Problem
There is currently no tooling support for AOT cache creation that can be accessed from the Java application. When the command-line options -XX:AOTCacheOutput and/or -XX:AOTMode=create are given, the cache is created only when the current JVM exits. This is not suitable for application that never exits, or for applications that want to create the AOT cache before the JVM exits.
Solution
Add management interface jdk.management.HotSpotAOTCacheMXBean to the jdk.management module to provide an operation endRecording() that would end the AOT recording and create the AOT cache and/or configuration file. As with any MXBean, the operation can be invoked either from within the application, or from an externally tool such as JConsole.
Specification
package jdk.management;
import java.lang.management.ManagementFactory;
import java.lang.management.PlatformManagedObject;
import javax.management.MBeanServer;
import javax.management.ObjectName;
/**
* Management interface for the JDK's Ahead of Time (AOT) Cache.
*
* <p> The management interface is registered with the platform {@link MBeanServer
* MBeanServer}. The {@link ObjectName ObjectName} that uniquely identifies the management
* interface within the {@code MBeanServer} is {@code jdk.management:type=HotSpotAOTCache}.
*
* <p> Direct access to the MXBean interface can be obtained with
* {@link ManagementFactory#getPlatformMXBean(Class)}.
*
* @since 26
*/
public interface HotSpotAOTCacheMXBean extends PlatformManagedObject {
/**
* If an AOT recording is in progress, ends the recording. This method returns
* after the AOT artifacts have been completely written.
*
* <p>The JVM will start recording AOT artifacts upon start-up if appropriate JVM options are
* given in the command-line. The recording will stop when the JVM exits, or when
* the {@code endRecording} method is called. Examples:
*
* <p> ${@code java -XX:AOTCacheOutput=app.aot ....}
*
* <blockquote>
* The JVM records optimization information for the current application in the AOT cache file
* {@code app.aot}. In a future run of the application, the option {@code -XX:AOTCache=app.aot} will
* cause the JVM to use the cache to improve the application's startup and warmup performance.
* </blockquote>
*
* <p> ${@code java -XX:AOTMode=record -XX:AOTConfiguration=app.aotconfig ....}
*
* <blockquote>
* The JVM records optimization information for the current application in the AOT configuration
* file {@code app.aotconfig}. Subsequently, an AOT cache file can be created with the command:
*
* <p>${@code java -XX:AOTMode=create -XX:AOTConfiguration=app.aotconfig -XX:AOTCache=app.aot ...}
* </blockquote>
*
* <p>For more information about creating and using the AOT artifacts, and detailed
* specification of the corresponding JVM command-line options, please refer
* to <a href="https://openjdk.org/jeps/483">JEP 483</a> and <a href="https://openjdk.org/jeps/514">JEP 514</a>.
*
* <p>Currently there are no APIs to start an AOT recording. AOT recordings must be
* started using JVM command-line options such as {@code -XX:AOTCacheOutput}.
* There are also no APIs to query whether an AOT recording is in progress, or what AOT
* artifacts are being recorded.
*
* <p> This method enables an application to end its own AOT recording
* programatically, but that is not necessarily the best approach. Doing so
* requires changing the application’s code, which might not be
* feasible. Even when it is feasible, injecting training-specific logic
* into the application reduces the similarity between training runs and
* production runs, potentially making the AOT cache less effective. It may
* be better to arrange for an external agent to end the training run,
* thereby creating an AOT cache without interfering with the application’s
* code.
*
* @return {@code true} if a recording was in progress and has been ended
* successfully; {@code false} otherwise.
*/
public boolean endRecording();
}
- csr of
-
JDK-8369736 Add management interface for AOT cache creation
-
- Resolved
-