Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Show counts of function calls in golang pprof

For profing program I use the following command:

go tool pprof http://localhost:6060/debug/pprof/profile

As a result in web mode I get this picture: enter image description here

How is it possible to show the number of function calls, not the time spent inside of this function like on the same pictures from golang blog? enter image description here

P.S There is a similar question. But how to do it only with pprof (without kcachegrind and other tools)?

like image 770
Kenenbek Arzymatov Avatar asked Jul 05 '18 19:07

Kenenbek Arzymatov


People also ask

What does the row in the go tool pprof output mean?

In the go tool pprof output, there is a row for each function that appeared in a sample. The first two columns show the number of samples in which the function was running (as opposed to waiting for a called function to return), as a raw count and as a percentage of total samples.

What is pprof in Golang?

pprof is a tool for visualization and analysis of profiling data. analyze the data. It can generate both text and graphical reports (through the use of the dot visualization package). First, we need to add monitoring code in the golang program, and expose it through the http interface.

How to use go tool pprof to do a profiling?

To do the profiling, we can call the /debug/pprof/profile and specify how long it will run in the seconds parameter, then save the result in a file. This is the command for that using curl: Wait until the profiling finish and then we can analyze the result. Now that we have the pprof file, we can analyze it using go tool pprof.

When to use multi-coroutine concurrency in Golang?

When using golang to write complex projects, it is often useful to use multi-coroutine concurrency scenarios. At this time, it is easy to cause the problem of coroutine leaks due to negligence, and then produce similar memory leaks. This program memory. pprof is a tool for visualization and analysis of profiling data. analyze the data.


1 Answers

Golang's profiling works by calculating function appear count in stacks, once per sample time window. It doesnot get calls and calleds, but rather get seen calls and seens calleds. So in fact it can't give call count, but can give time spending which is different.

like image 66
menghan Avatar answered Sep 21 '22 12:09

menghan