JDK-8198691 : CodeHeap State Analytics
  • Type: Enhancement
  • Component: hotspot
  • Sub-Component: compiler
  • Affected Version: 11
  • Priority: P4
  • Status: Resolved
  • Resolution: Fixed
  • OS: generic
  • CPU: generic
  • Submitted: 2018-02-26
  • Updated: 2024-10-14
  • Resolved: 2018-03-26
The Version table provides details related to the release that this issue/RFE will be addressed.

Unresolved : Release in which this issue/RFE will be addressed.
Resolved: Release in which this issue/RFE has been resolved.
Fixed : Release in which this issue/RFE has been fixed. The release containing this fix may be available for download as an Early Access Release or a General Availability Release.

To download the current JDK release, click here.
JDK 11
11 b10Fixed
Related Reports
Relates :  
Relates :  
Relates :  
Relates :  
Relates :  
Relates :  
Relates :  
Relates :  
Relates :  
Relates :  
Relates :  
Relates :  
Relates :  
Relates :  
Relates :  
Relates :  
Sub Tasks
JDK-8199213 :  
Description
There are occasions when some insight into the current state of the JVM code heap would be helpful to answer questions like
 * Why is the JIT turned off and then on again and again?
 * Where has all the code heap space gone?
 * Why is the method sweeper not working effectively?

Implement an on-the-fly analysis of the code heap. Trigger analysis and output via command-line parameter (state when vm shuts down) and via jcmd (at any time). 
Comments
URL: http://hg.openjdk.java.net/jdk/jdk/rev/973c9504178e User: jwilhelm Date: 2018-04-13 02:03:43 +0000
13-04-2018

URL: http://hg.openjdk.java.net/jdk/hs/rev/973c9504178e User: kvn Date: 2018-03-26 19:55:17 +0000
26-03-2018

All tests passed.
26-03-2018

Latest webrev: http://cr.openjdk.java.net/~lucy/webrevs/8198691.03/index.html
26-03-2018

I've executed some quick testing and hit the following build failures: jib > t:/workspace/open/src/hotspot/share/memory/heap.cpp(1710) : warning C4101: 'frameLine' : unreferenced local variable jib > t:/workspace/open/src/hotspot/share/memory/heap.cpp(1711) : warning C4101: 'textLine' : unreferenced local variable jib > t:/workspace/open/src/hotspot/share/memory/heap.cpp(1922) : warning C4101: 'frameLine' : unreferenced local variable jib > t:/workspace/open/src/hotspot/share/memory/heap.cpp(1923) : warning C4101: 'textLine' : unreferenced local variable jib > t:/workspace/open/src/hotspot/share/memory/heap.cpp(2094) : warning C4101: 'frameLine' : unreferenced local variable jib > t:/workspace/open/src/hotspot/share/memory/heap.cpp(2095) : warning C4101: 'textLine' : unreferenced local variable jib > t:/workspace/open/src/hotspot/share/memory/heap.cpp(2282) : warning C4101: 'frameLine' : unreferenced local variable jib > t:/workspace/open/src/hotspot/share/memory/heap.cpp(2283) : warning C4101: 'textLine' : unreferenced local variable jib > t:/workspace/open/src/hotspot/share/memory/heap.cpp(2479) : warning C4101: 'frameLine' : unreferenced local variable jib > t:/workspace/open/src/hotspot/share/memory/heap.cpp(2480) : warning C4101: 'textLine' : unreferenced local variable jib > t:/workspace/open/src/hotspot/share/memory/heap.cpp(2699) : warning C4267: '+=' : conversion from 'size_t' to 'int', possible loss of data jib > t:/workspace/open/src/hotspot/share/memory/heap.cpp(2700) : warning C4267: '+=' : conversion from 'size_t' to 'int', possible loss of data jib > * For target hotspot_variant-server_libjvm_objs_heap.o: jib > /scratch/mesos/slaves/555f5737-a945-4eb0-8d30-afb1fc816afd-S70/frameworks/1735e8a2-a1db-478c-8104-60c8b0af87dd-0196/executors/f3734fdc-8383-4ced-880d-32e03ccf13c3/runs/2dff03d3-d722-4122-a2e2-bb2a56cd1be4/workspace/open/src/hotspot/share/memory/heap.cpp:907:12: error: destination for this 'memset' call is a pointer to dynamic class 'StatElement'; vtable pointer will be overwritten [-Werror,-Wdynamic-class-memaccess] jib > memset(StatArray, 0, nElem*sizeof(StatElement)); jib > ~~~~~~ ^ jib > /scratch/mesos/slaves/555f5737-a945-4eb0-8d30-afb1fc816afd-S70/frameworks/1735e8a2-a1db-478c-8104-60c8b0af87dd-0196/executors/f3734fdc-8383-4ced-880d-32e03ccf13c3/runs/2dff03d3-d722-4122-a2e2-bb2a56cd1be4/workspace/open/src/hotspot/share/memory/heap.cpp:907:12: note: explicitly cast the pointer to silence this warning jib > memset(StatArray, 0, nElem*sizeof(StatElement)); jib > ^ jib > (void*) jib > /scratch/mesos/slaves/555f5737-a945-4eb0-8d30-afb1fc816afd-S70/frameworks/1735e8a2-a1db-478c-8104-60c8b0af87dd-0196/executors/f3734fdc-8383-4ced-880d-32e03ccf13c3/runs/2dff03d3-d722-4122-a2e2-bb2a56cd1be4/workspace/open/src/hotspot/share/memory/heap.cpp:925:12: error: destination for this 'memset' call is a pointer to dynamic class 'FreeBlk'; vtable pointer will be overwritten [-Werror,-Wdynamic-class-memaccess] jib > memset(FreeArray, 0, alloc_freeBlocks*sizeof(FreeBlk)); jib > ~~~~~~ ^ jib > /scratch/mesos/slaves/555f5737-a945-4eb0-8d30-afb1fc816afd-S70/frameworks/1735e8a2-a1db-478c-8104-60c8b0af87dd-0196/executors/f3734fdc-8383-4ced-880d-32e03ccf13c3/runs/2dff03d3-d722-4122-a2e2-bb2a56cd1be4/workspace/open/src/hotspot/share/memory/heap.cpp:925:12: note: explicitly cast the pointer to silence this warning jib > memset(FreeArray, 0, alloc_freeBlocks*sizeof(FreeBlk)); jib > ... (rest of output omitted) jib > jib > * All command lines available in /scratch/mesos/slaves/555f5737-a945-4eb0-8d30-afb1fc816afd-S70/frameworks/1735e8a2-a1db-478c-8104-60c8b0af87dd-0196/executors/f3734fdc-8383-4ced-880d-32e03ccf13c3/runs/2dff03d3-d722-4122-a2e2-bb2a56cd1be4/workspace/build/macosx-x64-debug/make-support/failure-logs. Also, the following tests fail: compiler/aot/verification/ClassAndLibraryNotMatchTest.java compiler/aot/verification/vmflags/NotTrackedFlagTest.java compiler/aot/verification/vmflags/TrackedFlagTest.java compiler/aot/cli/jaotc/ListOptionWrongFileTest.java compiler/aot/cli/jaotc/ListOptionTest.java # SIGFPE (0x8) at pc=0x00007fbf9231a837, pid=9709, tid=9712 # # JRE version: Java(TM) SE Runtime Environment (11.0) (fastdebug build 11-internal+0-2018-03-06-1030006.tobias.hartmann.jdkhs) # Java VM: Java HotSpot(TM) 64-Bit Server VM (fastdebug 11-internal+0-2018-03-06-1030006.tobias.hartmann.jdkhs, mixed mode, aot, tiered, compressed oops, g1 gc, linux-amd64) # Problematic frame: # V [libjvm.so+0xe2a837] CodeHeap::aggregate(outputStream*, char const*)+0xe7
06-03-2018

I agree with Robbin, that we should use unified logging. Probably, this should also be integrated with JFR (see JDK-8075796 and JDK-8087107).
02-03-2018

Note that we are removing the XX:*Print* options. You should use unified logging: http://openjdk.java.net/jeps/158 E.g. -Xlog:compiler+codeheap=trace or similar.
02-03-2018

I have added some documentation on how to use and how to interpret the CodeHeap state analytics. I hope the document proved useful. Comments/suggestions welcome.
01-03-2018

I have attached a ZIP archive which contains _sample_ output for the CodeHeap state analytics. The test sets were run with and without SegmentedCodeCache. The output was generated by SAP's own JVM. Therefore, some very minor SAP specifics are contained. There will also be some textual documentation to help interpret the output.
27-02-2018

I think it would be good to add information about the fragmentation of the code heap(s) as well. I've always expected that a high fragmentation can lead to the JIT being disabled (because a single large allocation fails) although there is still lots of free space. Related enhancement that you might want to close as duplicate JDK-8005885.
26-02-2018