I have a web application that is taking for longer than it should to perform a specific task. I place the web application under load using ab with a concurrency of one, and I see tomcat using 100% of one CPU. I want to drill down into the application and answer the question "what is this java code doing to cause the java code to burn 100% of a CPU?".
I have tried to use Java Flight Recorder as follows to record my application in full flight as follows:
-sh-4.1$ jcmd 115388 JFR.start duration=60s filename=/tmp/app-service-live.jfr settings=profile
Loading the resulting JFR file into VisualVM gives me the following:
As can be seen in the screenshot, despite only one thread being red hot while recording, all threads are marked as red hot. Drilling down into one of the red hot threads, VisualVM reports us as burning hot inside the sun.misc.Unsafe.park() method. This method is not red hot, but stone cold.
With no way to tell the difference between hot code contributing to the 100% CPU figure, and stone cold code that is blocked waiting for an external event, there is no coherent picture that emerges.
What changes do I need to make to my jcmd command line to properly capture what the CPU is doing?
What alternative process do I need to follow inside VisualVM to find hot code, while eliminating cold code?