开发者

Java profiling: detect which piece of code causes high CPU load

I profiled my code with both JProfiler and YourKit. However, I haven't been able to figure out how to detect which piece of code is responsible for high CPU load.

It's trivial to detect hot spots if the response time is bad. In my case though response time is not a problem. It's just that the CPU load is really high (surprisingly high) during t开发者_运维百科he short time this particular request is processed.

How can I pin-point which class(es)/method(s) are causing this? I guess what I'm looking for is some kind of list which tells me how many CPU cycles the processing of a method required - or so.


CPU load essentially indicates the number of cpu cycles where the cpu had something to do instead of just twiddling virtual thumbs.

So if your request actually does real work (instead of waiting for disk I/O) then it is to be expected that the load goes high while the work is being done as the cpu has something to do.

The thing you need to look for is running out of cpu cycles as that is when the response times start climbing.

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


While it's processing, it's at 100%. While it's waiting (such as for I/O) it's at 0%. There is no in-between. When a process takes less than 100%, that is a rolling average over the last N milliseconds.

If there is a way to make it more efficient, that will make it take less time, not less percent (necessarily).

If you want to find a way to make it take less time, give it sufficient workload and try this.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜