Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Go pprof not working properly

Tags:

go

I'm trying to get pprof working with Golang.

--text seems to work fine but most of other options does not work.

For instance with pdf:

root@ubuntu:/home/user/IdeaProjects/go_projects/src# go tool pprof --pdf ./src /tmp/profile578584736/cpu.pprof > out.pdf
sh: 1: dot: not found
root@ubuntu:/home/user/IdeaProjects/go_projects/src# 

With gv:

root@ubuntu:/home/user/IdeaProjects/go_projects/src# go tool pprof --gv ./src /tmp/profile578584736/cpu.pprof 
sh: 1: dot: not found
gv -scale 0
Can't exec "gv": No such file or directory at /usr/local/go/pkg/tool/linux_386/pprof line 719.
root@ubuntu:/home/user/IdeaProjects/go_projects/src# 

Is there something that I need to change in Go to get it working?

like image 923
Passionate Engineer Avatar asked Oct 06 '14 12:10

Passionate Engineer


People also ask

What does pprof do?

pprof is a tool for visualization and analysis of profiling data. pprof reads a collection of profiling samples in profile. proto format and generates reports to visualize and help analyze the data. It can generate both text and graphical reports (through the use of the dot visualization package).

What is pprof golang?

Pprof interprets and displays profiles of Go programs. Basic usage: go tool pprof binary profile. For detailed usage information: go tool pprof -h. For an example, see https://blog.golang.org/profiling-go-programs.

Which of the following package can be used to find memory usage for go program?

To check the CPU and memory usage and other profiles of a Go application at runtime, we can use `pprof` package. You can check for the following details at runtime based on the profile you chose: CPU. Memory/Heap.


3 Answers

For anyone on a Mac using homebrew that comes across this question:

brew install graphviz
like image 70
Conor Avatar answered Oct 22 '22 07:10

Conor


You need dot and gv installed. I see you're using Ubuntu, just try apt-get install graphviz gv

like image 33
Not_a_Golfer Avatar answered Oct 22 '22 06:10

Not_a_Golfer


Got a similar error on Windows 10. I fixed it by installing graphviz from here https://graphviz.org/download/. After that I restarted my IDE, issued the pdf and png commands and everything worked

like image 1
Siraf Avatar answered Oct 22 '22 07:10

Siraf