# Any tools can reveal why CPU usage is 100%



## redriver (Dec 17, 2015)

I encountered a performance bottleneck issue. When testing my developed network driver, I found the CPU usage of iperf3(1) can reach 100%. I'd like to know the hotspot of my code, is there any good tool in FreeBSD can help?

By the way, the network driver is developed for Hyper-v VM, so pmcstat(8) does not work. I guess dtrace(1) may help, but I'm not familiar with it and does not find a DTrace script which can give the process's hotspot.


----------



## tobik@ (Dec 17, 2015)

There are example DTrace scripts that ship with FreeBSD that might help: /usr/share/dtrace/toolkit/{procsystime,hotuser,hotkernel}

Also see this recent Thread freebsd-perf-stat-equivalent.54328.


----------



## redriver (Dec 18, 2015)

Oh, I remember there is an existing builtin DTrace script which can give hot spot. Thanks for reminder. Thanks for sharing the Brendan Gregg's slides and video.

I have gone through some tools mentioned in the diagram, but I don't think any of them can reveal the hotspot. I also found ktrace(1)'s output is still not useful even if I used kdump(1) to dump ktrace.out. I cannot find the hotspot, so only /usr/share/dtrace/toolkit/hotkernel gives me some helpful output.


----------

