Java Profiling: Determining Which Part of the Code Causes High CPU Utilization

I have profiled my code for both JProfiler and YourKit. However, I could not figure out how to determine which part of the code is responsible for the high processor load.

It is trivial to detect hot spots if the response time is poor. In my case, although response time is not a problem. It is simply that the processor load is really high (surprisingly high) for the short time that this particular request handles.

How can I indicate which class (s) / method calls this? I guess I'm looking for some kind of list that tells me how many CPU cycles the required method is processing - or so.

+6
source share
2 answers

The processor load essentially indicates the number of processor cycles in which the processor had to do something, and not just twist the virtual thumbs.

So, if your request really does the real work (instead of waiting for I / O to disk), then you should expect that the load will be high while the work is done, because the processor has something to do.

What you need to look for ends with processor cycles, since this is the time when the response time starts to rise.

If your problem is that the request is so short that the profiler cannot show you what you need to see, then think about using an automated tool to ask it to process hundreds of thousands of requests. This should help.

+5
source

While it is being processed, it is 100%. While it is waiting (for example, for I / O), it is 0%. Between them, no. When the process takes up less than 100%, this is the moving average for the last milliseconds.

If there is a way to make it more effective, it will make it take less time, at least percent (required).

If you want to find a way to do this, it will take less time, give it enough workload and try it .

+1
source

Source: https://habr.com/ru/post/887556/


All Articles