Summary
Introduce JVMTI feature to support tracking total GC CPU time.
Problem
Users are interested in tracking GC CPU time with JVMTI agents.
Solution
Introduce new JVMTI API's:
- new capability: can_get_gc_cpu_time
- new JVMTI functions: GetGCCpuTimerInfo, GetTotalGCCpuTime
Specification
New JVMTI API's include:
- new capability: can_get_gc_cpu_time
- new functions:
- jvmtiError GetGCCpuTimerInfo(jvmtiEnv* env, jvmtiTimerInfo* info_ptr)
- jvmtiError GetTotalGCCpuTime(jvmtiEnv* env, jlong* nanos_ptr)
The JVMTI spec update is:
<TBD: To add JVMTI spec-diff>
The src/hotspot/share/prims/jvmti.xml
diff is:
@@ -10520,10 +10520,16 @@
<description>
Can <functionlink id="GetThreadCpuTime">get</functionlink>
thread CPU time
</description>
</capabilityfield>
+ <capabilityfield id="can_get_gc_cpu_time" since="26">
+ <description>
+ Can <functionlink id="GetTotalGCCpuTime">get</functionlink>
+ GC CPU time
+ </description>
+ </capabilityfield>
<capabilityfield id="can_generate_method_entry_events"
disp1="can_generate" disp2="_method_entry_events"
>
<description>
Can generate method entry events on entering a method
@@ -11223,10 +11229,72 @@
</parameters>
<errors>
</errors>
</function>
+ <function id="GetGCCpuTimerInfo" phase="any" callbacksafe="safe" num="157" since="26">
+ <synopsis>Get Total GC Cpu Timer Information</synopsis>
+ <description>
+ Get information about the
+ <functionlink id="GetTotalGCCpuTime"/> timer.
+ The fields of the <datalink id="jvmtiTimerInfo"/> structure
+ are filled in with details about the timer.
+ This information will not change during a particular invocation of the VM.
+ </description>
+ <origin>new</origin>
+ <capabilities>
+ <required id="can_get_gc_cpu_time">
+ Can get GC cpu time.
+ </required>
+ </capabilities>
+ <parameters>
+ <param id="info_ptr">
+ <outptr><struct>jvmtiTimerInfo</struct></outptr>
+ <description>
+ On return, filled with information describing the time
+ returned by <functionlink id="GetTotalGCCpuTime"/>.
+ </description>
+ </param>
+ </parameters>
+ <errors>
+ </errors>
+ </function>
+
+ <function id="GetTotalGCCpuTime" phase="any" callbacksafe="safe" num="158" since="26">
+ <synopsis>Get Total GC CPU Time</synopsis>
+ <description>
+ Return the current value of the total GC CPU timer, in nanoseconds.
+ <p/>
+ The value returned represents nanoseconds since some fixed but
+ arbitrary time (perhaps in the future, so values may be
+ negative). This function provides nanosecond precision, but not
+ necessarily nanosecond accuracy. No guarantees are made about
+ how frequently values change.
+ <p/>
+ Get information about this timer with
+ <functionlink id="GetGCCpuTimerInfo"/>.
+ </description>
+ <origin>new</origin>
+ <capabilities>
+ <required id="can_get_gc_cpu_time">
+ Can get GC cpu time.
+ </required>
+ </capabilities>
+ <parameters>
+ <param id="nanos_ptr">
+ <outptr><jlong/></outptr>
+ <description>
+ On return, points to the time in nanoseconds.
+ This is an unsigned value. If tested or printed as a jlong (signed value)
+ it may appear to be a negative number.
+ </description>
+ </param>
+ </parameters>
+ <errors>
+ </errors>
+ </function>
+
- csr of
-
JDK-8369449 Spec: introduce new JVMTI function GetTotalGCCpuTime
-
- In Progress
-