Use pprof to do CPU, Memory profiling can help you understand the runtime status of YuniKorn scheduler. Profiling instruments have been
added to YuniKorn rest service, we can easily retrieve and analyze them from HTTP
endpoints.
At this step, ensure you already have YuniKorn running, it can be either running from
local via a make run command, or deployed as a pod running inside of K8s. Then run
go tool pprof http://localhost:9080/debug/pprof/profile
The profile data will be saved on local file system, once that is done, it enters into
the interactive mode. Now you can run profiling commands, such as
(pprof) top
Showing nodes accounting for 14380ms, 44.85% of 32060ms total
you can type command such as web or gif to get a graph that helps you better
understand the overall performance on critical code paths. You can get something
like below:
Note, in order to use these
options, you need to install the virtualization tool graphviz first, if you are using Mac, simply run brew install graphviz, for more info please refer here.
go tool pprof http://localhost:9080/debug/pprof/heap
this will return a snapshot of current heap which allows us to check memory usage.
Once it enters the interactive mode, you can run some useful commands. Such as
top can list top memory consumption objects.
(pprof) top
Showing nodes accounting for 83.58MB, 98.82% of 84.58MB total
you can also run web, pdf or gif command to get the graph for heap.
Download profiling samples and analyze it locally#
We have included essential go/go-tool binaries in scheduler docker image, you should be able to do some basic profiling
analysis inside of the docker container. However, if you want to dig into some issues, it might be better to do the analysis
locally. Then you need to copy the samples file to local environment first. The command to copy files is like following: